Saturday, January 29, 2022

I think I'm making a Mouse Guard app

So it just so happens that I started running a tabletop RPG, not Dungeons and Dragons, but a quirky little system called Mouse Guard.  All of the players' characters are sentient mice in a world where the Mouse territories are in a fight for survival against harsh elements of the weather, ferocious animals, and other mice.

Anyway, as part of preparing for a game session, I want to flesh out some towns, NPCs, and dungeons.  Some research tells me that I should determine a few attributes in advance.  The NPCs, for instance, should have a goal, a level of education, a trade, and so on.  The town itself should have a main industry, a determined size, a level of wealth, local resources, and so on.  For my game in particular, I want to simulate various political factions, so I want to record a list of relationships between different political factions and trades, so for instance if one faction would make one trade more powerful, a second trade would make that trade less powerful, then a person with that trade should be much more likely to support the first faction.

Anyways, at first I started typing this information into spreadsheets, but I realized that if I put it into a database, I could query and write programs to answer all kinds of questions about the data.  So I decided to do that.

Tomorrow is the second game session, so the best I could possibly hope for is to have a few towns and NPCs in SQLite db browser, but even that is going to be a big help.

Thursday, January 27, 2022

"Nationalized Charaters" are Just Characters

Today, I was going through a lesson on udacity about the Java Persistence API (JPA) and one of the example exercises was to write a Java program to store data with the JPA that, among other things:

Make sure that both the flower name and recipient name will support international language characters

In the context of the lesson, the Java annotation @Nationalized is presented, which apparently enables "National" character support.

I paused.  Like Spanish? ¿Que pasa? That's not international enough for you?

Of course, obviously, this requirement is talking about multi-byte characters, which are ubiquitous in Chineese, Japanese, and other logographic writing systems, which is why we have Unicode and the best representation, UTF-8. There are tons of blog posts that talk about this, and I'm well aware to always choose UTF-8.

But this is a Java application. Moreover, this is JPA, and the Java persistence API supports every database. Including databases that don't support UTF-8, the barbarians.

This became clear to me when I read this stack overflow post. The annotation doesn't exist to support Unicode, it exists to tell the database that if it's not already supporting Unicode, it better figure something out for this field because "national" characters are going into it.

By the way, welcome to my blog. I'm going to focus on explaining tidbits of knowledge that I gained while practicing programming. If that fails, I'll share some other kind of tidbit. Here's to 2022.