24 lines
990 B
Python
24 lines
990 B
Python
from board import *
|
|
from os import system, name
|
|
|
|
# It's probably cleanest for the view to be a class and for it
|
|
# to handle all input-output to the user, including
|
|
# - rendering board state
|
|
# - representing
|
|
|
|
def clear():
|
|
if name == 'nt':
|
|
_ = system('cls')
|
|
else:
|
|
_ = system('clear')
|
|
|
|
# CP: Should scale to n*n boards
|
|
def tui(board): #This displays the board state to the user
|
|
clear()
|
|
print(" a b c d")
|
|
print("4 "+str(board.state[0][0])+" "+str(board.state[0][1])+" "+str(board.state[0][2])+" "+str(board.state[0][3]))
|
|
print("3 "+str(board.state[1][0])+" "+str(board.state[1][1])+" "+str(board.state[1][2])+" "+str(board.state[1][3]))
|
|
print("2 "+str(board.state[2][0])+" "+str(board.state[2][1])+" "+str(board.state[2][2])+" "+str(board.state[2][3]))
|
|
print("1 "+str(board.state[3][0])+" "+str(board.state[3][1])+" "+str(board.state[3][2])+" "+str(board.state[3][3]))
|
|
print("It's player "+str(board.get_active_player_code()-1)+"'s turn.")
|