Thursday, October 5, 2017

Update on the "Four in a Row" app progress

10/5/17

I had put the Connect Four clone project on hold while I was in school. I finished the first part of my dissertation, so now I have a couple of week break before returning to school, so I worked on the game project a bit more. I added some sounds, and tweeked the code to make it simpler to play.

The goal is for anyone to be able to pick up and play the game without any coaching, so simplicity is the order of the day. I made it easy to click any region on the screen and drop a token into place. Also I added some instructions to carry out if the program "senses" that there are four of the same colored tokens in a row. It was pretty easy, until I realized that the diagonal four-in-a-row routines would require a different approach then horizontal and vertical.

But, I got that problem solved with some elbow grease. If you know a little about programming and algorithm design, I used a "Brute Force" algorithm to check all possible cases for diagonal four-in-a-row success.  Basically, it asks, "Are there four in a row for Case 1?  No, Ok, how about Case 2..." and so on.  If you've never heard of brute force algorithms, it's basically what it sounds like. It checks each possible outcome, one at a time until it reaches all possible outcomes.

It's kind of a pain in the neck, but it works.

I'm 100% certain that a better programmer would have created an easier way, but I suppose that the good news is that part is done. Yay!