OK! If you run game.py in /amazon-works, you should be able to play without errors, he said confidently.

This commit is contained in:
Finn Goehrig 2023-06-29 14:39:41 -04:00
parent 56f1eb564c
commit 18553340f2
3 changed files with 21 additions and 7 deletions

View File

@ -10,27 +10,41 @@ translator = {
'd4':[0,3], 'd3':[1,3], 'd2':[2,3], 'd1':[3,3]
}
def good_square_checker(square):
square_names = ['a1', 'a2', 'a3', 'a4', 'b1', 'b2', 'b3', 'b4', 'c1', 'c2', 'c3', 'c4', 'd1', 'd2', 'd3', 'd4']
if square not in square_names:
return False
else:
return True
def turn():
global board
move_chosen = False
while move_chosen == False:
tui(board)
print("Valid coordinates look like: \'b2\' or \'c4\'")
amazon = translator[(input("The starting coordinates of the amazon of your choice: "))]
move = translator[(input("The coordinates of the square you'd like to move to: "))]
burn = translator[(input("The coordinates of the square you'd like to set aflame: "))]
choice = ((amazon[0],amazon[1]),move,burn)
amazon = 'none'
move = 'none'
burn = 'none'
while good_square_checker(amazon) == False:
amazon = input("Choose a square containing the amazon of your choice: ")
while good_square_checker(move) == False:
move = input("Choose a square she can move to: ")
while good_square_checker(burn) == False:
burn = input("Choose a square she can then shoot: ")
choice = ((translator[amazon][0],translator[amazon][1]),translator[move],translator[burn])
print(choice)
print(board.possible_moves())
if choice in board.possible_moves():
board.state = board.get_successor_state(choice)
move_chosen = True
else:
print(str(choice)+" is not a valid move.")
input("That is not a valid move. Press enter to continue.")
def play():
while len(board.possible_moves())>0:
turn()
return ("Player "+str(get_active_player_code()-1)+" loses!")
tui(board)
print("Player "+str(board.get_active_player_code()-1)+" loses!")
play()