alpha-zero-general icon indicating copy to clipboard operation
alpha-zero-general copied to clipboard

Possible wrong code?

Open WangChuanYuan opened this issue 4 years ago • 2 comments

https://github.com/suragnair/alpha-zero-general/blob/5156c7fd1d2f3e5fefe732a4b2e0ffc5b272f819/connect4/Connect4Logic.py#L77

This is the judgement of whether player has won in horizontally in connect4. But I prefer it should be len(player_pieces[0]) - self.win_length + 1

WangChuanYuan avatar Sep 26 '20 14:09 WangChuanYuan

Looks right. It's also not checking vertical win, as you pointed out. Very confusingly written code.

yunjiangster avatar Oct 31 '21 06:10 yunjiangster

@WangChuanYuan Apparently fortunately the code wouldn't break, since if you loop too far, the last check starting at len(player_pieces) - self.win_length + 2 is only self.win_length - 1-long, and won't return true.

@yunjiangster The code does check for vertical win here -- sorry I don't know how to embed a line of code in an existing issue.

ngoctnq avatar Mar 22 '24 22:03 ngoctnq