minimum uci parceing

This commit is contained in:
k 2025-06-10 06:23:25 -04:00
parent 276539181c
commit c2d539e6a9
2 changed files with 49 additions and 0 deletions

36
main.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
#include <string.h>
#define BUFF_SIZE 4096
int main() {
setbuf(stdin, NULL);
setbuf(stdout, NULL);
char line[BUFF_SIZE];
char *lineRest, *token;
char ltz[] = "abcdefgh";
int cnt = 0;
while (1) {
(void)fgets(line, sizeof(line), stdin);
size_t len = strlen(line);
if (len - 1)
line[len - 1] = '\0';
token = strtok_r(line, " ", &lineRest);
if (!strcmp("uci", token)) {
printf("id name RatChess 0.0\n");
printf("id author rat<3\n\n");
printf("uciok\n");
} else if (!strcmp("quit", token)) {
return 0;
} else if (!strcmp("setoption", token)) {
} else if (!strcmp("position", token)) {
} else if (!strcmp("ucinewgame", token)) {
} else if (!strcmp("isready", token)) {
printf("readyok\n");
} else if (!strcmp("go", token)) {
printf("bestmove %c2%c4\n", ltz[cnt], ltz[cnt]);
cnt++;
}
}
}

13
shell.nix Normal file
View File

@ -0,0 +1,13 @@
{pkgs ? import <nixpkgs> {}}:
with pkgs;
mkShell rec {
packages = [gdb clang-tools];
nativeBuildInputs = [
pkg-config
gcc
gnumake
];
buildInputs = [
];
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
}