Commit 377f1e62 authored by Ahmad Reza Cheraghi's avatar Ahmad Reza Cheraghi
Browse files

Replace sim.py

parent d0f9c981
......@@ -5,19 +5,21 @@ The sim module everything for the simulator is provided.
import importlib
import random
class Sim:
def __init__(self, seed=1, max_round=10, solution="None"):
def __init__(self, seed=1, max_round=10, scenario="None"):
"""
:param seed: seed number for new random numbers
:param max_round: the max round number for terminating the simulator
:param solution: The name of solution/scenario that is going to be used
"""
random.seed(seed)
self.__max_round = max_round
self.__round_counter = 1
self.__seed=seed
self.__solution = solution
self.__scenario = scenario
def get_max_round(self):
"""
......@@ -42,18 +44,27 @@ class Sim:
:return:
"""
self.__round_counter += 1
def run(self, world, scenario):
def get_scenario(self):
"""
actual scenario name
:return: actual scenario name
"""
return self.__scenario
def run(self, world):
"""
:param world: The worlds object
:param scenario: The name of the scenario file
:return:
"""
if scenario is not None:
mod = importlib.import_module('robotsOnTiles.scenarios.'+scenario.strip('.py'))
if self.get_scenario() is not None:
random.seed(self.__seed)
mod = importlib.import_module('robotsOnTiles.scenarios.'+self.get_scenario())
while self.get_actual_round() <= self.get_max_round():
mod.scenario(self, world)
world.csv_round_writer.next_line(self.get_actual_round())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment