From 2a84cfd92681c8560ad42801ee7b42dc44f6385f Mon Sep 17 00:00:00 2001 From: Jean-loup Gailly Date: Mon, 1 Aug 2011 21:35:01 +0200 Subject: [PATCH] UCT: add stones_only option (do not count eyes) Nice for teaching go to kids. Maximize score when this option is set. --- board.c | 4 +++- board.h | 1 + uct/search.c | 2 +- uct/uct.c | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/board.c b/board.c index 895e6d4..901d1de 100644 --- a/board.c +++ b/board.c @@ -1433,7 +1433,7 @@ board_fast_score(struct board *board) foreach_point(board) { enum stone color = board_at(board, c); - if (color == S_NONE) + if (color == S_NONE && board->rules != RULES_STONES_ONLY) color = board_get_one_point_eye(board, c); scores[color]++; // fprintf(stderr, "%d, %d ++%d = %d\n", coord_x(c, board), coord_y(c, board), color, scores[color]); @@ -1453,6 +1453,8 @@ board_tromp_taylor_iter(struct board *board, int *ownermap) foreach_free_point(board) { /* Ignore occupied and already-dame positions. */ assert(board_at(board, c) == S_NONE); + if (board->rules == RULES_STONES_ONLY) + ownermap[c] = 3; if (ownermap[c] == 3) continue; /* Count neighbors. */ diff --git a/board.h b/board.h index 27735d3..7af701b 100644 --- a/board.h +++ b/board.h @@ -135,6 +135,7 @@ struct board { RULES_AGA, RULES_NEW_ZEALAND, RULES_JAPANESE, + RULES_STONES_ONLY, /* do not count eyes */ } rules; char *fbookfile; diff --git a/uct/search.c b/uct/search.c index b0199fa..7bb69bd 100644 --- a/uct/search.c +++ b/uct/search.c @@ -480,7 +480,7 @@ uct_search_result(struct uct *u, struct board *b, enum stone color, /* If the opponent just passed and we win counting, always * pass as well. */ - if (b->moves > 1 && is_pass(b->last_move.coord)) { + if (b->moves > 1 && is_pass(b->last_move.coord) && b->rules != RULES_STONES_ONLY) { /* Make sure enough playouts are simulated. */ while (u->ownermap.playouts < GJ_MINGAMES) uct_playout(u, b, color, u->t); diff --git a/uct/uct.c b/uct/uct.c index e0b1913..3fe55cf 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -620,6 +620,11 @@ uct_state_init(char *arg, struct board *b) /* Use territory scoring (default is area scoring). * An explicit kgs-rules command overrides this. */ u->territory_scoring = !optval || atoi(optval); + } else if (!strcasecmp(optname, "stones_only")) { + /* Do not count eyes. Nice to teach go to kids. + * http://strasbourg.jeudego.org/regle_strasbourgeoise.htm */ + b->rules = RULES_STONES_ONLY; + u->pass_all_alive = true; } else if (!strcasecmp(optname, "banner") && optval) { /* Additional banner string. This must come as the * last engine parameter. */ -- 2.11.4.GIT