Today, neopagans—especially those who take their influence from the Celts—celebrate Lughnasadh, an ancient celebration marking the start of the harvest season. It probably inspired Christian Lammas, so even the non-neopagans have bread to eat.

A Lughnasadh festival, maybe 1904

And since man cannot live by bread—or even Red—alone (thanks, I’ll see myself out), let’s talk software.

Mystic T-Square 🔗

GitHub - jcolag/mystic-t-squareA possible game. Contribute to jcolag/mystic-t-square development by creating an account on GitHub.

At least until a new idea or the occasional bug shows up, I consider Mystic T-Square complete, as a playable, two-player game.

The game now tracks statistics on questions asked and answered, plus who won various games, maintaining that data in the browser’s local storage. At the bottom of the right-hand panel—where the questions live—you’ll now find buttons to show information about the game, the few game options available, and the statistics that I mentioned in the last sentence.

In many cases, since we only need to count things, the game updates its statistics through the following function.

function incrementStore(key) {
  let value = localStorage.getItem(key);

  if (value === null) {
    value = 0;
  } else {
    value = Number(value);
  }

  if (!Number.isInteger(value)) {
    return;
  }

  localStorage.setItem(key, value + 1);
}

In plain English, check the key—questionsAsked, for example—replace it with 0 if it doesn’t exist, and make sure that we have a number, so that nobody tries to increment the API session token or some similar stored value. If we cleared those hurdles, update the value with the value plus one. Then, populating the statistics calls localStorage.getItem() for each key, and inserts the results into the DOM.

The Future…and the Present 🔗

I can see some potential directions, from here. The game could cache questions for the next game, rather than wasting whatever remains of the eight questions requested at the start of each. It could provide an option to limit the questions by category. Another possible option could allow the user to turn off the “random diversity” code, limiting the tokens to lemon-yellow-faced, genderless emoji.

Of course, as described at some point, the game actually needs an automated player to handle the tiles. But that requires actually thinking through the math, so I don’t expect it to just happen, like the other changes might.

Meanwhile, you can now play Mystic T-Square at its permanent home, hosted on GitHub. I didn’t realize that deploying a (simple and static) site to GitHub pages only required turning it on. If you have played the game from its temporary location for testing, the old page will automatically forward you to the new page.

Redirection 🔗

Speaking of redirecting to the new page, I don’t have this checked in anywhere, because it doesn’t serve a real purpose. However, on the chance that anybody lands on this page looking for how to do handle redirection between webpages, the old Mystic T-Square page now looks like the following.

<html>
<head>
  <meta http-equiv="Refresh" content="0; url='https://jcolag.github.io/mystic-t-square/'" />
  <title>Mystic T-Square — Redirecting...</title>
</head>
<body>
  If redirection doesn't work, try
  <a href="https://jcolag.github.io/mystic-t-square/">here</a>.
</body>
</html>

And add whatever CSS that you might need, for the short time that the user will see the redirection page. If you feel particularly paranoid—I don’t, here, because the stakes seem extremely low—you could also add some JavaScript on page load.

window.addEventListener('load', (e) => {
  window.location.href = "https://jcolag.github.io/mystic-t-square/";
}

Between the HTML redirection, JavaScript redirection, and instructing the player to click through to the new location, that should work, no matter the browser.

Open Questions 🔗

If you do play Mystic T-Square with friends, please report back on the balance between players. Currently, the game simply alternates turns, one question and one tile movement. I decided on that primarily because it didn’t require any further thought, but also because it didn’t seem like the tile-moving players 🙅 needed much power, since the trivia-playing players 🙆 have a decent chance of foiling themselves, if a question comes up from a subject that they don’t have familiarity with.

Of course, that line of thinking also sounds naïve, so I’d love to hear feedback on whether one tile moved per question answered feels right, seems too powerful, or not powerful enough, especially contrasted with how successful the trivia game goes.

Entropy Arbitrage 🔗

GitHub - jcolag/entropy-arbitrage-codeThe Jekyll blog for https://john.colagioia.net/blog - jcolag/entropy-arbitrage-code

This week, I spent some time catching up on changes to the blog that I hadn’t yet published.

To start, I made this change a long time ago, but then just forgot to do anything about it: The newsletter pull-out tab (to the right on this and every post, if you read these posts from my blog) now also points to my Buy Me a Coffee page, where people (you?) can (should?) “follow me”—which includes receiving the newsletter, plus announcements for each post to the blog—without sending me any money or even creating an account.

The Buy Me a Coffee controls

I also brought some library versions up to date.

The bigger deal, though? Primarily with the excuse of last Sunday’s post about redemption arcs, but potentially for more data-oriented posts in the future, blog posts can now show graphs, courtesy of Chart.js. If you didn’t see it last week, check out this example.

I’ve only debugged the plugin for the line charts, so far, and even that, I have severely restricted to one specific use case: Mostly just showing changes in value over time, like the word counts for developer diary posts, shown above. But as I go, I expect to use the charts more, and will probably make the plugins a bit more sophisticated.

I should also mention that I haven’t perfected the plugin, even for its narrow use case. Posts with a graph will need to include the library manually, for now.

<script src="/blog/assets/chart.js"></script>

I don’t want to slow the page-load time for posts that don’t use it, but I couldn’t get a plugin to insert that reference automatically. In the ideal case, it would include the library a maximum of one time per post, but I’d need to research to figure out how to do something like that, unless I want to build another complicated JSON object like I do for the GitHub plugin.

The approach that I’ve used has a nice aspect, because I store the data for the chart and read it from a separate file. This prevents me from cluttering a post like this with individual word count numbers that the reader should never see, and makes it easier to share the data. I can also build on this: With more sophisticated processing of the data file than “put commas between the elements,” I can add labels and descriptions to the data that would help someone processing it on their own, but might have no use in the post. I may need to do something like this, anyway, if I ever want a pie or donut chart: The only practical way to handle the data, its labels, and (I imagine optionally) the colors would use tabular data.

Library Updates 🔗

I needed to bump library versions for Bicker. The blog’s code, too, but I already mentioned that.

Next 🔗

I see the library updates piling up, so I may focus on digging through them for the week, to buy myself some time to figure out the Mystic T-Square AI.

Also, now that I’ve gotten a taste for hosting things through GitHub Pages, I have to wonder how much work it would take my daily puzzle games and turn them into applications, rather than daily generated pages. I like the generated pages for ease of use and sharing, but they do take up space. I don’t imagine that the Daily Nonogram would work well as an “app,” since the randomness comes from Wikipedia’s server and requires heavy processing. But the Daily Iungimoji and Daily G.L.O.B.E. seem like they have sufficiently predictable requirements for each puzzle, that I could generate from the day.

Such a system wouldn’t get the puzzles for days that I had already generated, of course, without a lot more work, but I could see archiving the old puzzles to supplement the new.

And thinking about Mystic T-Square again, I should probably take my ideas listed above and turn them into issues on the repository. It also definitely wouldn’t hurt to comment the code; I’ve probably mentioned before that each bit of work that I’ve done seemed obvious and not in need of comment, but as an aggregate, it became less clear.


Credits: The header image is Puck Fair, Killorglin, Co. Kerry by an unknown photographer, long in the public domain.