Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5e6a95

Browse files
committed
Fixed final utility in play_game().
1 parent c68651a commit c5e6a95

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

games.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,17 @@ def alphabeta_player(game, state):
124124
return alphabeta_search(state, game)
125125

126126
def play_game(game, *players):
127-
"Play an n-person, move-alternating game."
127+
"""Play an n-person, move-alternating game.
128+
>>> play_game(Fig62Game(), alphabeta_player, alphabeta_player)
129+
3
130+
"""
128131
state = game.initial
129132
while True:
130133
for player in players:
131134
move = player(game, state)
132135
state = game.make_move(move, state)
133136
if game.terminal_test(state):
134-
return game.utility(state, players[0])
137+
return game.utility(state, game.to_move(game.initial))
135138

136139
#______________________________________________________________________________
137140
# Some Sample Games
@@ -292,5 +295,5 @@ def legal_moves(self, state):
292295

293296
__doc__ += random_tests("""
294297
>>> play_game(Fig62Game(), random_player, random_player)
295-
-6
298+
6
296299
""")

0 commit comments

Comments
 (0)