Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug that an SGF file/string cannot contain 2 consecutive moves of the same color #1653

Closed
wants to merge 1 commit into from

Conversation

zhanzhenzhen
Copy link
Contributor

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:

  • There're 2 or more consecutive moves of the same color; or
  • There's AW and the first move is WHITE; or
  • There's no AW but there's AB, and the first move is BLACK.

The reason is that SGFTree passes get_to_move() as the argument when calling get_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 no AW, or white if there's AW.)

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 found populate_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 to std::make_pair(FastBoard::INVAL, SGFTree::EOT) then it will report error when compiling.

@gcp
Copy link
Member

gcp commented Jul 25, 2018

Another thing I don't know why is that std::make_pair(FastBoard::INVAL, 0) works, but if modified to std::make_pair(FastBoard::INVAL, SGFTree::EOT) then it will report error when compiling.

Seems to work for me. I did some minor cleanups here: #1654.

@gcp gcp closed this Jul 25, 2018
@gcp
Copy link
Member

gcp commented Jul 25, 2018

Actually, the compiler error was likely caused because this was missing:
7524a2f#diff-44ba5da097788068a1c8def978c3293cR40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants