diff --git a/main.c b/main.c new file mode 100644 index 0000000..7f4a1a3 --- /dev/null +++ b/main.c @@ -0,0 +1,36 @@ +#include +#include + +#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++; + } + } +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..b961719 --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +{pkgs ? import {}}: +with pkgs; + mkShell rec { + packages = [gdb clang-tools]; + nativeBuildInputs = [ + pkg-config + gcc + gnumake + ]; + buildInputs = [ + ]; + LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs; + }