diff --git a/py/game/Game.py b/py/game/Game.py index 1380822..fc3a23f 100644 --- a/py/game/Game.py +++ b/py/game/Game.py @@ -91,13 +91,9 @@ def get_action(self, board: Board) -> Action: return self.ai.on_suggest_action(board) else: suggestion = self.ai.on_suggest_action(board) - self.ai_suggested(suggestion) + self.player.on_ai_suggested(suggestion) return self.player.on_get_action(board) - def ai_suggested(self, suggestion: Action): - for listener in self.listeners: - listener.on_ai_suggested(suggestion) - def applied_action(self, action: Action, board: Board): for listener in self.listeners: listener.on_applied_action(action, board) diff --git a/py/game/GameComponent.py b/py/game/GameComponent.py index 14cd123..12fc98c 100644 --- a/py/game/GameComponent.py +++ b/py/game/GameComponent.py @@ -21,9 +21,6 @@ def on_inited(self, board: Board): def on_new_round(self, rounds: int): pass - def on_ai_suggested(self, suggestion: Action): - pass - def on_applied_action(self, action: Action, board: Board): pass @@ -53,6 +50,9 @@ def on_get_reaction(self, board: Board) -> Optional[Pop]: class GamePlayer(GameComponent): __metaclass__ = ABCMeta + def on_ai_suggested(self, suggestion: Action): + pass + @abstractmethod def on_get_action(self, board: Board) -> Action: pass diff --git a/py/ui/ConsoleUI.py b/py/ui/ConsoleUI.py index 4162c10..4c3164c 100644 --- a/py/ui/ConsoleUI.py +++ b/py/ui/ConsoleUI.py @@ -16,10 +16,6 @@ def on_new_round(self, rounds: int): print() print("Round", rounds) - def on_ai_suggested(self, suggestion: Action): - print() - print("AI suggested action:", suggestion) - def on_applied_action(self, action: Action, board: Board): print() print(board.matrix) @@ -38,6 +34,11 @@ def on_dead(self, rounds: int, board: Board): class ConsolePlayer(GamePlayer): + + def on_ai_suggested(self, suggestion: Action): + print() + print("AI suggested action:", suggestion) + def on_get_action(self, board: Board) -> Action: while True: print(board.matrix)