(board)
| 256 | |
| 257 | |
| 258 | def getComputerMove(board): |
| 259 | potentialMoves = getPotentialMoves(board, BLACK, DIFFICULTY) |
| 260 | # get the best fitness from the potential moves |
| 261 | bestMoveFitness = -1 |
| 262 | for i in range(BOARDWIDTH): |
| 263 | if potentialMoves[i] > bestMoveFitness and isValidMove(board, i): |
| 264 | bestMoveFitness = potentialMoves[i] |
| 265 | # find all potential moves that have this best fitness |
| 266 | bestMoves = [] |
| 267 | for i in range(len(potentialMoves)): |
| 268 | if potentialMoves[i] == bestMoveFitness and isValidMove(board, i): |
| 269 | bestMoves.append(i) |
| 270 | return random.choice(bestMoves) |
| 271 | |
| 272 | |
| 273 | def getPotentialMoves(board, tile, lookAhead): |
no test coverage detected