def swap_images(self, agent_index, new_state): """Change an image from a ghost to a pacman or vice versa. Used for capture the flag. """ prev_state, prev_image = self.agent_images[agent_index] for item in prev_image: gu.remove_from_screen(item) if new_state.is_pacman: image = self.draw_pacman(new_state, agent_index) self.agent_images[agent_index] = (new_state, image) else: image = self.draw_ghost(new_state, agent_index) self.agent_images[agent_index] = (new_state, image) gu.refresh()
def clear_expanded_cells(self): """Clear expanded cells (used for search agents).""" if 'expanded_cells' in dir(self) and len(self.expanded_cells) > 0: for cell in self.expanded_cells: gu.remove_from_screen(cell)
def remove_capsule(self, cell, capsule_images): """Remove capsule from the screen in given cell.""" x, y = cell gu.remove_from_screen(capsule_images[(x, y)])
def remove_food(self, cell, food_images): """Remove food from the screen in given cell.""" x, y = cell gu.remove_from_screen(food_images[x][y])
def clear_debug(self): """Clear any debig display.""" if 'expanded_cells' in dir(self) and len(self.expanded_cells) > 0: for cell in self.expanded_cells: gu.remove_from_screen(cell)