/** * Function to check if a final stage has been reached */ bool Board::finalReached() { if (!isInCheck() && isInCheckmate()) { Stats *s = s->getInstance(); #pragma omp atomic s->draw++; winner = 2; decision = calculateHeuristic(turn); bestBoard = nullptr; return true; } whiteKing = nullptr; whiteKing = getWhiteKing(); if (isInCheckmateWithPieces(whiteKing, blackPieces)) { winner = BLACK; decision = calculateHeuristic(BLACK) * 2; Stats *s = s->getInstance(); #pragma omp atomic s->blackWins++; bestBoard = nullptr; return true; } blackKing = nullptr; blackKing = getBlackKing(); if (isInCheckmateWithPieces(blackKing, whitePieces)) { winner = WHITE; decision = calculateHeuristic(WHITE) * 2; Stats *s = s->getInstance(); #pragma omp atomic s->whiteWins++; bestBoard = nullptr; return true; } if (turnsLeft == 0) { winner = 2; decision = calculateHeuristic(turn); Stats *s = s->getInstance(); #pragma omp atomic s->draw++; bestBoard = nullptr; return true; } return false; }
void Board::getBestPath() { Stats *s = s->getInstance(); s->heuristic = decision; printf("Best path has decision %d\n", decision); }