int main() { cout << "\n exacto[0.f] \n <<------------------------------->> \n by Daniel Sparks, USA \n" << endl << endl; cout << "Type 'game' for gameplay commands, or 'help' for all commands." << endl << endl; int i, j; string user_input; /* These are the coefficients for the piece square tables (see fill_PST), which can later be optimized 3 at a time. */ // unoptimized: int16_t C[4][3] = { { 0, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 } }; int16_t C[7][3] = { { 0, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 0, 0 } }; CEngine exacto; CEngine exacto2; CGame game; initialize(); fill_PST(C); parse_book("book.bin"); exacto.book_mode = is_book(true) ? _BOOK_MODE : BOOK_DISABLED; game.set_board("Default", "", "", "", "", ""); /*// Consolidate: string file[5] = { "tuneraz_11.txt", "tuneraz_12.txt", "tuneraz_13.txt", "tuneraz_14.txt", "tuneraz_15.txt" }; int score[30] = { 0 }; uint32_t m = 0, n = 0, r = 0; for(int p = 0; p < 5; p++) parse_tuning_file(&m, &n, &r, score, file[p]); int mu = 0; for(int p = 1; p < 27; p++) { cout << p << " : " << (((double)score[p])/2) << endl; mu += score[p]; } cout << "Total games: " << mu << endl << "Mean: " << mu / 26 << endl;*/ for(cin >> user_input; true; cin >> user_input) { next_command: if(user_input == "quit") break; else if((user_input == "xboard") || (user_input == "winboard")) exacto.post_pretty = false; else if(user_input == "protover") { cin >> user_input; cout << "feature ping=1 setboard=1 playother=1 san=0 usermove=1 time=1 draw=0 sigint=0 sigterm=0 reuse=1 analyze=0 colors=0 ics=0 name=0 pause=0 done=1" << endl; } else if(user_input == "accepted") {
OpeningBook::OpeningBook() { srand(time(NULL)); book_file.open(OPENING_BOOK_FILE); max_line_size = 0; book_open = false; if (book_file) { //if there is any correct line then the book will be open! parse_book(); } else { cerr << "Opening book file (book) is missing." << endl; } first = 0; last = book.size() - 1; book_file.close(); }
book * read_book(char * file, int type, int id) { xmlDoc * doc; xmlNode * root=NULL; xmlChar *title=NULL; book *b=NULL; char path[1024]; safe_snprintf(path, sizeof(path), "languages/%s/%s", lang, file); if ((doc = xmlReadFile(path, NULL, 0)) == NULL) { safe_snprintf(path, sizeof(path), "languages/en/%s", file); } if(doc == NULL && ((doc = xmlReadFile(path, NULL, 0)) == NULL)) { char str[200]; safe_snprintf(str, sizeof(str), book_open_err_str, path); LOG_ERROR(str); LOG_TO_CONSOLE(c_red1,str); } else if ((root = xmlDocGetRootElement(doc))==NULL) { LOG_ERROR("Error while parsing: %s", path); } else if(xmlStrcasecmp(root->name,(xmlChar*)"book")){ LOG_ERROR("Root element in %s is not <book>", path); } else if((title=xmlGetProp(root,(xmlChar*)"title"))==NULL){ LOG_ERROR("Root element in %s does not contain a title=\"<short title>\" property.", path); } else { b=parse_book(root->children, (char*)title, type, id); } if(title) { xmlFree(title); } xmlFreeDoc(doc); return b; }