42 printf(
"%2d ", result->
depth);
43 printf(
"%4d ", 100 * result->
score);
44 printf(
"%6lld ", result->
time / 10);
45 printf(
"%10lld ", result->
n_nodes);
114 fprintf(stderr,
"Error ");
115 va_start(args, format);
116 vfprintf(stderr, format, args);
123 va_start(args, format);
140 va_start(args, format);
141 vprintf(format, args);
147 va_start(args, format);
168 if (x ==
PASS) printf(
"move @@@@\n");
176 if (x ==
PASS) printf(
"edax> move @@@@\n");
197 if (x ==
PASS) printf(
"Hint:@@@@\n");
205 if (x ==
PASS) printf(
"edax> Hint:@@@@\n");
230 printf(
":%d", move->
score * 100);
255 const char *(color[2]) = {
"Black",
"White"};
256 const int player =
WHITE;
257 const int opponent = !player;
262 if (n_discs[player] > n_discs[opponent])
xboard_send(
"1-0 {%s wins %d-%d}\n", color[player], n_discs[player], n_discs[opponent]);
263 else if (n_discs[player] < n_discs[opponent])
xboard_send(
"0-1 {%s wins %d-%d}\n", color[opponent], n_discs[opponent], n_discs[player]);
264 else xboard_send(
"1/2-1/2 {Draw %d-%d}\n", n_discs[player], n_discs[opponent]);
273 unsigned long long s =
sizeof (
Hash) << n;
274 return ((s << 1) + (s >> 4) +
sizeof (
HashTable) * 3) >> 20;
302 else fprintf(
xboard_log->
f,
"edax search> BUG: search stopped for no reason ???\n");
303 fprintf(
xboard_log->
f,
"edax search> time spent = %.2f; depth reached = %d@%d%%; nodes = %lld\n",
305 fprintf(
xboard_log->
f,
"edax search> best score = %d; pv = ", result->
score);
370 char *cmd = NULL, *param = NULL;
382 if (strcmp(cmd,
".") == 0) {
383 spin_lock(search->
result);
386 spin_unlock(search->
result);
388 }
else if (strcmp(cmd,
"hint") == 0) {
391 }
else if (strcmp(cmd,
"bk") == 0) {
394 }
else if (strcmp(cmd,
"new") == 0) {
399 }
else if (strcmp(cmd,
"undo") == 0) {
404 }
else if ((strcmp(cmd,
"setboard") == 0)) {
410 }
else if (strcmp(cmd,
"exit") == 0) {
412 free(cmd); free(param);
416 }
else if (strcmp(cmd,
"quit") == 0) {
418 free(cmd); free(param);
442 char *cmd = NULL, *param = NULL;
444 bool alien_variant =
false;
446 int edax_turn =
EMPTY;
447 int last_edax_turn = !play->
player;
448 const char *(color[2]) = {
"black",
"white"};
470 if (*cmd ==
'\0' || *cmd ==
'#') {
473 }
else if (strcmp(cmd,
"xboard") == 0) {
476 }
else if (strcmp(cmd,
"protover") == 0) {
488 "variants=\"reversi\" "
497 }
else if (strcmp(cmd,
"accepted") == 0) {
500 }
else if (strcmp(cmd,
"debug") == 0) {
504 }
else if (strcmp(cmd,
"rejected") == 0) {
505 char feature[16], *value;
508 if (strcmp(feature,
"variants") == 0 && strcmp(value,
"reversi") == 0) {
509 free(cmd), free(param);
515 }
else if (strcmp(cmd,
"new") == 0 ) {
519 edax_turn = !play->
player;
523 }
else if (strcmp(cmd,
"variant") == 0 ) {
525 if (strcmp(param,
"alien") == 0) {
526 alien_variant =
true;
527 }
else if (strcmp(param,
"reversi") == 0) {
528 alien_variant =
false;
535 }
else if (strcmp(cmd,
"quit") == 0 || strcmp(cmd,
"eof") == 0 || strcmp(cmd,
"q") == 0) {
537 free(cmd); free(param);
542 }
else if ((strcmp(cmd,
"random") == 0)) {
546 }
else if ((strcmp(cmd,
"force") == 0)) {
548 last_edax_turn = edax_turn;
552 }
else if (strcmp(cmd,
"go") == 0) {
557 }
else if (strcmp(cmd,
"playother") == 0) {
562 }
else if (strcmp(cmd,
"white") == 0) {
566 }
else if (strcmp(cmd,
"black") == 0) {
571 }
else if (strcmp(cmd,
"level") == 0) {
572 int mps, base, inc, m, s;
577 if (*next ==
':') next =
parse_int(next + 1, &s);
581 if ((mps == 0 || mps > 30) && inc == 0) {
586 int t1 = base * 1000ull / mps;
587 int t2 = (base + inc * mps) * 30;
594 }
else if (strcmp(cmd,
"st") == 0) {
600 }
else if (strcmp(cmd,
"sd") == 0) {
606 }
else if ((strcmp(cmd,
"nps") == 0)) {
610 }
else if ((strcmp(cmd,
"time") == 0)) {
613 if (t > 6000) t -= 1000;
else if (t > 1000) t -= 100;
614 play->
time[edax_turn ==
EMPTY ? last_edax_turn : edax_turn].
left = t * 10;
616 }
else if ((strcmp(cmd,
"otim") == 0)) {
619 if (t > 6000) t -= 1000;
else if (t > 1000) t -= 100;
620 play->
time[edax_turn ==
EMPTY ? !last_edax_turn : !edax_turn].
left = t * 10;
623 }
else if (strcmp(cmd,
"?") == 0) {
627 }
else if ((strcmp(cmd,
"ping") == 0)) {
631 }
else if ((strcmp(cmd,
"draw") == 0)) {
635 }
else if ((strcmp(cmd,
"result") == 0)) {
646 }
else if ((strcmp(cmd,
"setboard") == 0)) {
651 }
else if ((strcmp(cmd,
"edit") == 0)) {
654 }
else if ((strcmp(cmd,
"hint") == 0)) {
657 }
else if ((strcmp(cmd,
"bk") == 0)) {
660 }
else if ((strcmp(cmd,
"undo") == 0)) {
663 }
else if ((strcmp(cmd,
"remove") == 0)) {
667 }
else if ((strcmp(cmd,
"hard") == 0)) {
671 }
else if ((strcmp(cmd,
"easy") == 0)) {
675 }
else if ((strcmp(cmd,
"post") == 0)) {
678 }
else if ((strcmp(cmd,
"nopost") == 0)) {
681 }
else if ((strcmp(cmd,
"analyze") == 0)) {
682 free(cmd); free(param);
686 }
else if ((strcmp(cmd,
"name") == 0)) {
689 }
else if ((strcmp(cmd,
"rating") == 0)) {
691 }
else if ((strcmp(cmd,
"ics") == 0)) {
693 }
else if ((strcmp(cmd,
"computer") == 0)) {
695 }
else if ((strcmp(cmd,
"pause") == 0)) {
698 }
else if ((strcmp(cmd,
"resume") == 0)) {
701 }
else if ((strcmp(cmd,
"memory") == 0)) {
710 }
else if ((strcmp(cmd,
"cores") == 0)) {
718 }
else if ((strcmp(cmd,
"egtpath") == 0)) {
721 }
else if ((strcmp(cmd,
"option") == 0)) {
725 }
else if (strcmp(cmd,
"usermove") == 0) {
DLL_API int bit_count(unsigned long long b)
Count the number of bits set to one in an unsigned long long.
Definition bit.c:72
char * board_to_FEN(const Board *board, const int player, char *string)
print to FEN description.
Definition board.c:1312
int board_from_FEN(Board *board, const char *string)
Set a board from a string description.
Definition board.c:212
void book_free(Book *book)
Free resources used by the opening book.
Definition book.c:1422
void book_save(Book *book, const char *file)
Save an opening book.
Definition book.c:1622
bool book_get_moves(Book *book, const Board *board, MoveList *movelist)
Get a list of moves from the book.
Definition book.c:2360
void book_load(Book *book, const char *file)
Load the opening book.
Definition book.c:1471
@ PASS
Definition const.h:37
@ NOMOVE
Definition const.h:37
@ WHITE
Definition const.h:43
@ EMPTY
Definition const.h:44
@ STOP_ON_DEMAND
Definition const.h:75
@ STOP_TIMEOUT
Definition const.h:74
@ STOP_END
Definition const.h:76
@ STOP_PONDERING
Definition const.h:73
@ IS_WAITING
Definition const.h:100
@ IS_ANALYZING
Definition const.h:102
void version(void)
Print version & copyright.
Definition main.c:27
void line_print(const Line *line, int width, const char *separator, FILE *f)
Print a move sequence.
Definition move.c:610
void move_print(const int x, const int player, FILE *f)
Print out a move.
Definition move.c:110
#define foreach_move(iter, movelist)
Definition move.h:78
Options options
Definition options.c:22
@ EDAX_TIME_PER_GAME
Definition options.h:19
@ EDAX_TIME_PER_MOVE
Definition options.h:20
void play_store(Play *play)
store the game into the opening book
Definition play.c:1175
void play_print(Play *play, FILE *f)
Print the game state.
Definition play.c:1225
void play_set_board_from_FEN(Play *play, const char *board)
Set a new board.
Definition play.c:828
void play_ponder(Play *play)
Ponder.
Definition play.c:729
void play_stop_pondering(Play *play)
Stop pondering.
Definition play.c:749
void play_new(Play *play)
Start a new game.
Definition play.c:62
void play_init(Play *play, Book *book)
Initialization.
Definition play.c:27
bool play_user_move(Play *play, const char *string)
Play a user move.
Definition play.c:909
Move * play_get_last_move(Play *play)
Get the last played move.
Definition play.c:927
void * play_ponder_run(void *v)
do ponderation.
Definition play.c:662
void play_undo(Play *play)
Undo a move.
Definition play.c:779
bool play_is_game_over(Play *play)
Check if game is over.
Definition play.c:190
void play_go(Play *play, const bool update)
Start thinking.
Definition play.c:214
void play_free(Play *play)
Free resources.
Definition play.c:52
Edax play control - header file.
const Selectivity selectivity_table[]
Definition search.c:97
unsigned long long search_count_nodes(Search *search)
Return the number of nodes searched.
Definition search.c:1073
void search_set_task_number(Search *search, const int n)
Change the number of task.
Definition search.c:847
void search_cleanup(Search *search)
Clean-up some search data.
Definition search.c:578
void search_set_observer(Search *search, void(*observer)(Result *))
set observer.
Definition search.c:1095
int search_guess(Search *search, const Board *board)
Guess the bestmove of a given board.
Definition search.c:1369
int search_count_tasks(const Search *search)
Count the number of tasks used in parallel search.
Definition search.c:1324
void search_resize_hashtable(Search *search)
Definition search.c:333
void search_stop_all(Search *search, const Stop stop)
Stop the search.
Definition search.c:1335
long long search_time(Search *search)
Return the time spent by the search.
Definition search.c:1061
void statistics_print(FILE *f)
Print statistics.
Definition stats.c:112
unsigned long long player
Definition board.h:27
unsigned long long opponent
Definition board.h:27
The opening book.
Definition book.h:25
bool need_saving
Definition book.h:47
int verbosity
Definition book.h:36
Search * search
Definition book.h:49
LogFile.
Definition util.h:423
FILE * f
Definition util.h:424
int score
Definition move.h:23
int x
Definition move.h:22
PlayType play_type
Definition options.h:42
bool can_ponder
Definition options.h:43
int n_task
Definition options.h:29
int level
Definition options.h:40
char * ui_log_file
Definition options.h:78
long long time
Definition options.h:41
double nps
Definition options.h:50
char * book_file
Definition options.h:59
int hash_table_size
Definition options.h:25
char * name
Definition options.h:81
bool auto_store
Definition options.h:84
int verbosity
Definition options.h:32
int player
Definition play.h:32
bool verbose
Definition play.h:57
Board board[1]
Definition play.h:26
long long left
Definition play.h:42
int initial_player
Definition play.h:33
Board initial_board[1]
Definition play.h:27
Thread thread
Definition play.h:53
bool launched
Definition play.h:56
Search search[1]
Definition play.h:28
volatile PlayState state
Definition play.h:37
struct Play::@23 ponder[1]
int type
Definition play.h:31
Book * book
Definition play.h:30
bool book_move
Definition search.h:50
unsigned long long n_nodes
Definition search.h:49
int score
Definition search.h:45
long long time
Definition search.h:48
int n_moves_left
Definition search.h:52
int selectivity
Definition search.h:43
Line pv[1]
Definition search.h:47
int depth
Definition search.h:42
int n_moves
Definition search.h:51
const char * separator
Definition search.h:145
Result * result
Definition search.h:151
const char * header
Definition search.h:144
int id
Definition search.h:101
struct Search::@25 options
int verbosity
Definition search.h:142
int depth
Definition search.h:117
volatile Stop stop
Definition search.h:122
int percent
Definition search.h:28
int type
Definition ui.h:36
Play play[2]
Definition ui.h:32
Book book[1]
Definition ui.h:33
int n_games
Definition xboard.c:31
unsigned long long n_nodes
Definition xboard.c:30
unsigned long long time
Definition xboard.c:29
bool ui_event_exist(UI *ui)
ui_event_exist
Definition ui.c:189
void ui_event_wait(UI *ui, char **cmd, char **param)
Wait input.
Definition ui.c:147
char * parse_int(const char *string, int *result)
Parse an integer.
Definition util.c:761
void thread_create2(Thread *thread, void *(*function)(void *), void *data)
Create a thread.
Definition util.c:922
void thread_join(Thread thread)
Join a thread.
Definition util.c:940
void string_to_lowercase(char *s)
Change all char of a string to lowercase.
Definition util.c:355
int string_to_int(const char *s, const int default_value)
Convert a string into an integer.
Definition util.c:457
char * parse_skip_spaces(const char *string)
Skip spaces.
Definition util.c:514
double string_to_real(const char *s, const double default_value)
Convert a string into a real number.
Definition util.c:488
char * parse_word(const char *string, char *word, unsigned int n)
Parse a word.
Definition util.c:562
void relax(int t)
sleep for t ms.
Definition util.c:203
long long string_to_time(const char *string)
Read time as "D:HH:MM:SS.C".
Definition util.c:320
Miscellaneous utilities header.
#define log_close(l)
Close an opened log file.
Definition util.h:435
long long real_clock(void)
#define MIN(a, b)
Definition util.h:101
#define log_print(l,...)
Print into the log file.
Definition util.h:442
#define log_open(l, file)
open a log file if allowed.
Definition util.h:429
#define log_is_open(l)
Check if the log stream can be used.
Definition util.h:448
#define BOUND(var, min, max, name)
Definition util.h:104
static void xboard_setup(Play *play)
Definition xboard.c:154
static void xboard_observer(Result *result)
Search oberver.
Definition xboard.c:38
static void xboard_check_game_over(Play *play)
Check if the game is over.
Definition xboard.c:251
static void xboard_error(const char *format,...)
Print an error.
Definition xboard.c:110
void ui_loop_xboard(UI *ui)
Loop event.
Definition xboard.c:440
static void xboard_analyze(Play *play)
Analyze.
Definition xboard.c:344
Log xboard_log[1]
Definition xboard.c:26
static void xboard_send(const char *format,...)
Send a command to xboard/winboard GUI.
Definition xboard.c:136
static void xboard_move(const int x)
Send a move to xboard/winboard GUI.
Definition xboard.c:166
static int hash_size(int n)
Definition xboard.c:271
static void xboard_book(Play *play)
Send a move from the book, if available.
Definition xboard.c:220
void xboard_stop_analyzing(Play *play)
Stop analyzing.
Definition xboard.c:321
static void xboard_loop_analyze(UI *ui)
Analyze.
Definition xboard.c:367
void ui_init_xboard(UI *ui)
initialize xboard protocol.
Definition xboard.c:72
void ui_free_xboard(UI *ui)
free resources used by xboard protocol.
Definition xboard.c:97
static void xboard_go(UI *ui, XBoardStats *stats)
Definition xboard.c:283
static void xboard_hint(Play *play)
Send a hint.
Definition xboard.c:191