A couple of days ago, Penn Jillette posted an enhanced version of his "Monkey Tuesday" theme to his website. He stated that the theme was free and he was interested in seeing what could be done with it. Since I can't resist free, one verse from the Monkey Tuesday theme is now the "game over" theme for Voracity.
Yesterday Ravuya posted a terrific idea as a comment. Shelly thought it'd be a good idea to send out a daily email with the high scores and links to the games, thus making it easier to make a daily ritual of the games. I was pretty lukewarm on this idea. People seem to cotton to the idea of seeing how well they did at a game, but I've never had a good experience with daily emails. I inevitably become annoyed with 'em.
Ravuya suggested that instead I make an RSS feed out of the high scores. That way I could put together a daily entry of the scores along with a link to the current game. It'd serve the same purpose as a reminder, but it'd be much less obtrusive because it'd be showing up in your RSS reader of choice rather than your inbox.
Unfortunately, this brings up a problem. The way my games work is that high score tables are only generated when they're about to be viewed, not when the next day actually begins (12 AM CST in this case), thus freeing me from having some kind of server daemon.
That means if you go to http://www.thecodezone.com/games/poppies.php to play a game, the first thing it does is quietly check the date on the file http://www.thecodezone.com/games/tables/hitable_poppies.php. If the date on the file is different from the server's date, it quietly regenerates that file, showing it in a little floating frame. The upshot is that you see games from several hours ago, even though the table was generated just three seconds earlier (if you're the first person of the day to play the game).
Looking at all of the games for today, for example, the tables were all generated between 1:01 AM and 3:58 AM (CST). Those times correspond to the first time somebody played the game today.
Making an RSS feed would require me to rethink things a bit, otherwise I wouldn't really be able to guarantee a timely RSS delivery. It'd be sort of a dining philosopher's deadlock on a macro-scale. The games are waiting on someone to load the pages so it can update the tables, but meanwhile nobody's loading the games because they're not being reminded to play. The deadlock is only broken by someone playing the games without a reminder, this causing the games to write a new RSS and remind everyone to go and play.
Of course, that's a mite contrived, but it does underline my need for a different way to generate my tables. What it's all leading to is that I need to have. . .
1. A single piece of PHP somewheres that automatically generates all of the tables at once along with a public XML file that people can load into their RSS readers.
2. Something that'll cause that PHP code to run early in the morning.
Now then, It'd be pretty easy to make a little scheduler right here that loads up "regen-tables.php" at 1:00 every morning (CST), but that'd be a mite kludgy. For one, it adds another point of failure to the process. If I go on vacation or something happens that could limit my access to the machine, all of the high scores stop updating.
No, it needs to be something that lives on the server somewheres and automatically runs "regen-tables.php" at 1:00 every morning. I'll probably need to pester the crazywebhosting server-monkeys to see if such a thing is easy to set up.
Now then, next question. Do I need one RSS feed or seven? Easiest would be to have one RSS feed called hiscores.xml. It'd look something like this. . .
DAILY PUZZLE HIGH SCORES FOR 5/31/2006
ChessCards (link to ChessCards):
1. Fredrick Fribble, Moves: 207, Time 3:57
2. Zippy, Moves: 250, Time 4:50
ConFusebox (link to ConFusebox):
1. Zippy, Moves: 40, Time 2:30
2. Skippy, Moves: 30, Time 3:05
That'd be pretty straightforward, but it'd also be pretty long. Especially if the games start to get a larger following. If you only care about ConFusebox, you might not wanna sift through all the other scores every morning to see how you did. You might prefer a hiscores_confusebox.xml file that contains only those scores.
In that case, I'd still have a hiscores_all.xml that contains all of the scores (as above) for people (like me) who play all of the games.
Any thoughts? There's certainly no downside to having six individual feeds along with one uber-feed containing all of the scores, but is that just overengineering things? Will I end up with seven feeds, six of which everyone will ignore?
So your homework is the following:
1. How will I best handle doing one early-morning update of the high score tables?
2. One big RSS feed for all of the scores or seven RSS feeds, one for each game and one for all of the games together?