コード例 #1
0
 def edgePieces(self, board):
     '''
     How many pieces do I have on the edges
     '''
     pieces = 0
     playerIndex = CheckerBoard.playeridx(self.maxplayer)
     for row, column, piece in board:
         playeridx, king = CheckerBoard.identifypiece(piece)
         if playeridx == playerIndex:
             if row is 0 or column is 0 or row is 7 or column is 7:
                 pieces += 1
     return pieces
コード例 #2
0
 def totalPieces(self, board):
     '''
     How many pieces do I have - how many does the other player have
     '''
     pieces = 0
     playerIndex = CheckerBoard.playeridx(self.maxplayer)
     for row, column, piece in board:
         playeridx, king = CheckerBoard.identifypiece(piece)
         if playeridx == playerIndex:
             pieces += 1
         else:
             pieces -= 1
     return pieces
コード例 #3
0
 def pieceDefense(self, board):
     defense = 0
     playerIndex = CheckerBoard.playeridx(self.maxplayer)
     for row, column, piece in board:
         playeridx, king = CheckerBoard.identifypiece(piece)
         if playeridx == playerIndex:
             if not king:
                 defense += self.positionDefense(board, row, column)
                 defense += self.kingDefense(board, row, column)
         #else:
         #    if not king:
         #        defense -= self.positionDefense(board, row, column)
         #        defense -= self.kingDefense(board, row, column)
     return defense
コード例 #4
0
 def distanceToKings(self, board):
     '''
     How far is each side from being "Kinged"
     '''
     distance = 0
     playerIndex = CheckerBoard.playeridx(self.maxplayer)
     for row, column, piece in board:
         playeridx, king = CheckerBoard.identifypiece(piece)
         if playeridx == playerIndex:
             if not king:
                 distance -= board.disttoking(self.maxplayer, row)
         #else:
         #    if not king:
         #        distance += board.disttoking(self.minplayer, row)
     return distance