Skip to content
Snippets Groups Projects
Commit 2a7ce437 authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

rendering city

parent d4488cbd
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,7 @@ class GraphicsLayer(object): ...@@ -65,7 +65,7 @@ class GraphicsLayer(object):
def get_cmap(self, *args, **kwargs): def get_cmap(self, *args, **kwargs):
return plt.get_cmap(*args, **kwargs) return plt.get_cmap(*args, **kwargs)
def set_rail_at(self, row, col, binTrans, iTarget=None, isSelected=False, rail_grid=None): def set_rail_at(self, row, col, binTrans, iTarget=None, isSelected=False, rail_grid=None, num_agents=None):
""" Set the rail at cell (row, col) to have transitions binTrans. """ Set the rail at cell (row, col) to have transitions binTrans.
The target argument can contain the index of the agent to indicate The target argument can contain the index of the agent to indicate
that agent's target is at that cell, so that a station can be that agent's target is at that cell, so that a station can be
......
...@@ -499,7 +499,7 @@ class PILSVG(PILGL): ...@@ -499,7 +499,7 @@ class PILSVG(PILGL):
False)[0] False)[0]
self.draw_image_row_col(colored_rail, (row, col), layer=PILGL.PREDICTION_PATH_LAYER) self.draw_image_row_col(colored_rail, (row, col), layer=PILGL.PREDICTION_PATH_LAYER)
def set_rail_at(self, row, col, binary_trans, target=None, is_selected=False, rail_grid=None, def set_rail_at(self, row, col, binary_trans, target=None, is_selected=False, rail_grid=None, num_agents=None,
show_debug=True): show_debug=True):
if binary_trans in self.pil_rail: if binary_trans in self.pil_rail:
...@@ -511,8 +511,12 @@ class PILSVG(PILGL): ...@@ -511,8 +511,12 @@ class PILSVG(PILGL):
if show_debug: if show_debug:
self.text_rowcol((row + 0.8, col + 0.0), strText=str(target), layer=PILGL.TARGET_LAYER) self.text_rowcol((row + 0.8, col + 0.0), strText=str(target), layer=PILGL.TARGET_LAYER)
city_size = 1
if num_agents is not None:
city_size = max(1,np.log(1+num_agents))
if binary_trans == 0: if binary_trans == 0:
if self.background_grid[col][row] <= 4 + ((col * row + col) % 10): if self.background_grid[col][row] <= 4 + np.ceil(((col * row + col) % 10)/city_size):
a = int(self.background_grid[col][row]) a = int(self.background_grid[col][row])
a = a % len(self.dBuildings) a = a % len(self.dBuildings)
if (col + row + col * row) % 13 > 11: if (col + row + col * row) % 13 > 11:
......
...@@ -529,7 +529,8 @@ class RenderTool(object): ...@@ -529,7 +529,8 @@ class RenderTool(object):
is_selected = False is_selected = False
self.gl.set_rail_at(r, c, transitions, target=target, is_selected=is_selected, self.gl.set_rail_at(r, c, transitions, target=target, is_selected=is_selected,
rail_grid=env.rail.grid, show_debug=self.show_debug) rail_grid=env.rail.grid, num_agents=env.get_num_agents(),
show_debug=self.show_debug)
self.gl.build_background_map(targets) self.gl.build_background_map(targets)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment