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){
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);

View File

@ -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;

View File

@ -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;
}