lab_cards/amazons/game.py

39 lines
1.2 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 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)
print(board.possible_moves())
if choice in board.possible_moves():
print("This is what I'm sending: "+str(choice))
board.state = board.get_successor_state(choice)
print("board = "+str(board.state))
move_chosen = True
else:
print(str(choice)+" is not a valid move.")
def play():
while len(board.possible_moves())>0:
turn()
return ("Player "+str(get_active_player_code()-1)+" loses!")
play()