richardjs / zoe

AI engine for the strategy game Hive
GNU General Public License v3.0
2 stars 0 forks source link

Check for winning result before looking at actions. #17

Closed edre closed 1 year ago

edre commented 1 year ago

Previously this would miss some winning positions, then Node_expand on a state with no actions, and cause a read out of bounds on the empty actions list, then segfault.

Fixes #16.

richardjs commented 1 year ago

Hm, interesting. This suggests that state.winning_action isn't properly getting set here. A state that can lead to a state with a win shouldn't get past the winning_action check at the beginning of iterate.

Ultimately, I'd rather fix that source issue than modifying iterate to handle states with winning results. Let me see what I can find...

Do you happen to have a state that causes bestmove to crash?

edre commented 1 year ago

It's probably better to fix the bug at the source. This patch is more of a hack to demonstrate where the problem manifests.