From c4803c84c0ed9a0ec30c57c43a3cd78fa93c459b Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 30 Jul 2012 14:27:13 +0200 Subject: [PATCH] Add support for RULES_PASS_STONES - player hands a stone to the opponent on pass Requested by Robert Jasiek for the 13x13 EGC2012 tournament. --- board.c | 7 +++++++ board.h | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/board.c b/board.c index 2e2ca06..a315ac8 100644 --- a/board.c +++ b/board.c @@ -1355,6 +1355,11 @@ int board_play(struct board *board, struct move *m) { if (unlikely(is_pass(m->coord) || is_resign(m->coord))) { + if (is_pass(m->coord) && board->rules == RULES_PASS_STONES) { + /* On pass, the player gives a pass stone + * to the opponent. */ + board->captures[stone_other(m->color)]++; + } struct move nomove = { pass, S_NONE }; board->ko = nomove; board->last_move4 = board->last_move3; @@ -1594,6 +1599,8 @@ board_set_rules(struct board *board, char *name) board->rules = RULES_AGA; } else if (!strcasecmp(name, "new_zealand")) { board->rules = RULES_NEW_ZEALAND; + } else if (!strcasecmp(name, "pass_stones")) { + board->rules = RULES_PASS_STONES; } else { return false; } diff --git a/board.h b/board.h index e87002a..aa8b8fb 100644 --- a/board.h +++ b/board.h @@ -132,13 +132,17 @@ struct board { * the board implementation is basically Chinese rules (handicap * stones compensation) w/ suicide (or you can look at it as * New Zealand w/o handi stones compensation), while the engine - * enforces no-suicide, making for real Chinese rules. */ + * enforces no-suicide, making for real Chinese rules. + * However, we accept suicide moves by the opponent, so we + * should work with rules allowing suicide, just not taking + * full advantage of them. */ enum { RULES_CHINESE, /* default value */ RULES_AGA, RULES_NEW_ZEALAND, RULES_JAPANESE, RULES_STONES_ONLY, /* do not count eyes */ + RULES_PASS_STONES, /* RULES_CHINESE + pass stones */ } rules; char *fbookfile; -- 2.11.4.GIT