partly implemented uci
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
#include <chess/types.h>
|
#include <chess/types.h>
|
||||||
|
|
||||||
#define REPETETION_TABLE_LENGTH 1024
|
#define REPETETION_TABLE_LENGTH 1024
|
||||||
|
#define START_FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
|
||||||
|
|
||||||
bool bitboardGet(const uint_least64_t *board, struct piece_t piece, uint_least8_t i);
|
bool bitboardGet(const uint_least64_t *board, struct piece_t piece, uint_least8_t i);
|
||||||
uint_least64_t bitboardGetMask(const uint_least64_t *board, struct piece_t piece);
|
uint_least64_t bitboardGetMask(const uint_least64_t *board, struct piece_t piece);
|
||||||
@ -13,4 +14,5 @@ void bitboardClear(uint_least64_t *board, struct piece_t piece, uint_least8_t i)
|
|||||||
void bitboardSet(uint_least64_t *board, struct piece_t piece, uint_least8_t i);
|
void bitboardSet(uint_least64_t *board, struct piece_t piece, uint_least8_t i);
|
||||||
struct piece_t pieceAtField(const uint_least64_t *board, uint_least8_t i);
|
struct piece_t pieceAtField(const uint_least64_t *board, uint_least8_t i);
|
||||||
struct gameState_t newGameState(uint_least64_t *board,
|
struct gameState_t newGameState(uint_least64_t *board,
|
||||||
struct zobristTableElement *repetitionTableStore, char *FEN);
|
struct zobristTableElement *repetitionTableStore, const char *FEN);
|
||||||
|
struct gameState_t parseFen(uint_least64_t *board, const char *FEN);
|
||||||
|
|||||||
@ -12,8 +12,6 @@
|
|||||||
#include "evaluate.h"
|
#include "evaluate.h"
|
||||||
#include <chess/util.h>
|
#include <chess/util.h>
|
||||||
|
|
||||||
#define START_FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
|
|
||||||
|
|
||||||
struct drawData_t {
|
struct drawData_t {
|
||||||
RsvgHandle **piecesSvg;
|
RsvgHandle **piecesSvg;
|
||||||
struct gameState_t *gameState;
|
struct gameState_t *gameState;
|
||||||
|
|||||||
@ -67,8 +67,11 @@ struct piece_t pieceAtField(const uint_least64_t *board, uint_least8_t i) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct gameState_t parseFen(uint_least64_t *board, const char *FEN) {
|
||||||
|
}
|
||||||
|
|
||||||
struct gameState_t newGameState(uint_least64_t *board,
|
struct gameState_t newGameState(uint_least64_t *board,
|
||||||
struct zobristTableElement *repetitionTableStore, char *FEN) {
|
struct zobristTableElement *repetitionTableStore, const char *FEN) {
|
||||||
struct gameState_t gameState = {board, 0};
|
struct gameState_t gameState = {board, 0};
|
||||||
for(uint_least8_t i = 0; i < BITBOARD_LENGTH; ++i) {
|
for(uint_least8_t i = 0; i < BITBOARD_LENGTH; ++i) {
|
||||||
board[i] = 0;
|
board[i] = 0;
|
||||||
|
|||||||
72
src/uci.c
Normal file
72
src/uci.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "chess/move.h"
|
||||||
|
#include "chess/types.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdatomic.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <chess/bitboard.h>
|
||||||
|
|
||||||
|
atomic_bool searchShouldStop;
|
||||||
|
|
||||||
|
#define customStrCmp(input, cmd) customStrCmpFunc(&(input), cmd, sizeof(cmd))
|
||||||
|
static bool customStrCmpFunc(char **input, const char *cmd, const size_t length) {
|
||||||
|
bool result = strncmp(*input, cmd, length) == 0;
|
||||||
|
if(result) *input += length + 1;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char input[4096];
|
||||||
|
struct gameState_t gameState;
|
||||||
|
uint_least64_t board[TOTAL_BOARD_SIZE];
|
||||||
|
gameState.repetitionTable = (struct zobristTable){NULL};
|
||||||
|
initMagicTable();
|
||||||
|
while(true) {
|
||||||
|
char *inputPtr = input;
|
||||||
|
if(fgets(input, sizeof input, stdin) == NULL) {
|
||||||
|
perror("Error: reading stdin: ");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "uci")) {
|
||||||
|
printf(
|
||||||
|
"id name NoNameChessEngine\n"
|
||||||
|
"id author MrGeorgen\n"
|
||||||
|
"uciok\n"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "isready")) {
|
||||||
|
printf("readyok\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "position")) {
|
||||||
|
if(gameState.repetitionTable.arr == NULL) {
|
||||||
|
fprintf(stderr, "Error: required uicnewgame before a position command\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "startpos")) {
|
||||||
|
gameState = parseFen(board, START_FEN);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "fen")) {
|
||||||
|
gameState = parseFen(board, inputPtr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "quit")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "go")) {
|
||||||
|
while(*inputPtr != '\0') {
|
||||||
|
//if(customStrCmp(inputPtr, "wtime"))
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(customStrCmp(inputPtr, "stop")) {
|
||||||
|
searchShouldStop = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user