Connect 4
Mon 13 April 2015Connect 4 is a great game that two people play by dropping differently coloured pieces into a grid, where they fall to the bottom of the column. To win the game, one player must make a line of four of their pieces in a row, either horizontally, vertically or diagonally.
It’s great fun to play with friends, with all sorts of strategies, “traps” and “double-traps”. I’ve certainly always enjoyed a good game, so it struck me as a natural place to start when I wanted to build a simple game to play when I was bored.
I noticed that (aside from everyone getting sick of playing “that game”), there were people who would beat me nearly every time! Obviously my strategy was lacking in some subtle aspect, and my opponent was capitalizing on this.
Well, I’ve heard that the best way to learn is to teach, so I set about teaching my computer to play me. With my first little AI written, I pitted it off against one of my friends… and it was defeated with ease, without it’s opponent paying full attention to it. Great
Of course, I couldn’t stop there, I couldn’t live with the shame!
I began adjusting weightings, adding new heuristics, and generally making the computer smarter, sneakier and less forgiving.
It took 4 iterations of this improvement to come up with something that was good enough to beat me most times, and was only toppled by one of my most skillful friends. It’s hard to continue past there, since I couldn’t tell if changes were making it better or not (at least, not without a much larger sample size), so I wrapped it up and sent it out to the world!
I’ve since made the earlier prototypes available, and named each version after the friend that topped it.
Think you have what it takes to beat Logical Laura? Why not find out?