def updateBoard(self, t, tile, row, col):
"""
@param string t
either 'virtual' or 'live'
@param int tile
either 1 or -1
1 for player 1 (black)
-1 for player 2 (white)
@param int row
0-7 which row
@param int col
0-7 which col
@return bool
true if valid
false if invalid move - doesn't update board
"""
board = self.board if t == 'live' else self.virtualBoard
result = self.isValidMove(board, tile, row, col)
if result != False:
if t == 'live' :
self.nextTurn = self.BLACK if self.nextTurn != self.BLACK else self.WHITE
else:
self.virtualNextTurn = self.BLACK if self.virtualNextTurn != self.BLACK else self.WHITE
board[row][col] = tile
for row in result:
board[ row[0] ][ row[1] ] = tile
if ( t == 'live'):
self.syncVirtualBoard()
return True
else:
return False
评论列表
文章目录