diff --git a/src/eval.c b/src/eval.c index d61e69e..8ace056 100644 --- a/src/eval.c +++ b/src/eval.c @@ -20,14 +20,14 @@ int negamax(game *g, int depth, int alpha, int beta, int color); move *findBest(move* moves, size_t size, game* g){ int bestScore = -INF; - move *bestMove = moves; + move *bestMove = NULL; int color = g->whiteToMove ? 1 : -1; for (int i = 0; i < size; i++) { game gg = *g; makeMove(&gg, &moves[i]); int score = -negamax(&gg, MAX_DEPTH, -INF, INF, -color); - if (score > bestScore) { + if (score > bestScore || bestScore == -INF) { bestScore = score; bestMove = &moves[i]; printf("info score cp %d\n", g->whiteToMove ? bestScore : -bestScore); diff --git a/src/main.c b/src/main.c index fd9aa10..c607749 100644 --- a/src/main.c +++ b/src/main.c @@ -64,6 +64,10 @@ int main() { cnt += kingMove(g,(mov+cnt)); cnt += queenMove(g,(mov+cnt)); move *m = findBest(mov,cnt,g); + if(m == NULL){ + printf("bestmove 0000\n"); + continue; + } char *end = ""; int yTo, xTo, yFrom, xFrom; diff --git a/src/moves.c b/src/moves.c index 45ad882..dafb464 100644 --- a/src/moves.c +++ b/src/moves.c @@ -249,7 +249,7 @@ int queenMove(game *g, move *moves){ w = g->white.queen; b = g->black.queen; size += rookScan(g,moves,w,b); - size += bishopScan(g,moves,w,b); + size += bishopScan(g,(moves+size),w,b); return size; }