diff --git a/pyclient/__init__.py b/pyclient/__init__.py index b80fe32..0bed8f7 100644 --- a/pyclient/__init__.py +++ b/pyclient/__init__.py @@ -60,7 +60,7 @@ class PyClient: agent = agents[player-1] payload = agent.poll( game=current_state.action_name(), - payload=current_state.to_dict(), + payload=current_state.as_seen_by(player), timeout=timeout, ) diff --git a/pyclient/games/tic_tac_toe.py b/pyclient/games/tic_tac_toe.py index 8e109ae..a720287 100644 --- a/pyclient/games/tic_tac_toe.py +++ b/pyclient/games/tic_tac_toe.py @@ -171,6 +171,17 @@ class TicTacToe: def action_name(self): return "/tic-tac-toe" + + def as_seen_by(self, player : int) -> Dict[str, Any]: + """ + Return the view of the game from the perspective of a given player. + + :param player: The perspective on the board. + :type player: int + """ + out = self.to_dict() + out["your_token"] = str(Field.X) if player == 1 else str(Field.O) + return out def count_o(self) -> int: """