board.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:othello-rl 作者: jpypi 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号