Commit c3a91e1f authored by Karol Actun's avatar Karol Actun
Browse files

merge with master

parents a7ebadfa eb1c00fc
......@@ -261,6 +261,9 @@ class Visualization:
self._viewer.marker_update_flag = True
self._viewer.marker_offset_data[marker] = (marker.coordinates, marker.color)
def update_visualization_data(self):
self._viewer.update_data()
# setters and getters for various variables in the visualization
def set_rounds_per_second(self, rounds_per_second):
......
......@@ -24,25 +24,27 @@ class World:
self.init_particles = []
self.particle_id_counter = 0
self.particles = []
self.particles_created = []
self.particle_rm = []
self.particle_map_coordinates = {}
self.particle_map_id = {}
self.particles_created = []
self.particle_rm = []
self.__particle_deleted = False
self.new_particle = None
self.tiles = []
self.tiles_created = []
self.tiles_rm = []
self.tile_map_coordinates = {}
self.tile_map_id = {}
self.tiles_created = []
self.tiles_rm = []
self.__tile_deleted = False
self.new_tile = None
self.__tile_deleted = False
self.markers = []
self.markers_created = []
self.marker_map_coordinates = {}
self.marker_map_id = {}
self.markers_created = []
self.markers_rm = []
self.__marker_deleted = False
self.new_marker = None
......@@ -114,7 +116,8 @@ class World:
# if visualization is on, run the scenario in a separate thread and show that the program runs..
x = threading.Thread(target=mod.scenario, args=(self,))
self.vis.wait_for_thread(x, "loading scenario... please wait.", "Loading Scenario")
self.vis._viewer.update_data()
self.vis.update_visualization_data()
else:
# if no vis, just run the scenario on the main thread
mod.scenario(self)
......@@ -340,6 +343,7 @@ class World:
self.new_particle.created = True
logging.info("Created particle at %s", self.new_particle.coordinates)
return self.new_particle
else:
logging.info("there is already a particle on %s" % str(coordinates))
return False
......@@ -387,7 +391,6 @@ class World:
def add_tile(self, coordinates, color=None):
"""
Adds a tile to the world database
:param color: color of the tile (None for config default)
:param coordinates: the coordinates on which the tile should be added
:return: Successful added matter; False: Unsuccessful
......@@ -410,6 +413,7 @@ class World:
logging.info("Created tile with tile id %s on coordinates %s",
str(self.new_tile.get_id()), str(coordinates))
return self.new_tile
else:
logging.info("there is already a tile on %s " % str(coordinates))
return False
......
......@@ -6,7 +6,7 @@ import os
import sys
import time
import random
from lib import world, config
from lib import world, config, vis3d
from lib.gnuplot_generator import gnuplot_generator
......@@ -25,16 +25,27 @@ def swarm_sim(argv):
random.seed(config_data.seed_value)
swarm_sim_world = world.World(config_data)
round_start_timestamp = time.perf_counter()
while (config_data.max_round == 0 or 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.vis.run(round_start_timestamp)
round_start_timestamp = time.perf_counter()
run_solution(swarm_sim_world)
logging.info('Finished')
# generate_data(config_data, swarm_sim_world)
generate_data(config_data, swarm_sim_world)
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):
......
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