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
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
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
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