51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from board import *
|
|
from view import *
|
|
|
|
board = Board()
|
|
|
|
translator = {
|
|
'a4':[0,0], 'a3':[1,0], 'a2':[2,0], 'a1':[3,0],
|
|
'b4':[0,1], 'b3':[1,1], 'b2':[2,1], 'b1':[3,1],
|
|
'c4':[0,2], 'c3':[1,2], 'c2':[2,2], 'c1':[3,2],
|
|
'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():
|
|
move_chosen = False
|
|
while move_chosen == False:
|
|
tui(board)
|
|
print("Valid coordinates look like: \'b2\' or \'c4\'")
|
|
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:
|
|
input("That is not a valid move. Press enter to continue.")
|
|
|
|
|
|
def play():
|
|
while len(board.possible_moves())>0:
|
|
turn()
|
|
tui(board)
|
|
print("Player "+str(board.get_active_player_code()-1)+" loses!")
|
|
|
|
play()
|