Skip to content

Commit

Permalink
moved on_ai_suggested() to GamePlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengKeli authored and keli committed Nov 25, 2018
1 parent ac235a2 commit 0aa75e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 1 addition & 5 deletions py/game/Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions py/game/GameComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions py/ui/ConsoleUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 0aa75e0

Please sign in to comment.