class TeamA: def __init__(self): self.board = [[' ']*8 for i in range(8)] self.size = 8 self.board[4][4] = 'W' self.board[3][4] = 'B' self.board[3][3] = 'W' self.board[4][3] = 'B' # a list of unit vectors (row, col) self.directions = [ (-1,-1), (-1,0), (-1,1), (0,-1),(0,1),(1,-1),(1,0),(1,1)] #prints the boards def PrintBoard(self): # Print column numbers print(" ",end="") for i in range(self.size): print(i+1,end=" ") print() # Build horizontal separator linestr = " " + ("+-" * self.size) + "+" # Print board for i in range(self.size): print(linestr) # Separator print(i+1,end="|") # Row number for j in range(self.size): print(self.board[i][j],end="|") # board[i][j] and pipe separator print() # End line print(linestr) #checks every direction fromt the position which is input via "col" and "row", to see if there is an opponent piece #in one of the directions. If the input position is adjacent to an opponents piece, this function looks to see if there is a #a chain of opponent pieces in that direction, which ends with one of the players pieces. def islegal(self, row, col, player, opp): if(self.get_square(row,col)!=" "): return False for Dir in self.directions: for i in range(self.size): if ((( row + i*Dir[0])=0 ) and (( col + i*Dir[1])>=0 ) and (( col + i*Dir[1])=0 ) and (( col + i*Dir[1])>=0 ) and (( col + i*Dir[1])=0 ) and (( col + i*Dir[1])>=0 ) and (( col + i*Dir[1])