Live data from Hacker News

Play against the computer – Connect Four game in JavaScript

flydaddy.net

21–26 of 26 posts

Re: Play against the computer – Connect Four game in JavaScript

#21
post #6

Ran into bug - AI beat me by creating a diagonal with the piece in the top rank and it did not count that as endgame. I was able to keep playing.

Should be fixed now - an off by one error checking diagonals that hit the top of the board. Thanks!

Re: Play against the computer – Connect Four game in JavaScript

#22
post #7

ICYI Connect Four is a solved game, you can read about it here: https://en.wikipedia.org/wiki/Connect_Four#Mathematical_solu...

Yes, I may do a minimax version with a difficulty setting. That would be fun to do.

If you tell the optimal algorithm to only think 3 moves ahead, it's too easy, and if you let it think 4 ahead it becomes very difficult (but not quite impossible).

Re: Play against the computer – Connect Four game in JavaScript

#23

Earlier quoted context omitted.

It seems like going first is a disadvantage, since the AI can just play defensively until you are backed into a corner.

I've found that the only way to win is to go first, just like in tic tac toe. Going second can produce a draw at best, against an optimal opponent. This is just my experience though, not a strong assertion.

This is not true, I've played twice as the second player and won both. The seem to likes setting up 3 diagonal, during that you are free to setup your own lower trap with two intersecting diagonals. So far doing that always seems to win.

Re: Play against the computer – Connect Four game in JavaScript

#25
post #7

ICYI Connect Four is a solved game, you can read about it here: https://en.wikipedia.org/wiki/Connect_Four#Mathematical_solu...

You can solve it yourself from scratch in a few minutes by running my Fhourstones benchmark [1]. Other interesting connect-4 tidbits may be found on my connect-4 page [2].

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

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

Post reply on HN