Skip to content

Commit 128cf36

Browse files
committed
Modify query_player to work with move representations that are strings
1 parent 5e54a04 commit 128cf36

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

games.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ def min_value(state, alpha, beta, depth):
137137
def query_player(game, state):
138138
"Make a move by querying standard input."
139139
game.display(state)
140-
return eval(input('Your move? '))
140+
move_string = input('Your move? ')
141+
try:
142+
move = eval(move_string)
143+
except NameError:
144+
move = move_string
145+
return move
141146

142147

143148
def random_player(game, state):

0 commit comments

Comments
 (0)