int main(int argc, char * argv[]) { // init util_init(); my_random_init(); // for opening book printf("Toga II 1.2.1a UCI based on Fruit 2.1 by Thomas Gaksch and Fabien Letouzey. Settings by Dieter Eberle\n"); // early initialisation (the rest is done after UCI options are parsed in protocol.cpp) option_init(); square_init(); piece_init(); pawn_init_bit(); value_init(); vector_init(); attack_init(); move_do_init(); random_init(); hash_init(); trans_init(Trans); book_init(); // loop loop(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { // init util_init(); my_random_init(); // for opening book printf( "Gambit Fruit based on Fruit 2.1 and Toga by Ryan Benitez, Thomas Gaksch and Fabien Letouzey\nEdit by Evgeniy Zheltonozhskiy\n"); // early initialisation (the rest is done after UCI options are parsed in protocol.cpp) option_init(); square_init(); piece_init(); pawn_init_bit(); value_init(); vector_init(); attack_init(); move_do_init(); random_init(); hash_init(); trans_init(Trans); book_init(); // loop loop(); return EXIT_SUCCESS; }
/* Sends to server the attack message */ TEG_STATUS attack_out() { int src; int dst; if( attack_finish( &src, &dst ) != TEG_STATUS_SUCCESS ) { textmsg( M_ERR,_("Error, make sure to select the countries first.")); attack_init(); return TEG_STATUS_ERROR; } net_printf(g_game.fd,TOKEN_ATAQUE"=%d,%d\n",src,dst); attack_backup(); return TEG_STATUS_SUCCESS; }
/* it's someone turn */ TEG_STATUS clitok_turno( char *str) { int numjug; PCPLAYER pJ; PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; p.igualador = &igualador; p.separador = &separador; p.data = str; if( strlen(str)==0 ) goto error; if( parser_call( &p ) && !p.hay_otro ) { numjug = atoi( p.token ); } else goto error; if( player_whois( numjug, &pJ) != TEG_STATUS_SUCCESS) goto error; g_game.whos_turn = numjug; attack_unshow(); out_countries(); if( numjug == g_game.numjug ) { ESTADO_SET(PLAYER_STATUS_ATAQUE); /* cosas a hacer cuando yo comienzo un nuevo turno */ reagrupe_bigreset(); attack_init(); textmsg(M_INF,_("It's your turn to attack!!")); } else { /* No es mi turno, entonces yo tengo que estar en idle */ textmsg(M_IMP,_("Player %s(%s) has the turn to attack!"), pJ->name, _(g_colores[pJ->color]) ); ESTADO_SET(PLAYER_STATUS_IDLE); } gui_turn( pJ ); return TEG_STATUS_SUCCESS; error: textmsg(M_ERR,"Error in clitok_turno()"); return TEG_STATUS_ERROR; }
TEngine::TEngine(AnsiString FileName) { util_init(); my_random_init(); square_init(); piece_init(); pawn_init_bit(); value_init(); vector_init(); attack_init(); move_do_init(); random_init(); hash_init(); Reversed = true; board_from_fen(&StartBoard,StartFen); board_from_fen(&Board,StartFen); GameStarted = false; StateNewGame = false; LastCommitMove[0] = 0; Process = new TProcess(FileName); Process->Send("uci"); char buf[10000]; do { Sleep(10); if (Process->Get(buf)) { char *next_line = buf; while (true) { char *cur_line = next_line; if (cur_line[0] == 0) break; char *end = strstr(cur_line,"\r\n"); end[0] = 0; end[1] = 0; next_line = end + 2; char *cur_word; while (cur_line) { cur_word = get_cur_word_str(&cur_line); int pos; if (string_equal(cur_word,"id")) { cur_word = get_cur_word_str(&cur_line); if (string_equal(cur_word,"name")) { AnsiString EngineName = cur_line; MainForm->lbEngineName->Caption = EngineName; } } if (string_equal(cur_word,"uciok")) { if (MainForm->MultiPV > 1) { Process->Send("setoption name MultiPV value " + IntToStr(MainForm->MultiPV)); Sleep(100); Process->Get(buf); } Process->Send("setoption name Hash value " + IntToStr(MainForm->HashSize)); return; } } } } } while (true); }
int main(int argc, char * argv[]) { // board_t board[1]; // init Init = false; #ifdef _WIN32 signal(SIGINT,SIG_IGN); signal(SIGTERM,SIG_IGN); #ifdef SIGPIPE signal(SIGPIPE,SIG_IGN); #endif #endif util_init(); printf("PolyGlot %s by Fabien Letouzey\n",Version); option_init(); uci_options_init(); square_init(); piece_init(); attack_init(); hash_init(); my_random_init(); // build book if (argc >= 2 && my_string_equal(argv[1],"make-book")) { book_make(argc,argv); return EXIT_SUCCESS; } if (argc >= 2 && my_string_equal(argv[1],"merge-book")) { book_merge(argc,argv); return EXIT_SUCCESS; } // read options if (argc == 2) option_set("OptionFile",argv[1]); // HACK for compatibility parse_option(); // HACK: also launches the engine // EPD test if (argc >= 2 && my_string_equal(argv[1],"epd-test")) { epd_test(argc,argv); return EXIT_SUCCESS; } // opening book book_clear(); if (option_get_bool("Book")){ if (book_open(option_get_string("BookFile"))) option_set("Book","false");//some error,set to false } //adapter_loop(); #ifdef _WIN32 Engine_ready_ok=CreateEvent(NULL,FALSE,FALSE,NULL); Engine_sync_stop = CreateEvent(NULL,FALSE,FALSE,NULL); // all set and done.lets open a thread for fun DWORD dwThreadID; HANDLE hThread; hThread= CreateThread( NULL, //default security attributes 0, //default stacksize ThreadFunc, //The thread function! &sCommand, //the commands for the thread function 0, //default creation flags &dwThreadID); //the thread identifier Idle500msecs();// if(hThread==NULL){ my_log("CreateThread failed\n"); } #endif adapter_loop(); engine_send(Engine,"quit"); engine_close(Engine); #ifdef _WIN32 CloseHandle(hThread); //close the thread; #endif return EXIT_SUCCESS; }