Maximin Connect 4 Completed
I've finished working on the Maximin Connect 4 program. I've set up a page where you can play around with the AI since I'm not sure how to embed HTML in these posts. Some general things I learned (I'll make a separate post with more Connect 4 specific ideas once I've run some more tests on the AI):
Fixing this shouldn't be that difficult; the psuedo code I read suggested using a ‘undoMove' function instead of creating new Arrays every ply. Thinking that storing an extra few Arrays wouldn't be too costly, I didn't do that. Since creating Arrays is costly, an ‘undoMove' function should be used.
- Implementing a working version of the psuedo code required over 20 times as many lines of code. In my defense, my code also includes the negamax algorithm; still actually writing the eval function and hooks for the rest of the Connect 4 program to use requires more verbosity then I was expecting. Looking over the code, there is some duplicated functionality that would be nice to remove, particularly the similarities between the negamax and alphabeta code.
- I'm never sure how general to make things ahead of time. Working on my reversi game, I initially created a version that worked locally in one browser window. After playing around with the hangout API, I slowly added functionality to the handout version – syncing board state between all participants computers, only allowing the active player make move, buttons to start a new game, ect. Once I finished reversi, I wanted to add more games, but the prospect of getting a new game working only though testing on hangouts was daunting because loading new version of code takes over a minute and I'm used to iterating much faster then that. Additionally, if I found problems with code that interacted with the hangout API, I'd have to also correct the issue in the other games code. While this isn't a huge deal with only two games, it'd become a big time suck once six or seven games were made. To get around these difficulties, I wrote a wrapper for the reversi program that generalized board updates and game endings away from the specific logic of reversi. While I was working on the wrappered reversi which worked locally, I felt fairly silly since I had already created a copy of reversi that worked locally! I think the extra effort was worthwhile – it only took me a few hours to write a checkers game with the local wrapper and it didn't require too much more work to make checkers also work with hangouts.