from fruit import Fruit, SHAPE_DEFINITIONS from random import choice from retro.errors import AgentNotFoundByName class FruitManager: display = False def play_turn(self, game): try: game.get_agent_by_name("fruit") except AgentNotFoundByName: self.create_piece(game) def create_piece(self, game): fruit = Fruit((14, 1), game, choice(SHAPE_DEFINITIONS)) game.add_agent(fruit)