class Car: character = 'O' def __init__(self, position): self.position = position self.next = None def play_turn(self, game): lives = 3 width, height = game.board_size if game.turn_number % 3 == 0: x, y = self.position if x == width - 1: game.remove_agent(self) game.remove_agent(self.next) else: person = game.get_agent_by_name('person') new_position = (x+1, y) if new_position == person.position: lives = lives-1 game.state["lives"] -=1 if game.state["lives"] == 0: game.end() else: self.next.position = self.position self.position = new_position