pic random move

This commit is contained in:
k 2025-06-19 03:48:31 -04:00
parent 3aa41364b3
commit bfe9335515

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h>
#include "moves.h" #include "moves.h"
#include "types.h" #include "types.h"
#include "help.h" #include "help.h"
@ -50,12 +51,14 @@ int main() {
playMoves(g, lineRest); playMoves(g, lineRest);
} else if (!strcmp("ucinewgame", token)) { } else if (!strcmp("ucinewgame", token)) {
} else if (!strcmp("isready", token)) { } else if (!strcmp("isready", token)) {
srand(time(NULL));
printf("readyok\n"); printf("readyok\n");
} else if (!strcmp("go", token)) { } else if (!strcmp("go", token)) {
move mov[1500];//big dumb buffer
move mov[200]; int cnt = 0;
int cnt = knightMove(g, mov); cnt += pawnMove(g,mov);
move *m = &mov[0]; cnt += knightMove(g,(mov+cnt));
move *m = &mov[rand() % cnt];
char *end = ""; char *end = "";
int yTo, xTo, yFrom, xFrom; int yTo, xTo, yFrom, xFrom;
@ -64,9 +67,9 @@ int main() {
xFrom = m->From % 8; xFrom = m->From % 8;
yFrom = m->From / 8 + 1; yFrom = m->From / 8 + 1;
if ((g->whiteToMove && yTo == 8) || (!g->whiteToMove && yTo == 1)) { long long bit = 1LL << m->From;
// end = "q\n"; if (((g->whiteToMove && yTo == 8) || (!g->whiteToMove && yTo == 1)) && ((findSet(g,bit) == &g->white.pawns) || (findSet(g,bit) == &g->black.pawns))) {
end = "\n"; end = "q\n";
} else { } else {
end = "\n"; end = "\n";
} }