pic random move
This commit is contained in:
parent
3aa41364b3
commit
bfe9335515
17
src/main.c
17
src/main.c
@ -5,6 +5,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "moves.h"
|
||||
#include "types.h"
|
||||
#include "help.h"
|
||||
@ -50,12 +51,14 @@ int main() {
|
||||
playMoves(g, lineRest);
|
||||
} else if (!strcmp("ucinewgame", token)) {
|
||||
} else if (!strcmp("isready", token)) {
|
||||
srand(time(NULL));
|
||||
printf("readyok\n");
|
||||
} else if (!strcmp("go", token)) {
|
||||
|
||||
move mov[200];
|
||||
int cnt = knightMove(g, mov);
|
||||
move *m = &mov[0];
|
||||
move mov[1500];//big dumb buffer
|
||||
int cnt = 0;
|
||||
cnt += pawnMove(g,mov);
|
||||
cnt += knightMove(g,(mov+cnt));
|
||||
move *m = &mov[rand() % cnt];
|
||||
|
||||
char *end = "";
|
||||
int yTo, xTo, yFrom, xFrom;
|
||||
@ -64,9 +67,9 @@ int main() {
|
||||
xFrom = m->From % 8;
|
||||
yFrom = m->From / 8 + 1;
|
||||
|
||||
if ((g->whiteToMove && yTo == 8) || (!g->whiteToMove && yTo == 1)) {
|
||||
// end = "q\n";
|
||||
end = "\n";
|
||||
long long bit = 1LL << m->From;
|
||||
if (((g->whiteToMove && yTo == 8) || (!g->whiteToMove && yTo == 1)) && ((findSet(g,bit) == &g->white.pawns) || (findSet(g,bit) == &g->black.pawns))) {
|
||||
end = "q\n";
|
||||
} else {
|
||||
end = "\n";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user