Show HN: pure client-side Connect Four AI with Web Workers, AngularJS, Firebase
jsbin.com
jsbin.com
We were given the choice to alternatively implement a board game (pending approval) instead of taking a more formal final exam. The only catch was since it was a course focusing on Java, we had to use Swing (which if one has used Swing, the formal exam almost looks like the better option).
Figuring the game would be more fun, I ended up implementing connect four, thinking it would naively be easy enough to do the basics based on my previous GUI experience with Windows Forms and HTML/CSS and add to it if I had time. Boy, was I wrong.
Writing the game engine/logic was a great experience, but dealing with Swing took probably 70% of the time and had to ditch doing AI for a 2 player only approach. Just the quirky/unintuitive nature of the Swing GUI builders in comparison to Visual Studio Windows GUI Forms made it easier to just write out the GUI by hand (which was not that much better). The issue of it isn't even Swing itself causing headaches so much as the way the official Swing SDK written[1].
Code for it is on my Github still, but other than serving as a reference for anyone else (and warning in the readme), I think I would rather start over in a different language than contribute anymore to it :).
[1] A snippet of Qt Jambi and the same code written with the official Swing SDK (http://pastie.org/8324820)
There's a bug in the UI: placing a token should start the game in the same way as clicking "OK, go". Currently, the game itself will work fine but the red arrows at the top don't appear, and the text "You will play first?" doesn't change.
UI is good, gets the job done.
[0]: http://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning
The graphics and the UI are solid. And apparently, the AI is also solid.
Good work. How about a human vs human version?
Edit: Looks like the answer is no, since I drew it while playing second. One option to improve the engine could be to give it an opening book (this is what they do with chess engines).