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:
parent
56f1eb564c
commit
18553340f2
Binary file not shown.
Binary file not shown.
|
@ -10,27 +10,41 @@ translator = {
|
||||||
'd4':[0,3], 'd3':[1,3], 'd2':[2,3], 'd1':[3,3]
|
'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():
|
def turn():
|
||||||
global board
|
|
||||||
move_chosen = False
|
move_chosen = False
|
||||||
while move_chosen == False:
|
while move_chosen == False:
|
||||||
tui(board)
|
tui(board)
|
||||||
print("Valid coordinates look like: \'b2\' or \'c4\'")
|
print("Valid coordinates look like: \'b2\' or \'c4\'")
|
||||||
amazon = translator[(input("The starting coordinates of the amazon of your choice: "))]
|
amazon = 'none'
|
||||||
move = translator[(input("The coordinates of the square you'd like to move to: "))]
|
move = 'none'
|
||||||
burn = translator[(input("The coordinates of the square you'd like to set aflame: "))]
|
burn = 'none'
|
||||||
choice = ((amazon[0],amazon[1]),move,burn)
|
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())
|
print(board.possible_moves())
|
||||||
if choice in board.possible_moves():
|
if choice in board.possible_moves():
|
||||||
board.state = board.get_successor_state(choice)
|
board.state = board.get_successor_state(choice)
|
||||||
move_chosen = True
|
move_chosen = True
|
||||||
else:
|
else:
|
||||||
print(str(choice)+" is not a valid move.")
|
input("That is not a valid move. Press enter to continue.")
|
||||||
|
|
||||||
|
|
||||||
def play():
|
def play():
|
||||||
while len(board.possible_moves())>0:
|
while len(board.possible_moves())>0:
|
||||||
turn()
|
turn()
|
||||||
return ("Player "+str(get_active_player_code()-1)+" loses!")
|
tui(board)
|
||||||
|
print("Player "+str(board.get_active_player_code()-1)+" loses!")
|
||||||
|
|
||||||
play()
|
play()
|
||||||
|
|
Loading…
Reference in New Issue