-
Notifications
You must be signed in to change notification settings - Fork 0
/
play.py
29 lines (27 loc) · 1.1 KB
/
play.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from time import sleep
from board import *
from moves import *
def play(board):
"""Playing cycle, plays until both players have no moves left or
until 60 turns are played. Returns the final board.
"""
playing = True
turn_count = 1 # Turn counter, used for 60 turns limit.
while playing:
print('Turno ' + str(turn_count))
for i in range(2):
print_board(board)
if check_all_moves(board, PLAYERS[i]):
while not enter_chip(board, i): # Enters the cycle only if there is an input error.
print('Sintaxis incorrecta o movimiento inválido. Vuelva a ingresar la ficha.')
else:
if not check_all_moves(board, PLAYERS[i - 1]):
print('Ningun color tiene jugadas posibles.')
playing = False
break # Breaks and the game ends
sleep(1)
print('Color ' + PLAYER_COLORS[i] + ': no tienes jugadas posibles')
turn_count += 1
if turn_count == MAX_TURNS:
playing = False
return board