Fixes for release 2 + likely sequel = header file


No release 2 yet. But it must be close. And I hope/think that pushing this to Itch.io, even if the readership is not great, will  help me finish the deal. I'll have committed myself.

For the post-comp version of Fivebyfivia, the main thing I wanted was the GO TO <square> command. That's pretty much been tested. And I also wanted to re-check some of the features I didn't have time for. Enough popped up from general bug fixes that I'd like to write a devlog.

I mentioned I had a good idea for a sequel, and it's rolling along nicely. But I realized I was copying a lot of code. Copying code is okay if I need slight tweaks and the code will probably be stable. And for the very short stubs I have a header called Trivial Niceties.

But for Fourbyfouria, there's stuff that won't easily port to the next game, but it's tricky enough I'd like to rewrite it as little as possible. I realized how much cutting and pasting I was doing with the code. I could've made this common file sooner, but cutting and pasting worked well enough. The event that made me decide to go through with it was tracking parser commands that were <letter> <number> but not a1-e5. I just didn't want two branches of regex code, even if it was relatively easy. You can see them in chapter irregular and non-existent rooms for humor value only. But it wasn't just figuring b6 or z0 or some square not on the board. I realized I just wanted parser errors to match, and if I had an error message for 5b, it would probably be appropriate for 4b, and vice versa. So why duplicate the effort?

I also realized I could use Python to see what lines each of my main story.ni files had in common. Then once I created the common file, I could check it against 5b's and 4b's story.ni. It went much quicker than I thought, getting the identical-lines files to a reasonable size. Of course, there would always be false positives for basic Inform commands, e.g. "yes;", "no;", "the rule succeeds;" and "the rule succeeds." I suppose I could write an ignore-file if I ever need to do this again. But I was able to collapse a bunch of rewritten code.

I was worried there might be problems compiling or serious bugs--and there were a few, but the fixes were obvious! And the bugs that turned up were sort of hidden and not a result of the actual merge to the common file.

Thus was the Chess Common header created. I'd like to encourage you to click on the link, because I think a lot will make sense, even if you don't know much about chess or inform 7. There's the nontechnical stuff, like [5b] for Fivebyfivia, or "[verbs]" to give the different commands that show basic verbs.

You can probably see the room definitions after that. I don't link them together ("a2 is east of a1,") because that information is in the main files. For 5b, it's checking through knightly directions to see rooms that differ by 2x/1y or 1x/2y. For 4b, it's the cardinal directions. You can see how I defined directions as having xness and yness, which is what you'd expect (North is 0, 1 and southwest is -1, -1 and so forth.) I realized I could move stuff like testing if a room was on the edge as well.

You may also notice about 200 lines dedicated to defining verbs, as well. This is one of those things that seem trivial, but when I was writing test scripts, 1) I wanted them to match up and 2) I had just written a script that looked for definitions in the source like so:

understand "go to [any puzzly room]" as gotoing.
understand "go to" as gotoing.

Then I made sure my testing scripts hit them at least once. It wasn't hard to track "include" files as well. So I wanted that coverage, and I wanted the commands consistent, for people who maybe wanted to play each game in order, so the parser would be minimally confusing.

There were other things, too: I got a suggestion that the horse was sort of a character in 5b, so why not 4b? The common file made it easier. I just moved the knightly directions code from 5b to 4b, then gave 4b a "check going a knightly direction" rule. It was pleasing to see how my engineering efforts (put everything into a header file) paid off by making a narrative/aesthetic fix a lot easier.

I was worried this small sub-project wouldn't pay off, but I really think it did. Probably part of that was just confidence I could clean my code up, or being able to perform an engineering task like this quicker than I thought.

But I think I got concrete benefits from not having my main files cluttered. It seemed easier to find what to edit, where, to make a cosmetic change. While it'd become second nature to have the testing file separate. Here's 5b's, which isn't huge, but hopefully the tests are clear. The test names are short as Inform uses a maximum 9-letter word dictionary by default. I didn't consider that maybe a definitions file could be, too. I think having it off to the side helped me focus on creative stuff a bit better.

Get Fivebyfivia Delenda Est

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.