I just played with the basic chess engine. I managed to get a lot of advice from http://web.archive.org/web/20070704121716/http://www.brucemo.com/compchess/programming/alphabeta.htm , but the real site does not work, and not all pages are archived. (Does anyone know where to find the full version of Bruce's site?)
But now to the real question: how do I communicate with XBoard? I understand that this is through stdin and stdout, but I have code problems. Basically, for starters, I just want
- get input from XBoard and print it on the console / screen
- Move the hard-coded input to the XBoard and make the transition
- Utility functions and have random ai chess that select random moves.
After that, I can begin to implement real things, such as alpha beta search.
I'm stuck on the first two things right now. Here is the code I tried to write / borrow.
#include <iostream> #include <string.h> #include <stdio.h> #include <stdlib.h> #define STR_BUFF 256 using namespace std; int main (int argc, const char * argv[]) { char input[STR_BUFF]; char output[STR_BUFF]; while(true){ fflush(stdout); // read input if (!fgets(input, STR_BUFF, stdin)){ printf("terminated"); return 0;; } printf("%s", input); } return 0; }
I am only returning to C after 6 months of break, and this is the first project in which I used the stdin / stdout pipelines to communicate with another program (minus a few basic programs), so I would appreciate any help and any explanation, I know That programming a chess engine is a Hercules task, but I have already programmed chess rules before, and what I can find on Bruce's website is just awesome.
source share