Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Bitboards and Connect Four (github.com/denkspuren)
38 points by pncnmnp on Feb 26, 2024 | hide | past | favorite | 4 comments


My connect-4 page [1] also links to this comprehensive explanation.

[1] https://tromp.github.io/c4/c4.html


I used a similar technique in a university class. We were doing a Connect 4 bot tournament, and I wanted mine to be as optimized as possible.

But in the end I spent all my time playing around with bitwise operations, so had no time left to add in multiple threads (so couldn't was slowed down by a factor of 4 or so) timing (so had to cut off the search early to not accidentally go over the limit), or to tweak the score heuristic.

Which meant my program only got second place. Still, I think the teacher enjoyed it, and there were some oohs and aahs when my program output moves basically instantly during the tournament.


As I understand it, chess engines generally do something similar, taking particular advantage of the fact that chess boards are 8x8 in size.


Reminds me of a similar write-up about hexagonal grids posted to HN 10+ years ago:

https://news.ycombinator.com/item?id=5809724




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: