bool isDiagonalsFilled(int i, int j, OthelloBoard& curBoard ) { int k = i, l = j; while(0 <= k && k < 8 && 0 <= l && l < 8){ if(curBoard.get(k,l) == EMPTY) return false; k++, l++; } k = i, l = j; while(0 <= k && k < 8 && 0 <= l && l < 8){ if(curBoard.get(k,l) == EMPTY) return false; k++, l--; } k = i, l = j; while(0 <= k && k < 8 && 0 <= l && l < 8){ if(curBoard.get(k,l) == EMPTY) return false; k--, l++; } k = i, l = j; while(0 <= k && k < 8 && 0 <= l && l < 8){ if(curBoard.get(k,l) == EMPTY) return false; k--, l--; } return true; }
int MyBot::evaluationFunction(Turn turn, const OthelloBoard& board){ int sum = 0; Turn opp = other(turn); for(int i = 0; i < 8; i++){ for(int j = 0; j < 8; j++){ if(turn == board.get(i,j)){ sum = sum + weights[i][j]; } else if(opp == board.get(i,j)){ sum = sum - weights[i][j]; } } } return sum; }
void getPrevMove(const OthelloBoard& board) { int i, j; OpponentMoveDone = true; int numberOfMoves = 0; for (i = 0; i < 8; ++i) { for (j = 0; j < 8; ++j) { if (PrevBoard.get(i, j) == EMPTY && board.get(i, j) != PrevBoard.get(i, j)) { PrevMove.x = i, PrevMove.y = j; ++numberOfMoves; if(numberOfMoves > 1) OpponentMoveDone = false; } } } gameMovesDone += numberOfMoves; if(numberOfMoves == 0) OpponentMoveDone = false; }