(board, player)
| 71 | minEvalBoard = -1 # min - 1 |
| 72 | maxEvalBoard = n * n + 4 * n + 4 + 1 # max + 1 |
| 73 | def EvalBoard(board, player): |
| 74 | tot = 0 |
| 75 | for y in range(n): |
| 76 | for x in range(n): |
| 77 | if board[y][x] == player: |
| 78 | if (x == 0 or x == n - 1) and (y == 0 or y == n - 1): |
| 79 | tot += 4 # corner |
| 80 | elif (x == 0 or x == n - 1) or (y == 0 or y == n - 1): |
| 81 | tot += 2 # side |
| 82 | else: |
| 83 | tot += 1 |
| 84 | return tot |
| 85 | |
| 86 | # if no valid move(s) possible then True |
| 87 | def IsTerminalNode(board, player): |
no test coverage detected