def key_r(self, event): cab_log.info('[TkIO] < simulation reset') self.core.reset_simulation() self.ui.clear_cell_shape_mapping() self.ui.clear_agent_shape_mapping() self.ui.init_cell_shape_mapping() self.ui.init_agent_shape_mapping()
def key_r(self, event): cab_log.info('[TkIO] < simulation reset') self.core.reset_simulation() self.ui.clear_cell_shape_mapping() self.ui.clear_agent_shape_mapping() self.ui.init_cell_shape_mapping() self.ui.init_agent_shape_mapping()
def reset_simulation(self): """ Re-call the initializers for ABM and CA to reset the CAB completely. TODO: Improve this, as not everything that can be modified is reset. """ cab_log.info('resetting simulation') self.abm.__init__(self.gc, proto_agent=self.proto_agent) self.ca.__init__(self, proto_cell=self.proto_cell) self.gc.TIME_STEP = 0
def reset_simulation(self): """ Re-call the initializers for ABM and CA to reset the CAB completely. TODO: Improve this, as not everything that can be modified is reset. """ cab_log.info('resetting simulation') self.abm.__init__(self.gc, proto_agent=self.proto_agent) self.ca.__init__(self, proto_cell=self.proto_cell) self.gc.TIME_STEP = 0
def mouse_right(self, event): cab_log.info('[TkIO] < right mouse button action') # Update current mouse coordinates. self.mouse_motion(event) # Retrieve correct location coordinates. if self.core.gc.USE_HEX_CA: pos_x, pos_y = self.get_mouse_hex_coords() else: pos_x, pos_y = self.get_mouse_rect_coords() cab_log.info('[TkIO] < triggering cell action') self.core.ca.ca_grid[pos_x, pos_y].on_rmb_click(self.core.abm, self.core.ca) if self.gc.ONE_AGENT_PER_CELL: if (pos_x, pos_y) in self.core.abm.agent_locations: # cab_log.info('[TkIO] < triggering agent action') self.core.abm.agent_locations[pos_x, pos_y].on_rmb_click(self.core.abm, self.core.ca) else: if (pos_x, pos_y) in self.core.abm.agent_locations: for agent in self.core.abm.agent_locations[pos_x, pos_y]: # cab_log.info('[TkIO] < triggering agent action') agent.on_rmb_click(self.core.abm, self.core.ca)
def mouse_right(self, event): cab_log.info('[TkIO] < right mouse button action') # Update current mouse coordinates. self.mouse_motion(event) # Retrieve correct location coordinates. if self.core.gc.USE_HEX_CA: pos_x, pos_y = self.get_mouse_hex_coords() else: pos_x, pos_y = self.get_mouse_rect_coords() cab_log.info('[TkIO] < triggering cell action') self.core.ca.ca_grid[pos_x, pos_y].on_rmb_click(self.core.abm, self.core.ca) if self.gc.ONE_AGENT_PER_CELL: if (pos_x, pos_y) in self.core.abm.agent_locations: # cab_log.info('[TkIO] < triggering agent action') self.core.abm.agent_locations[pos_x, pos_y].on_rmb_click( self.core.abm, self.core.ca) else: if (pos_x, pos_y) in self.core.abm.agent_locations: for agent in self.core.abm.agent_locations[pos_x, pos_y]: # cab_log.info('[TkIO] < triggering agent action') agent.on_rmb_click(self.core.abm, self.core.ca)
def mouse_wheel(self, event): cab_log.info('[TkIO] < mouse wheel action')
def key_g(self, event): self.gc.DISPLAY_GRID = not self.gc.DISPLAY_GRID if self.gc.DISPLAY_GRID: cab_log.info('[TkIO] > showing grid') else: cab_log.info('[TkIO] > hiding grid')
def key_q(self, event): cab_log.info('[TkIO] < shutting down... Bye!') sys.exit()
def key_s(self, event): cab_log.info('[TkIO] < stepping simulation') self.core.step_simulation()
def mouse_wheel(self, event): cab_log.info('[TkIO] < mouse wheel action')
def key_g(self, event): self.gc.DISPLAY_GRID = not self.gc.DISPLAY_GRID if self.gc.DISPLAY_GRID: cab_log.info('[TkIO] > showing grid') else: cab_log.info('[TkIO] > hiding grid')
def key_q(self, event): cab_log.info('[TkIO] < shutting down... Bye!') sys.exit()
def key_s(self, event): cab_log.info('[TkIO] < stepping simulation') self.core.step_simulation()
def key_space(self, event): self.core.gc.RUN_SIMULATION = not self.core.gc.RUN_SIMULATION if self.core.gc.RUN_SIMULATION: cab_log.info('[TkIO] < simulation resumed') else: cab_log.info('[TkIO] < simulation paused')
def default_keyboard_action(self, active_key: int): """ Method to process all the keyboard inputs. This is not supposed to be overwritten. """ if active_key == pygame.K_SPACE: self.core.gc.RUN_SIMULATION = not self.core.gc.RUN_SIMULATION if self.core.gc.RUN_SIMULATION: cab_log.info('[PyGameIO] < simulation resumed') else: cab_log.info('[PyGameIO] < simulation paused') # Simulation Standard: 'r' resets the simulation. if active_key == pygame.K_r: self.core.reset_simulation() cab_log.info('[PyGameIO] < simulation reset') # Simulation Standard: 's' advances the simulation by one step. if active_key == pygame.K_s: self.core.step_simulation() cab_log.info('[PyGameIO] < stepping simulation') # Simulation Standard: 'q' closes the simulation and visualization window. if active_key == pygame.K_q: cab_log.info('[PyGameIO] < shutting down simulation') sys.exit() # Simulation Standard: 'g' toggles grid outline of the cells. if active_key == pygame.K_g: self.core.gc.DISPLAY_GRID = not self.core.gc.DISPLAY_GRID if self.core.gc.DISPLAY_GRID: cab_log.info('[PyGameIO] > showing grid') else: cab_log.info('[PyGameIO] > hiding grid')
def default_keyboard_action(self, active_key: int): """ Method to process all the keyboard inputs. This is not supposed to be overwritten. """ if active_key == pygame.K_SPACE: self.core.gc.RUN_SIMULATION = not self.core.gc.RUN_SIMULATION if self.core.gc.RUN_SIMULATION: cab_log.info('[PyGameIO] < simulation resumed') else: cab_log.info('[PyGameIO] < simulation paused') # Simulation Standard: 'r' resets the simulation. if active_key == pygame.K_r: self.core.reset_simulation() cab_log.info('[PyGameIO] < simulation reset') # Simulation Standard: 's' advances the simulation by one step. if active_key == pygame.K_s: self.core.step_simulation() cab_log.info('[PyGameIO] < stepping simulation') # Simulation Standard: 'q' closes the simulation and visualization window. if active_key == pygame.K_q: cab_log.info('[PyGameIO] < shutting down simulation') sys.exit() # Simulation Standard: 'g' toggles grid outline of the cells. if active_key == pygame.K_g: self.core.gc.DISPLAY_GRID = not self.core.gc.DISPLAY_GRID if self.core.gc.DISPLAY_GRID: cab_log.info('[PyGameIO] > showing grid') else: cab_log.info('[PyGameIO] > hiding grid')
def key_space(self, event): self.core.gc.RUN_SIMULATION = not self.core.gc.RUN_SIMULATION if self.core.gc.RUN_SIMULATION: cab_log.info('[TkIO] < simulation resumed') else: cab_log.info('[TkIO] < simulation paused')