fix queen move bug

This commit is contained in:
k 2025-06-20 03:56:20 -04:00
parent 05a0b2b7f1
commit 89e00df712
3 changed files with 7 additions and 3 deletions

View File

@ -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){ move *findBest(move* moves, size_t size, game* g){
int bestScore = -INF; int bestScore = -INF;
move *bestMove = moves; move *bestMove = NULL;
int color = g->whiteToMove ? 1 : -1; int color = g->whiteToMove ? 1 : -1;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
game gg = *g; game gg = *g;
makeMove(&gg, &moves[i]); makeMove(&gg, &moves[i]);
int score = -negamax(&gg, MAX_DEPTH, -INF, INF, -color); int score = -negamax(&gg, MAX_DEPTH, -INF, INF, -color);
if (score > bestScore) { if (score > bestScore || bestScore == -INF) {
bestScore = score; bestScore = score;
bestMove = &moves[i]; bestMove = &moves[i];
printf("info score cp %d\n", g->whiteToMove ? bestScore : -bestScore); printf("info score cp %d\n", g->whiteToMove ? bestScore : -bestScore);

View File

@ -64,6 +64,10 @@ int main() {
cnt += kingMove(g,(mov+cnt)); cnt += kingMove(g,(mov+cnt));
cnt += queenMove(g,(mov+cnt)); cnt += queenMove(g,(mov+cnt));
move *m = findBest(mov,cnt,g); move *m = findBest(mov,cnt,g);
if(m == NULL){
printf("bestmove 0000\n");
continue;
}
char *end = ""; char *end = "";
int yTo, xTo, yFrom, xFrom; int yTo, xTo, yFrom, xFrom;

View File

@ -249,7 +249,7 @@ int queenMove(game *g, move *moves){
w = g->white.queen; w = g->white.queen;
b = g->black.queen; b = g->black.queen;
size += rookScan(g,moves,w,b); size += rookScan(g,moves,w,b);
size += bishopScan(g,moves,w,b); size += bishopScan(g,(moves+size),w,b);
return size; return size;
} }