goboard_slow.py method does_move_violate_ko() Incorrect #34
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.
I believe the goboard_slow.py from chapter 3 has an error in checking for ko violation. The original code ends up only comparing player and the object id; the object id will always be different, so even when the new board is returned to the state that will violate ko, it won't be detected. The Zobrist code works fine because the hashes are directly compared. So this is minor because most people will want to use Zobrist anyway.
I added a test to the provided test code to prove this bug exists. Try the test against the old code, it should fail.
Arguably I should write a dunder eq for this fix, but I went with this approach first.