I don’t have a SB-related picture today, but the cat we just recently adopted woke me up by booping me on the nose, which was adorable, so I’m sharing this. Also, I recently discovered that I enjoy coding to video game soundtracks, so I made a YouTube playlist of a bunch of ones that I liked and that work well for me. Let me know if you have any other suggestions!
And now…it’s question time!
- What did you learn yesterday?
- What are you going to do today?
- What do you expect to learn?
Yesterday was a day of getting ahead of myself. I went ahead and started the Roman Numeral kata, only to realize that I had no idea what I was doing. When I asked for help, Brandon suggested that I go back and work on the Coin Changer kata some more, saying it’s more important that I have mastery over that one than that I accomplish the entire list. We also refactored my code to add a loop rather than the not-very-DRY code I had previously.
We have a series of projects that we have to finish in order to pass out of the apprenticeship and move to an actual junior developer job. Since the requirements to apply for the apprenticeship changed after I had already started the tic-tac-toe game, I’m a little bit ahead of the curve, so yesterday I started working on the 4×4 version. I went back to my minimax version, because I figured that would be easier, and once I finished that I would move on to the rules-based one. I copied all my code into a new Github repo, changing the parts I thought would need to change, ran the game in my terminal…and it worked! Sorta…it let me play the first move, but then when it came time to switch players, it just froze up. I spent like an hour trying to figure out what was going on; I installed ByeBug and put it a couple places in an attempt to see what I did wrong, I texted Kevin and he walked me though some debugging also (debugging doesn’t work super well when you’re not both starting at your computer screen, FYI). I never got an error message, which made the whole thing mysterious and annoying. Brandon got out of the meeting he was in, walked to my computer and diagnosed the problem immediately.
Turns out that the the minimax algorithm works by building a move tree of all the possible moves that each player can move, and then choosing the best one, or the one that will lead to winning the game. This works pretty well in regular tic-tac-toe, when a 3×3 board gives you a relatively limited number of choices. Moving to a 4×4 board increases that number exponentially, however, and my poor little MacBook Air was straining under the calculations.
So…today I’m going to learn how to write code that limits the number of nodes that my code searches ahead of making a move. Brandon suggested two options: alpha beta pruning, which he said would probably be way overkill, and a depth limit search — I can tell it to only search 5 moves ahead, for instance, instead of the whole game. I’m also going to work once again on the Coin Changer kata, so hopefully I’ll cement the latest version in my brain.
I expect to learn about depth limit searches! I’m kind of excited about this, it seems a little more computer-sciency, but actually relevant. 🙂 I wish I had taken computer science or coding classes in college, although since I went to a little art school I’m not actually entirely sure if they even offered any. I’m glad to learn any way I can.