Fix a bug that an SGF file/string cannot contain 2 consecutive moves of the same color #1653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1469.
As I'm not a C++ developer, please check my modifications carefully to see if they are all correct. I've tested, but maybe there're coding style or other problems.
This bug will be triggered if:
AW
and the first move is WHITE; orAW
but there'sAB
, and the first move is BLACK.The reason is that SGFTree passes
get_to_move()
as the argument when callingget_move
method, so if all moves are not "black, white, black, white...", then it won't be loaded correctly. (Here all handicap/setup stones can be considered as one move and the color can be considered as black if there's noAW
, or white if there'sAW
.)I've replaced 2 places of
get_move
. There's still one place left, but that's related to training so it's impossible to trigger this bug (but maybe better also change it?).The
follow_mainline_state
modification is required. But during my test, I foundpopulate_states
modification takes no effect, that is, it seems also OK if unchanged.Another thing I don't know why is that
std::make_pair(FastBoard::INVAL, 0)
works, but if modified tostd::make_pair(FastBoard::INVAL, SGFTree::EOT)
then it will report error when compiling.