Beispiel #1
0
def main():
    """ Main program function. """
    resources_path = Path(os.path.dirname(os.path.abspath(__file__))).parent / 'resource'
    print(resources_path)
    all_players = load_players(resources_path / 'players.json')
    simulator = Simulator(resources_path)
    simulator.run(all_players)
Beispiel #2
0
    def test_simultor_2_steps(self):
        simulator = Simulator()

        simulator.run(2)

        self.assertEqual(len(simulator.grid.cells), 2)

        for cell in simulator.grid.cells:
            self.assertEqual(simulator.grid.cells[cell].color, Color.BLACK)
Beispiel #3
0
    def put(self, steps):
        simulator = Simulator()

        simulator.run(steps)

        folder = 'simulations'
        filename = 'simulation-%d-%s' % (steps, uuid.uuid4())
        simulator.export_grid(os.path.join(folder, filename))

        return filename
Beispiel #4
0
    def test_simultor_1_step(self):
        simulator = Simulator()

        simulator.run(1)

        self.assertEqual(len(simulator.grid.cells), 1)

        element = list(simulator.grid.cells.keys())[0]

        self.assertEqual(element, Simulator.ORIGIN)
        self.assertEqual(simulator.grid.cells[element].color, Color.BLACK)

        self.assertEqual(simulator.robot.move_orientation, WindRose.EAST)
#! /usr/bin/env python2.7

import src.simulator
import sys

from src.simulator import Simulator
port = 0
if (len(sys.argv) == 3):
   if (sys.argv[1] == "-p"):
      port = int(sys.argv[2])
      print(port)
sim = Simulator(port)
sim.run()