From 8b8525b8a9e72991188dae7176bd67d385bd8c56 Mon Sep 17 00:00:00 2001 From: Jean-loup Gailly Date: Sun, 4 Apr 2010 17:24:36 +0200 Subject: [PATCH] Move uct_notify() to slave.c --- uct/slave.c | 22 ++++++++++++++++++++++ uct/slave.h | 1 + uct/uct.c | 23 ----------------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/uct/slave.c b/uct/slave.c index e50d03f..82b40ab 100644 --- a/uct/slave.c +++ b/uct/slave.c @@ -21,6 +21,28 @@ /* UCT infrastructure for a distributed engine slave. */ +enum parse_code +uct_notify(struct engine *e, struct board *b, int id, char *cmd, char *args, char **reply) +{ + struct uct *u = e->data; + + static bool board_resized = false; + board_resized |= is_gamestart(cmd); + + /* Force resending the whole command history if we are out of sync + * but do it only once, not if already getting the history. */ + if ((move_number(id) != b->moves || !board_resized) + && !reply_disabled(id) && !is_reset(cmd)) { + if (UDEBUGL(0)) + fprintf(stderr, "Out of sync, id %d, move %d\n", id, b->moves); + static char buf[128]; + snprintf(buf, sizeof(buf), "out of sync, move %d expected", b->moves); + *reply = buf; + return P_DONE_ERROR; + } + return reply_disabled(id) ? P_NOREPLY : P_OK; +} + /* Get stats updates for the distributed engine. Return a buffer with * one line "played_own root_playouts threads keep_looking" then a list * of lines "coord playouts value amaf_playouts amaf_value". diff --git a/uct/slave.h b/uct/slave.h index 5d45e88..2c5a697 100644 --- a/uct/slave.h +++ b/uct/slave.h @@ -7,6 +7,7 @@ struct board; struct engine; struct time_info; +enum parse_code uct_notify(struct engine *e, struct board *b, int id, char *cmd, char *args, char **reply); char *uct_genmoves(struct engine *e, struct board *b, struct time_info *ti, enum stone color, char *args, bool pass_all_alive); #endif diff --git a/uct/uct.c b/uct/uct.c index ff61a89..4332fc3 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -144,29 +144,6 @@ uct_pass_is_safe(struct uct *u, struct board *b, enum stone color, bool pass_all return pass_is_safe(b, color, &mq); } -/* This function is called only when running as slave in the distributed version. */ -static enum parse_code -uct_notify(struct engine *e, struct board *b, int id, char *cmd, char *args, char **reply) -{ - struct uct *u = e->data; - - static bool board_resized = false; - board_resized |= is_gamestart(cmd); - - /* Force resending the whole command history if we are out of sync - * but do it only once, not if already getting the history. */ - if ((move_number(id) != b->moves || !board_resized) - && !reply_disabled(id) && !is_reset(cmd)) { - if (UDEBUGL(0)) - fprintf(stderr, "Out of sync, id %d, move %d\n", id, b->moves); - static char buf[128]; - snprintf(buf, sizeof(buf), "out of sync, move %d expected", b->moves); - *reply = buf; - return P_DONE_ERROR; - } - return reply_disabled(id) ? P_NOREPLY : P_OK; -} - static char * uct_printhook_ownermap(struct board *board, coord_t c, char *s, char *end) { -- 2.11.4.GIT