Plaintext level data
December 23rd, 2011A few days back, I got involved in some of the most asinine drama I could ever had imagined. Considering most internet drama is asinine, that’s saying something, but ofcourse that’s just my opinion. Basically, two of my friends on IRC are writing games, in two completely different styles. One, by NovaYoshi, is a graphically simple single-screen puzzle game. The other, by GreyMario, is somewhat more complex in the graphical sense. One has less than ten different tiles, the other potentially hundreds.
Now, GreyMario may make some mistakes in life, but he knows very well that when you have so many different tiles to store in a level map, you’d be better off with a byte stream of some sort. That is, you store the level data in some binary format that you’d need specialized tools (a level editor) for. And there’s nothing wrong with that approach. In contrast, Nova’s game uses plaintext data files.
The funny thing about plaintext level maps is that the most basic of basics as far as obviousness goes looks a little like this:
# E# # * * * ##H### ######## H # # H # # * * H # # * * * P H # ################
It’s quite clear what’s what and where it’d go, making the editing of the level map in any text editor very straightforward. The hashes are solid walls (as they more often than not are), the asterisks are pickups of some kind, possibly coins or gems or something like that, the ‘P’ is the player, the ‘E’ is, considering the rest, an exit, and the stack of ‘H’ is a ladder. It even looks kinda like a ladder. It’s pretty difficult to make grievous mistakes with this format, and it’s easy enough for the game to parse. In contrast, it’s pretty much impossible to display this format’s binary counterpart in the same way. If you displayed each byte value as a block of a unique color, you could maybe recognize the same basic level structure, but it’s no longer clear what the counterparts to ‘P’, ‘E’, and ‘H’ are.
However, this is not exactly what Nova’s game uses. Aside from some descriptive commands to name levels, describe them, and specify what enemies should appear, the map data itself uses two characters per tile:
# # # # # # # e e # # # # # # # `1 # # # # # # # . . # # # # # # # `2 # . . . . . . . . # # # # # # # `3 # . . . . . . . . # # # # # # # `4 # . . . . . . . . # # # # # # # `5 # . . . . . . . . # # # # # # # `6 # . . . . . . . . # # # # # # # `7 # . . . . . . . . # # # # # # # `8 # . . . . . . . . # # # # # # # `9 # . . . . . . . . # # # # # # # `A # . . . . . . . . # # # # # # # `B # . . . . . . . . # # # # # # # `C # . . . . . . . # # # # # # # # `D . . . . p . . . # # # # # # # # `E # # # # # # # # # # # # # # # # `F
According to Nova, there are two reasons for this. One, it fixes the aspect ratio, or so he claims. I personally couldn’t care less but it’s his design so I’ll just deal with it. Two, the space characters function as tile type commands of some sort. In the metadata that precedes the map, the designer can specify custom tiles and use them in the map data as ‘!’ tiles, as opposed to space. Note that the backtics at the end of each line mark the end, and the numbers are ignored. Also, the ‘e’ tiles are enemy entry points – they sort of “flow” into the screen from those spots, and are defined in the metadata.
GreyMario has friends of his own. People I don’t know, and don’t talk to because they aren’t just on another IRC channel, but on a completely different server. One of those friends, and I use the term loosely, caused the drama I mentioned at the beginning of this article.
Basically, LordTrevor considered plaintext the be-all-end-all of level data formats, even for complex, hundreds-of-tiles data, and would not listen to reason. That by itself isn’t that bad, but the amusing bit is how he claimed plaintext was user-friendly, easy to edit, and all that jazz. His first argument was already good – textual information was supposedly easier and faster for the game to read than a byte stream. And then GreyMario pasted a sample of what Trevor used in his game:
[o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][P][o][o][o][o][o][o][o][G][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][_][_][_][_][_][_][_][_][_][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o] [o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o][o]
Let me count the ways this is a bad format. One, the endless parade of brackets causes massive noise. They serve no obvious purpose whatsoever. Also, they make an already somewhat brittle format even more easy to break just by misplacing a pair. And when that happens, you can’t find the error because everything looks the same! Two, using ‘o’ for what I assume means “open air” causes contrast problems – it’s very difficult to find certain other tiles. In fact, when this first appeared in my IRC client, I couldn’t find the ‘P’ (probably for “player”) for almost a minute, and didn’t even notice there was a ‘G’ (goal?) until I pasted it into this article just now! Third, using ‘_’ for platforms. I’m guessing even Trevor noticed some contrast problems because that platform is the only thing that really stands out in this sample, and the all-but-industry-standard ‘#’ wouldn’t do. So because his empty air looks solid, the platforms have to look empty. How high do you have to be to come up with that?
Then there’s the problem of character range. On the average keyboard, you can type 26 letters, both upper and lowercase, ten digits and their shift-key symbols, and then another 22 symbols. That’s about ninety characters as a technical limit. For a game with more than a hundred tiles – like GM’s – that’s not enough. But if you go above that amount and get things like accented letters involved, you get encoding issues. Nothing at all would stop a user from saving his level map in Windows-1252 instead of the Unicode your game expects (hypothetically speaking), or things like accented characters not being stored in their precomposed form. The map’s readability is severely lowered too – even with only ~90 characters, you lose the obvious meanings – ‘/’ and ‘\’ might be grassy slopes, but you can’t use them for sloped ceilings, and there are no other characters like those. This makes plaintext intrinsically best suited to low-tilecount games like Nova’s Forehead Block Guy, and it logically follows that you get the most user-friendliness from a custom level editor. That, at least, gives the option of WYSIWYG, rendering the exact values moot.
And the best part? Nova is writing a level editor for FHBG as I type. Because the game also runs on systems without keyboards. Now that is being user-friendly.





There are several styles of indentation available to programmers, where C-like languages are concerned. That is, programming languages with braces. As the Jargon File explains: