-
Notifications
You must be signed in to change notification settings - Fork 0
/
bigBoard.py
34 lines (29 loc) · 1.51 KB
/
bigBoard.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
30
31
32
33
34
import smallBoard
class big_board(): #tic-tac-toe board object
def __init__(self):
self.board_list = [tic_tac_toe_board() for i in range(9)] #create list of boards
self.win_list = [None for i in range(9)] #create empty list to hold the winners of the boards
def check_win_p(self): #returns the wining player
for player in ('x', 'o'): #iterate through the players
positions = set(get_player_wins(player)) #create a set of the boards the player has won
for win_line in win_combos: #iterate through every possible winning combination
win = True #set the default to True
for pos in win_line: #compare positions
if pos not in positions: #if any positions is not in the winnign combination
win = False #set it to False
break #escape loop
if win:
return player #return the winning player
return None #return None if no one won
def get_player_wins(self, player): #returns a list of all boards the player has won
return [pos for pos, value in enumerate(self.win_list) if value == player]
def make_move(self, board_pos, player_pos, player): #makes the move specified by the inputs
self.board_list[board_pos].make_move(player_pos, player) #makes the move in the specified board
win_list[board_pos] == self.board_list[board_pos].check_win_p() #check if the player won that board and update win_list
def is_board_full(board_pos): #checks if specific board is full
if len(self.board_list[board_pos].available_moves()) == 0:
return True
else:
return False
def print_board(self):
pass