From 1772383a1c3aada5799eb4ef32bab66ab03ef374 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 16 Jan 2012 19:03:46 +0100 Subject: [PATCH] middle_ladder_walk(): Allow alternative near-edge termination of ladders --- t-regress/games/2011-06-06-tyzef-pachi30s.sgf | 2 +- tactics/ladder.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/t-regress/games/2011-06-06-tyzef-pachi30s.sgf b/t-regress/games/2011-06-06-tyzef-pachi30s.sgf index 86970f5..2926db0 100644 --- a/t-regress/games/2011-06-06-tyzef-pachi30s.sgf +++ b/t-regress/games/2011-06-06-tyzef-pachi30s.sgf @@ -1,6 +1,6 @@ (;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2] RU[Chinese]SZ[19]KM[7.50]TM[1800]OT[5x30 byo-yomi] -PW[tyzef]PB[pachi30s]WR[7k]DT[2011-06-06]GC[17 D6:bad!{ladder} plays out ladder]PC[The KGS Go Server at http://www.gokgs.com/]C[pachi30s [-\]: GTP Engine for pachi30s (black): Pachi Distributed Engine version 8.99 (Hakugen-devel): I'm playing the distributed engine. When I'm losing, I will resign, if I think I win, I play until you pass. Anyone can send me 'winrate' in private chat to get my assessment of the position. +PW[tyzef]PB[pachi30s]WR[7k]DT[2011-06-06]GC[17 /D6:bad!{ladder} plays out ladder]PC[The KGS Go Server at http://www.gokgs.com/]C[pachi30s [-\]: GTP Engine for pachi30s (black): Pachi Distributed Engine version 8.99 (Hakugen-devel): I'm playing the distributed engine. When I'm losing, I will resign, if I think I win, I play until you pass. Anyone can send me 'winrate' in private chat to get my assessment of the position. ]RE[B+Resign] ;B[qc]BL[1796.606] ;W[ep]WL[1796.485] diff --git a/tactics/ladder.c b/tactics/ladder.c index 48f0a76..2dd1dd9 100644 --- a/tactics/ladder.c +++ b/tactics/ladder.c @@ -110,7 +110,19 @@ middle_ladder_walk(struct board *b, enum stone lcolor, int x, int y, int xd, int if (ladder_catcher(b, x - xd, y, lcolor)) ladder_horiz; do { + /* Terminate early if we got near the board edge + * and can force sagari: + * | . O . . + * | . 1 x . 2 would be expected by our ladder reader but we + * | 2 o o x essentially opt for 1 by explicit edge check + * | . x o x */ + if (board_atxy(b, x + 2 * xd, y) == S_OFFBOARD + && board_atxy(b, x + xd, y - 1) == S_NONE && board_atxy(b, x + xd, y + 1) == S_NONE) + return true; ladder_vert; + if (board_atxy(b, x, y + 2 * yd) == S_OFFBOARD + && board_atxy(b, x + 1, y + yd) == S_NONE && board_atxy(b, x - 1, y + yd) == S_NONE) + return true; ladder_horiz; } while (1); } -- 2.11.4.GIT