misc improvements

This commit is contained in:
k 2025-06-19 19:40:11 -04:00
parent eaaa0ca24d
commit e1fe8ee603
4 changed files with 13 additions and 29 deletions

View File

@ -1,4 +1,5 @@
#ifndef EVAL_H #ifndef EVAL_H
#define EVAL_H #define EVAL_H
move *findBest(move* move, size_t size, game* g); move *findBest(move* move, size_t size, game* g);
void makeMove(game *g, move* m);
#endif #endif

View File

@ -12,7 +12,7 @@
#define QUEEN_VALUE 900 #define QUEEN_VALUE 900
#define KING_VALUE 20000 #define KING_VALUE 20000
#define INF 9000000 #define INF 9000000
#define MAX_DEPTH 3 // Adjustable depth #define MAX_DEPTH 3
int evaluateBoard(game *game); int evaluateBoard(game *game);
void makeMove(game *g, move* m); void makeMove(game *g, move* m);
@ -63,7 +63,6 @@ int evaluateBoard(game *game) {
} }
void makeMove(game *g, move* m) { void makeMove(game *g, move* m) {
//should replace inside of PlayMoves but im lazy
long long from_bit = 1LL << m->From; long long from_bit = 1LL << m->From;
long long to_bit = 1LL << m->To; long long to_bit = 1LL << m->To;

View File

@ -2,7 +2,7 @@
#include "types.h" #include "types.h"
long long fullSet(sets *s) { 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) { long long fullSetBoth(game *g) {

View File

@ -53,7 +53,6 @@ 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)) {
static move mov[1500];//big dumb buffer static move mov[1500];//big dumb buffer
@ -122,31 +121,16 @@ game *fenGame(char *str) {
} }
void playMoves(game *g, char *moves) { void playMoves(game *g, char *moves) {
char *move; char *moveStr;
move = strtok_r(moves, " ", &moves); moveStr = strtok_r(moves, " ", &moves);
move = strtok_r(moves, " ", &moves); moveStr = strtok_r(moves, " ", &moves);
while (move) { while (moveStr) {
long long bit = 1LL << ((move[1] - '0' - 1) * 8 + (move[0] - 'a')); move m;
long long *set = findSet(g, bit); m.From = (moveStr[0]-'a') + (moveStr[1]-'1')*8;
if (!set) { m.To = (moveStr[2]-'a') + (moveStr[3]-'1')*8;
printf("info fuck\n"); m.Promo = (strlen(moveStr) == 5) ? moveStr[4] : 0;
return; makeMove(g, &m);
} moveStr = strtok_r(moves, " ", &moves);
*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;
} }
} }