abassibe / Gomoku

2 stars 0 forks source link

Fix crash when playing with hint enabled #103

Closed demonoidv closed 3 years ago

demonoidv commented 3 years ago

This should fix the crash we have sometimes (actually, quite often) when playing with the help of the hint mode. It's a bit complicated to explain in details what was wrong, but in a few words, the issue was that the Python part seems to keep the move returned by the AI for the hint (so, not a move that has actually been played) in memory and seems to send it to the Rust part just like it was an actual move played by one of the two players. So, if the AI wants to play this exact move, the Rust part would panic (because we compare the last move played with the move generated by the AI to determine if there is actually a move to play, this logic is not good at all, especially since there is just en unwrap() in the calling part. Also, this logic has no more reason to exist since the Python part now does a pretty good job at determining the end of the game).

Well, maybe a bit too many words here but I want to be sure we will be able to remember what was the issue and how we fixed it.

WARNING: There is probably something wrong in the Python part as well (it should not consider the move generated for the hint as an actual move for instance).