From 7b28a8d7e440f7761121eb3faecb9780dff624af Mon Sep 17 00:00:00 2001 From: Carton He Date: Wed, 23 Dec 2020 00:11:56 +0800 Subject: [PATCH] Fix [tt] caused exception on small boards For board <= 19x19, according to https://www.red-bean.com/sgf/go.html: A pass move is shown as '[]' or alternatively as '[tt]' (only for boards <= 19x19). --- katrain/core/sgf_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katrain/core/sgf_parser.py b/katrain/core/sgf_parser.py index 158d6a8..43e81a4 100644 --- a/katrain/core/sgf_parser.py +++ b/katrain/core/sgf_parser.py @@ -29,7 +29,7 @@ class Move: @classmethod def from_sgf(cls, sgf_coords, board_size, player="B"): """Initialize a move from SGF coordinates and player""" - if sgf_coords == "" or Move.SGF_COORD.index(sgf_coords[0]) == board_size[0]: # some servers use [tt] for pass + if sgf_coords == "" or (sgf_coords == "tt" and board_size[0] <= 19 and board_size[1] <= 19): # [tt] can be used as "pass" for <= 19x19 board return cls(coords=None, player=player) return cls( coords=(Move.SGF_COORD.index(sgf_coords[0]), board_size[1] - Move.SGF_COORD.index(sgf_coords[1]) - 1),