From 7a240fa7abf5d7730814a56eb1d7698fa12bd9a2 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 14 Feb 2010 02:38:08 +0100 Subject: [PATCH] Board probdist: Invalid and eye-filling moves receive zero probability --- board.c | 15 ++++++++++++++- board.h | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/board.c b/board.c index 96eaae9..1bb8517 100644 --- a/board.c +++ b/board.c @@ -401,9 +401,18 @@ board_gamma_update(struct board *board, coord_t coord, enum stone color) { #ifdef BOARD_GAMMA assert(board->gamma); - float value = 1.0f; + /* Punch out invalid moves and moves filling our own eyes. */ + if (board_at(board, coord) != S_NONE + || (board_is_eyelike(board, &coord, stone_other(color)) + && !trait_at(board, coord, color).cap) + || (board_is_one_point_eye(board, &coord, color))) { + probdist_set(&board->prob[color - 1], coord, 0); + return; + } + /* We just quickly replicate the general pattern matcher stuff * here in the most bare-bone way. */ + float value = 1.0f; if (trait_at(board, coord, color).cap) value *= board->gamma->gamma[FEAT_CAPTURE][0]; if (trait_at(board, coord, stone_other(color)).cap @@ -1062,6 +1071,8 @@ board_play_outside(struct board *board, struct move *m, int f) board_at(board, coord) = color; if (unlikely(!group)) group = new_group(board, coord); + board_gamma_update(board, coord, S_BLACK); + board_gamma_update(board, coord, S_WHITE); board->last_move2 = board->last_move; board->last_move = *m; @@ -1156,6 +1167,8 @@ board_play_in_eye(struct board *board, struct move *m, int f) board_at(board, coord) = color; group_t group = new_group(board, coord); + board_gamma_update(board, coord, S_BLACK); + board_gamma_update(board, coord, S_WHITE); board->last_move2 = board->last_move; board->last_move = *m; diff --git a/board.h b/board.h index 797bceb..a7b8f34 100644 --- a/board.h +++ b/board.h @@ -169,8 +169,8 @@ struct board { * multiplying gammas of the appropriate pattern features based on * pat3 and traits (see pattern.h). The probability distribution * is maintained over the full board grid. */ - /* - Always invalid moves might have non-zero probability. (TODO) - * - Self-eye-filling moves might have non-zero probability. (TODO) + /* - Always invalid moves are guaranteed to have zero probability. + * - Self-eye-filling moves will always have zero probability. * - Ko-prohibited moves might have non-zero probability. * - FEAT_CONTIGUITY is not accounted for in the probability. */ struct probdist prob[2]; -- 2.11.4.GIT