My desire to be a Master Programmer has drawn me to find extracurricular programming projects. As you may recall, for the filterable WordPress gallery I did some significant programming, but it was all within WordPress, using a lot of WP’s custom functions and shortcodes from the plugin Media Library Assistant. I read once early on that WordPress is a bad way to learn PHP, but if you know PHP well you can do amazing things with WordPress. That seems wiser and wiser as I gain experience with both.
I also told you long ago that I wanted to learn PHP via creating a sort of RPG/adventure game, but I’ve come to realize that’s too large a project to begin with – not to mention the amount of time required to develop the game itself, independent of implementing it. I did make a character creation form way back when, but starting over recently I went simpler: tic-tac-toe. And it took hours. At least 5, maybe 6. It’s entirely PHP (and HTML, of course); there’s no JavaScript and the CSS is minimal. I could take it further, but there’s one problem: tic-tac-toe is awesomely boring. I did see a Games Magazine puzzle about tic-tac-toe played on three boards simultaneously (each player marks one square per turn, on the board of their choice), and if I do go back to it I’ll probably try a variation like that one.
In the meantime, though, I continued through my list of games to Mastermind. That’s the one where you have to guess a sequence of colors by getting feedback of the form “one part of this guess was completely correct, two were correct colors but in the wrong place, and one was completely incorrect.” This one didn’t require even the minimal AI of tic-tac-toe, but did require more complicated information to be stored from turn to turn. I also made it object-oriented, which wasn’t the case with tic-tac-toe. I styled the whole thing to look like marbles placed on a wooden board with cylindrical holes drilled into it, and let the player choose whether the secret sequence should allow duplicate colors or not (allowing duplicates is the “real” version, though not allowing duplicates is the default of my version).
Then I decided to AJAXify it, so the page wouldn’t bounce back up to the top every time you made a guess. That was more of an adventure than anticipated – the whole thing needed refactoring. After a good deal of argh I got it working, though, and it makes for a quicker and nicer play experience. I have to give credit here to Jade Krafsig, whose AJAX tic-tac-toe game was invaluable in getting Mastermind converted.
It is not responsive, I’ll warn you, but it’s enjoyable to play and fits even on a small laptop, so I thought I’d put it in my webspace to share: Play Mastermind. If you play it, let me know what you think!
Update: now you can also get the code for Mastermind on GitHub.