Assorted Kerkerkruip Inform questions

Kerkerkruip is mostly 15-10 year old Inform 7 code, with loads of Inform 6 inclusions that were mostly (read: entirely) not written by me and dependent on extension that have not been updated in ages. My current plan, after some thinking, is to stop meaning to update it and to instead start working on something I’m provisionally calling

Kerkerkruip 2: Bride of the Witch Queen

but of course using as much of the original code as I can. Now this would be a big project and I don’t want to focus on that (unless there’s interest in me keeping a design log, in which case I might do that if it fits competition rules). It might turn out to be vapourware. Rather, I want to understand some of the things that are going on in the original code. And I want to understand them in a way that makes me a better Inform programmer.

Here’s current Kerkerkruip code:

The meta flag is a truth state variable. The meta flag variable translates into I6 as "meta".

After taking a player action (this is the all out of world actions are fast rule):
	if the meta flag is true:
		now the take no time boolean is true.

This is the acting fast rule: [Stops the turn sequence rules before we reach the every turn rules.]
	if the take no time boolean is true:
		rule succeeds.
The acting fast rule is listed before the every turn stage rule in the turn sequence rules.

This works; it ensures that the every turn rules do not run after, say, saving the game. But it depends on a claim about how something translates into I6.

Is this still necessary? My understanding is that Inform 7 has been moving away from the need to include Inform 6 stuff. But more importantly, how can I know about things like this? Where do I look to find information about translating variables into I6, and what this ends up doing?

5 Likes

(As an illustration of why starting from scratch and then important small parts of code one-by-one seems like a good idea, there’s really no way I would have ever identified this code as the source of an abject compiler failure if I had been trying to compile all of Kerkerkruip! Jira )

2 Likes

meta is an Inform 7 flag explained in the WorldModelKit. From giving that page a quick read, I think the issue is that I6 verbs are marked as meta/out-of-world, whereas for I7 it is the action that matters. While they usually match up, sometimes they don’t. (I6 only gained the option to specify meta actions differently from verbs in August this year!) So “understand as a mistake” needs to be marked as an I7 meta action even while the verb might be an in-world action for other forms. Otherwise the meta flag is set in the Actions section.

Kerkerkruip adds a third layer on top - the “take no time” flag. This is so that looking/examining/etc don’t progress time. Could this have been accomplished without an extra layer? Possibly, I’m not sure of all the implications. If you were to try it again from scratch I’d try it without an extra variable and see if you can get by.

2 Likes

A quick test reveals that out-of-world actions do not trigger every turn rules out of the box, if that’s all you’re looking to do in this snippet.

2 Likes

You’re right that they don’t in a vanilla project, but they do in the Kerkerkruip ATTACK extension, presumably because we mess with the turn sequence rules. We need more fine-grained control because several actors – not always including and also not limited to the player – have to make decisions about what they do, sometimes reacting to others, before any actions are performed. This happens in the combat round rules.

Vanilla:

parse command rule
declare everything initially unmentioned rule
generate action rule
(follow the scene changing rules)
every turn stage rule
timed events rule
advance time rule
update chronological records rule
(follow the scene changing rules)
adjust light rule
note object acquisitions rule
notify score changes rule

Kerkerkruip ATTACK:

abide by the combat round rules rule
declare everything initially unmentioned rule
(follow the scene changing rules)
acting fast rule
every turn stage rule
timed events rule
advance time rule
when the combat status is combat inactive players don’t increment the turn count rule
update chronological records rule
(follow the scene changing rules)
adjust light rule
note object acquisitions rule
notify score changes rule

Here the acting fast rule stops the rest of the turn sequence rules, while the combat round rules contain machinery that triggers the parse command rule and the generate action rule when necessary. I suspect that meta-actions stop their rulebook from proceeding beyond the generate action rule; but while that rulebook is the turn sequence rules in vanilla, it no longer is in Kerkerkruip ATTACK.

1 Like

I’ll try! (Update: it seems to work.)

Another question… here’s something that I guess you wrote (I certainly did not!):

To #if debug and showing weightings: (- #ifdef DEBUG; if ( (+ Show AI weightings +) ) { -).
To #endif debug and showing weightings: (- } #endif; -).

This no longer compiles, because Inform now checks the Inform 6 inclusions and complains that they have ifs without endifs, or endifs without ifs. Since this code makes perfect sense, Inform’s checks are arguably too rigid. Do you think this is worth reporting on the bug tracker?

Unfortunately, this is working as designed. The idea is that each I6 inclusion is now processed on its own, then the whole thing is assembled into one big .inf file for compilation; this is why I6 inclusions in Inform 10 now replace entire routines instead of sections of routines.

It makes the compiler logic work a lot better, but it means we can no longer do conditional-compilation hacks like this.

1 Like

Boo! Though I guess I can live with it. :smiley:

Does that mean that this no longer works? (from Original Parser by Ron Newcomb)
To at this point (here - a control label): (- .{here}; -).
To go back/-- up/down to where (here - a control label): (- jump {here}; -).

That one might, because it happens within a single enormous I6 routine.

:astonished_face:

…so you’re engaging in multiple invocations of parse command and generate action within a single turn?

…why not let parse command and generate action happen in their own time via skipping the rest of the turn sequence? Are you storing up game state that would be hard to preserve?

The I6 compiler has been improved a lot recently so compile time #ifdefs may not be needed, it could just be checking a constant instead.

Kerkerkruip does not do multiple parse command and generate action invocations per turn, though it could without too much trouble. It does frequently do turns in which the player does not get to type a command, and it also frequently does turns where the player is not the ‘main’ actor.

Here’s what’s going on. Kerkerkruip sees the game turn (in the sense of ‘one run-through of the turn sequence rules’) as equivalent to a combat turn (in the sense of ‘one person gets to take an action in combat, and possibly other people get to react to that’). This means that the turn sequence rules start by finding out – through an initiative system – who the main actor will be, and then they ask that actor to choose an action (if it’s the player, this means parsing a command, if it’s an NPC, it means running the AI rules). The attack action then allows the person who is attacked to react to the attack (again, either by parsing a command or by running the AI rules; crucially, you cannot attack as a reaction). After everyone who needs to choose an action has done so, the actions are sorted in the right order and performed. Then we proceed with the rest of the turn sequence rules.

This system was built for generality, not all of which is used by Kerkerkruip. It’s perfectly possible to have a multi-people-attack that multiple people have to react to; to have reactions that require further reactions before anything is actually done (which could lead to two parse command triggers in a single turn); to have weird rules that switch the order in which actions and reactions are performed; to have effects that cancel other people’s actions before they are done; and so on. None of that was ever used (I think), but it wouldn’t be hard to do it.

4 Likes