misc improvements
This commit is contained in:
parent
eaaa0ca24d
commit
e1fe8ee603
@ -1,4 +1,5 @@
|
||||
#ifndef EVAL_H
|
||||
#define EVAL_H
|
||||
move *findBest(move* move, size_t size, game* g);
|
||||
void makeMove(game *g, move* m);
|
||||
#endif
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#define QUEEN_VALUE 900
|
||||
#define KING_VALUE 20000
|
||||
#define INF 9000000
|
||||
#define MAX_DEPTH 3 // Adjustable depth
|
||||
#define MAX_DEPTH 3
|
||||
|
||||
int evaluateBoard(game *game);
|
||||
void makeMove(game *g, move* m);
|
||||
@ -63,7 +63,6 @@ int evaluateBoard(game *game) {
|
||||
}
|
||||
|
||||
void makeMove(game *g, move* m) {
|
||||
//should replace inside of PlayMoves but im lazy
|
||||
long long from_bit = 1LL << m->From;
|
||||
long long to_bit = 1LL << m->To;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include "types.h"
|
||||
|
||||
long long fullSet(sets *s) {
|
||||
return s->bishops ^ s->king ^ s->knights ^ s->pawns ^ s->queen ^ s->rooks;
|
||||
return s->bishops | s->king | s->knights | s->pawns | s->queen | s->rooks;
|
||||
}
|
||||
|
||||
long long fullSetBoth(game *g) {
|
||||
|
||||
36
src/main.c
36
src/main.c
@ -53,7 +53,6 @@ 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)) {
|
||||
static move mov[1500];//big dumb buffer
|
||||
@ -122,31 +121,16 @@ game *fenGame(char *str) {
|
||||
}
|
||||
|
||||
void playMoves(game *g, char *moves) {
|
||||
char *move;
|
||||
move = strtok_r(moves, " ", &moves);
|
||||
move = strtok_r(moves, " ", &moves);
|
||||
while (move) {
|
||||
long long bit = 1LL << ((move[1] - '0' - 1) * 8 + (move[0] - 'a'));
|
||||
long long *set = findSet(g, bit);
|
||||
if (!set) {
|
||||
printf("info fuck\n");
|
||||
return;
|
||||
}
|
||||
*set &= (~bit);
|
||||
bit = 1LL << ((move[3] - '0' - 1) * 8 + (move[2] - 'a'));
|
||||
long long *tmp = findSet(g, bit);
|
||||
if (tmp)
|
||||
*tmp &= (~bit);
|
||||
if (strlen(move) == 5) {
|
||||
char c = move[4];
|
||||
if (g->whiteToMove)
|
||||
c = toupper(c);
|
||||
set = charToSet(g, c);
|
||||
}
|
||||
*set |= bit;
|
||||
|
||||
move = strtok_r(moves, " ", &moves);
|
||||
g->whiteToMove = !g->whiteToMove;
|
||||
char *moveStr;
|
||||
moveStr = strtok_r(moves, " ", &moves);
|
||||
moveStr = strtok_r(moves, " ", &moves);
|
||||
while (moveStr) {
|
||||
move m;
|
||||
m.From = (moveStr[0]-'a') + (moveStr[1]-'1')*8;
|
||||
m.To = (moveStr[2]-'a') + (moveStr[3]-'1')*8;
|
||||
m.Promo = (strlen(moveStr) == 5) ? moveStr[4] : 0;
|
||||
makeMove(g, &m);
|
||||
moveStr = strtok_r(moves, " ", &moves);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user