From cae6cfa239210cad4413f5e6b2b9b9a4d45cecf7 Mon Sep 17 00:00:00 2001 From: Jean-loup Gailly Date: Sun, 9 May 2010 13:21:43 +0200 Subject: [PATCH] Distributed engine: force a different id if requested --- distributed/protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/distributed/protocol.c b/distributed/protocol.c index 71e1897..ac7b813 100644 --- a/distributed/protocol.c +++ b/distributed/protocol.c @@ -545,8 +545,11 @@ update_cmd(struct board *b, char *cmd, char *args, bool new_id) static int gtp_id = -1; int moves = is_reset(cmd) ? 0 : b->moves; if (new_id) { - /* fast_random() is 16-bit only so the multiplication can't overflow. */ - gtp_id = force_reply(moves + fast_random(65535) * DIST_GAMELEN); + int prev_id = gtp_id; + do { + /* fast_random() is 16-bit only so the multiplication can't overflow. */ + gtp_id = force_reply(moves + fast_random(65535) * DIST_GAMELEN); + } while (gtp_id == prev_id); reply_count = 0; } snprintf(gtp_cmd, gtp_cmds + CMDS_SIZE - gtp_cmd, "%d %s %s", -- 2.11.4.GIT