Commit eb1c00fc authored by Ahmad Reza's avatar Ahmad Reza
Browse files

Moved the scenario calling from world.py and into swarm-sim.py

parent 3db8d81b
......@@ -52,15 +52,6 @@ class World:
seed=config_data.seed_value,
directory=config_data.direction_name)
mod = importlib.import_module('scenario.' + self.config_data.scenario)
mod.scenario(self)
if self.config_data.particle_random_order:
random.shuffle(self.particles)
if config_data.visualization:
self.window = vis.VisWindow(config_data.window_size_x, config_data.window_size_y, self)
def csv_aggregator(self):
self.csv_round.aggregate_metrics()
particle_csv = csv_generator.CsvParticleFile(self.config_data.direction_name)
......
......@@ -6,7 +6,7 @@ import os
import sys
import time
import random
from lib import world, config
from lib import world, config, vis
from lib.gnuplot_generator import gnuplot_generator
......@@ -27,11 +27,16 @@ def swarm_sim(argv):
swarm_sim_world = world.World(config_data)
draw_scenario(config_data, swarm_sim_world)
if config_data.visualization:
window = vis.VisWindow(config_data.window_size_x, config_data.window_size_y, swarm_sim_world)
while swarm_sim_world.get_actual_round() <= config_data.max_round and swarm_sim_world.get_end() is False:
round_start_timestamp = time.perf_counter()
if config_data.visualization:
swarm_sim_world.window.draw_world(round_start_timestamp)
if swarm_sim_world.window.window_active is False:
window.draw_world(round_start_timestamp)
if window.window_active is False:
break
run_solution(swarm_sim_world)
......@@ -42,6 +47,13 @@ def swarm_sim(argv):
logging.info('Finished')
def draw_scenario(config_data, swarm_sim_world):
mod = importlib.import_module('scenario.' + config_data.scenario)
mod.scenario(swarm_sim_world)
if config_data.particle_random_order:
random.shuffle(swarm_sim_world.particles)
def read_cmd_args(argv, config_data):
try:
opts, args = getopt.getopt(argv, "hs:w:r:n:m:d:v:", ["solution=", "scenario="])
......
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