@@ -60,10 +60,11 @@ class Engine:
6060 while not engine.completed:
6161 state = engine.play_next()
6262
63- This plays a turn for each player, one after another, until the
64- game is complete. Other, more fine-grained methods exist if you
65- need to structure game play differently for your purposes (for
66- instance, to train a machine learning model).
63+ This synchronously plays a turn for each player, one after another, until
64+ the game is complete. Other, more fine-grained methods exist if you need
65+ to structure game play differently for your purposes (for instance, to
66+ train a machine learning model or to play the game in an asynchronous
67+ event-driven environment).
6768
6869 Attributes:
6970 mode(GameMode): The game mode
@@ -157,9 +158,18 @@ def start_game(self) -> Game:
157158 self ._rules .start_game (self ._game )
158159 return self ._game
159160
161+ def next_turn (self ) -> Tuple [PlayerColor , Character ]:
162+ """
163+ Get the color and character for the next turn
164+ This will give you a different player each time you call it.
165+ """
166+ color = self ._queue .next ()
167+ character = self ._map [color ]
168+ return color , character
169+
160170 def play_next (self ) -> Game :
161171 """
162- Play the next turn of the game, returning initial game state.
172+ Play the next turn of the game, returning game state as of the end of the turn .
163173
164174 Returns:
165175 Game: Current state of the game.
@@ -169,8 +179,7 @@ def play_next(self) -> Game:
169179
170180 saved = self ._game .copy ()
171181 try :
172- color = self ._queue .next ()
173- character = self ._map [color ]
182+ color , character = self .next_turn ()
174183
175184 done = False
176185 while not done :
0 commit comments