main.c (1006B)
1 #include <stdbool.h> 2 #include <stdio.h> 3 #include <string.h> 4 5 #include "bb.h" 6 #include "pos.h" 7 8 #define BUFSIZE 8192 9 #define START_FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" 10 11 #define VERSION "v0.0.1" 12 13 /* sizeof magically gets the length of the string! (plus \0) */ 14 #define CMD(s) strncmp(buf, s, sizeof(s)-1) == 0 15 16 int 17 main() { 18 char buf[BUFSIZE]; 19 20 /* Create a position structure */ 21 pos p; 22 23 parse_fen(&p, START_FEN); 24 25 for (;;) { 26 fgets(buf, BUFSIZE, stdin); 27 28 if (CMD("uci")) { 29 puts("id name bpaul-chess " VERSION); 30 puts("id author Benjamin Paul"); 31 puts("uciok"); 32 } else if (CMD("isready")) { 33 puts("readyok"); 34 } else if (CMD("quit")) { 35 break; 36 } else if (CMD("position startpos")) { 37 /* Still would need to do the moves section of this command :( */ 38 parse_fen(&p, START_FEN); 39 } else if (CMD("position fen")) { 40 parse_fen(&p, buf + 11); 41 } 42 #ifndef NDEBUG /* Debug commands! */ 43 else if (CMD("print")) { 44 print_board(&p); 45 } 46 #endif 47 } 48 49 return 0; 50 }