How to write Inform 7 code using Inform 7 Buddy (Quest of the Mysteries)

Hi, have you heard of the Custom GPT: Inform 7 Buddy. It helps you write code similarly to how VS Code has Copilot. It can be found on the ChatGPT App.

Here is how I used it recently. In my Zork like adventure, I wanted a puzzle which went like this. You need to go on a treadmill, to earn a loaf of bread which you give to a beggar, in order to receive a powerful amulet.

This is complicated by the fact that you need to go on the treadmill three times in order to earn your loaf. Further, the Beadle prevents you from going on the treadmill without you giving him a work permit, which you can receive elsewhere in the adventure from a Job Coach in the Employment Exchange.

This is probably too vague a description for I7 Buddy, so I entered the following prompt:

can you give me the code for the following puzzle: The game starts with variable workhouse_state set to 0. after entering employment exchange with workhouse_state set to 0, The job coach says “Greetings traveller. There is some work available in the work house are you interested?” If the player says yes: the job coach says “You’ll need this permit though!” He hands the player the permit and workhouse_state is set to 1. after entering the workhouse with workhouse_state set to 0: the beadle says “You’ll need a permit to do some work before I can give you a loaf of bread.” After entering rhe workhouse with workhouse_state set to 1 and player is carrying the permit, the beadle says “Hand me that permit and then have a go on the treadmill.” If the player gives the beadle the permit then workhouse_state is set to 2. If the player then goes on the treadmill: he works for fifteen minutes before collapsing on the floor exhausted. Then the workhouse_state is set to 3. The Beadle says “You’ll need to work harder than that for your bread.” When workhouse_state is set to 3, if the player tries to go on the treadmill, The beadle prevents him and says "You’ll need another work permit. After entering the employment exchange when workhouse_state is set to 3, the Job coach says “There’s more work at the workhouse. Are you interested?” If the player says yes. The job coach gives him the permit and workhouse_state is set to 4. If the player enters the workhouse with workhouse_state set to 4. The beadle says “Hand me that permit and then have a go on the treadmill.” If the player gives the beadle the permit then workhouse state is set to 5. If the player then goes on the treadmill: he works for another fifteen minutes before collapsing, and coughing up blood. Then the workhouse state is set to 6. The Beadle says “You’ll need to work harder than that for your bread.” When workhouse_state is set to 6, and the player tries to go on the treadmill, The beadle prevents him and says "You’ll need another work permit. After entering the employment exchange when workhouse_state is set to 6, the Job coach says “There’s more work at the workhouse. Are you interested?” If the player says yes. The job coach gives him the permit and workhouse_state is set to 7. If the player enters the workhouse with workhouse_state set to 7. The beadle says “Hand me that permit and then have a go on the treadmill.” If the player gives the beadle the permit then workhouse state is set to 8. If the player then goes on the treadmill: he works for another fifteen minutes before collapsing, and coughing up more blood. workhouse_state is set to 9, and finally the beadle gives the player a loaf of bread.

As you can see this is pretty exact, but not very pretty. Here is the response I got:

"The Workhouse Puzzle" by You

The Employment Exchange is a room. "A dingy office with yellowing posters about job readiness programs."
The Workhouse is east of the Employment Exchange. "The grim, echoing interior of the workhouse. A treadmill dominates the room."

The Job Coach is a man in the Employment Exchange. The Beadle is a man in the Workhouse.

The player carries nothing.

The treadmill is a device in the Workhouse. The treadmill is switched off.

The permit is a thing. The permit is nowhere.

The loaf of bread is a thing. The loaf of bread is nowhere.

Workhouse_state is a number that varies. Workhouse_state is 0.

To offer-permit:
	say "The Job Coach says, 'You'll need this permit though!'";
	now the player carries the permit;
	increase workhouse_state by 1.

To beadle-request:
	say "The Beadle says, 'Hand me that permit and then have a go on the treadmill.'";

To treadmill-collapse:
	say "You work for fifteen minutes before collapsing on the floor, exhausted.";
	increase workhouse_state by 1;
	if workhouse_state is 3:
		say "The Beadle sniffs. 'You'll need to work harder than that for your bread.'";
	if workhouse_state is 6:
		say "You cough up blood. The Beadle crosses his arms. 'You'll need to work harder than that for your bread.'";
	if workhouse_state is 9:
		say "You cough up more blood. The Beadle nods, satisfied. 'You've earned this.'";
		now the player carries the loaf of bread.

After going to the Employment Exchange:
	if workhouse_state is 0:
		say "The Job Coach says, 'Greetings traveller. There is some work available in the workhouse. Are you interested?'";
	else if workhouse_state is 3:
		say "The Job Coach says, 'There's more work at the workhouse. Are you interested?'";
	else if workhouse_state is 6:
		say "The Job Coach says, 'There's more work at the workhouse. Are you interested?'";
	else if workhouse_state is 9:
		say "The Job Coach looks at you with pity. 'There’s no more work for you, friend.'";

Understand "yes" as saying yes.

Saying yes is an action applying to nothing.

Carry out saying yes:
	if the location is the Employment Exchange and (workhouse_state is 0 or workhouse_state is 3 or workhouse_state is 6):
		offer-permit;
	otherwise:
		say "No one responds.";

After going to the Workhouse:
	if workhouse_state is 0:
		say "The Beadle says, 'You'll need a permit to do some work before I can give you a loaf of bread.'";
	else if (workhouse_state is 1 or workhouse_state is 4 or workhouse_state is 7) and the player carries the permit:
		beadle-request.

Instead of giving the permit to the Beadle:
	if (workhouse_state is 1 or workhouse_state is 4 or workhouse_state is 7):
		remove the permit from play;
		increase workhouse_state by 1;
		say "You hand over the permit. The Beadle grunts approvingly.";
	else:
		say "The Beadle sneers. 'That's no use to me now.'";

Instead of switching on the treadmill:
	if workhouse_state is 2 or workhouse_state is 5 or workhouse_state is 8:
		treadmill-collapse;
	else if workhouse_state is 3 or workhouse_state is 6:
		say "The Beadle blocks your path. 'You'll need another work permit.'";
	else:
		say "You're not sure how to use the treadmill yet.";

Instead of entering the treadmill:
	try switching on the treadmill.

As you can see a massive improvement. Unfortunately it didn’t work right out of the box, and I had to spend another hour debugging

Here is the code I finally used:


Workhouse_state is a number that varies. Workhouse_state is 0.

To offer-permit:
	say "The Job Coach says, 'You'll need this permit though!'";
	now the player carries the permit;
	increase workhouse_state by 1.

To beadle-request:
	say "The Beadle says, 'Hand me that permit and then have a go on the treadmill.'";

To treadmill-collapse:
	say "You work for for hours before collapsing on the floor, exhausted.";
	increase workhouse_state by 1;
	if workhouse_state is 3:
		say "The Beadle sniffs. 'You'll need to work harder than that for your bread.'";
	if workhouse_state is 6:
		say "You cough up blood. The Beadle crosses his arms. 'You'll need to work harder than that for your bread.'";
	if workhouse_state is 9:
		say "You cough up more blood. The Beadle nods, satisfied. 'You've earned this.'";
		now the player carries the loaf of bread.

After going to the Employment Exchange:
	try looking;
	if workhouse_state is 0:
		say "The Job Coach says, 'Greetings traveller. There is some work available in the workhouse. Are you interested?'[line break]Type accept if you are.'";
	else if workhouse_state is 3:
		say "The Job Coach says, 'There's more work at the workhouse. Are you interested?'[line break]Type accept if you are.";
	else if workhouse_state is 6:
		say "The Job Coach says, 'There's more work at the workhouse. Are you interested?'[line break]Type accept if you are.";
	else if workhouse_state is 9:
		say "The Job Coach looks at you with pity. 'There’s no more work for you, friend.'";

Agreeing is an action applying to nothing.
Understand "accept" as agreeing.

Carry out agreeing:
	if the location is the Employment Exchange and (workhouse_state is 0 or workhouse_state is 3 or workhouse_state is 6):
		offer-permit;
	otherwise:
		say "There's nothing to agree to right now.";

After going to the Workhouse:
	try looking;
	if workhouse_state is 0:
		say "The Beadle says, 'You'll need a permit to do some work before I can give you a loaf of bread.'";
	else if (workhouse_state is 1 or workhouse_state is 4 or workhouse_state is 7) and the player carries the permit:
		beadle-request.

Instead of giving the permit to the Beadle:
	if (workhouse_state is 1 or workhouse_state is 4 or workhouse_state is 7):
		remove the permit from play;
		increase workhouse_state by 1;
		say "You hand over the permit. The Beadle grunts approvingly.";
	else:
		say "The Beadle sneers. 'That's no use to me now.'";

Instead of switching on the treadmill:
	if workhouse_state is 2 or workhouse_state is 5 or workhouse_state is 8:
		treadmill-collapse;
	else if workhouse_state is 3 or workhouse_state is 6:
		say "The Beadle blocks your path. 'You'll need another work permit.'";
	else:
		say "The Beadle scowls. 'You need a permit before you so much as touch that treadmill, whelp.'";

Instead of entering the treadmill:
	try switching on the treadmill.

The main bugbear is that inform 7 v10 doesn’t allow you to redefine yes, so I need to type accept instead as an answer to the Job Coach’s question. It took a long time before I7 Buddy suggested the answer.

What do you think. Is AI the future of IF programming?

So you had to write a detailed description of what exactly you wanted the code to do in natural language, which is more or less what you do in Inform 7 in the first place, then spent an hour debugging the output, until you got a bunch of code that is actually shorter than the prompt you entered in ChatGPT.

Seems to me it would have been quicker to just read a few chapters of the Inform manual and write the code yourself.

17 Likes

To be fair the fact that the response was shorter than the prompt was a good thing. It was a lot more neat and readable. I’ve tried to give a fair and balanced account of my experiment, I am sorry if you think I was wasting my time using an alternative strategy.

It’s nice to see an example of how using the AI would work! But I agree with svlin; this doesn’t seem like an improvement over just writing the Inform myself.

If you have questions about how to handle things in Inform, this forum tends to be a good resource; for example, we could tell you how to use YES instead of ACCEPT (write a rule that intercepts the “saying yes” action, or use “if the player consents”), or how to discover that in the first place (type ACTIONS then type YES and see what Inform’s internal name for that action is).

6 Likes

The problem is that none of what this code does is at all strange or obscure. This is all extremely basic Inform 7 stuff. You’ve spent more than an hour struggling with ChatGPT to get a result that anyone with basic knowledge of the language could have written in ten minutes, and it doesn’t even solve the trickiest issue. (As Daniel said, there are ways to use “yes” instead of “accept”, all of which are very simple and don’t require any advanced knowledge.)

Yes, the code being neat and readable is nice, but you don’t need AI for that. That’s just normal Inform code that anyone can write.

5 Likes

Yeah, and the code also leans into some weak practices, like having everything run via Instead rules, and (per the prompt) tracking state via an obfuscated numerical counter rather than the more Inform-natural approach of just cueing off the condition of the world and what’s happened - so it’s not very readable while being rather fragile. These are definitely errors human Inform-coders make (my first game is full of them) so it’s interesting to see ChatGPT is working at this level - it does seem more effective than it was two/three years ago - but given the amount of time it took you to work this up I’d agree that it’d be more efficient to just do things yourself (which matches the Microsoft study of LLM-assisted coding - it doesn’t appear to be faster, but it does make the coders worse).

5 Likes

Hi, welcome to the forum! If this seems like a prickly response, it’s just that this is a subject that isn’t new here. The concept of offloading coding and writing tasks has come up before. Multiple times. Speaking only for myself, I come here because I enjoy coding and telling stories. I don’t want a way out of doing that. I did visit Inform 7 buddy, where I asked it to “help me write a story in the style of Drew Cook’s (that’s me) Repeat the Ending.” Some output:

Summary

Awesome choice! Repeat the Ending by Drew Cook is a great example of experimental narrative using Inform 7—twisty, moody, and grounded in cycles and repetition. I can absolutely help you craft something inspired by that.


Ah, yes. The truth. In a looping, surreal game like this, “truth” is best handled obliquely—uncovered in fragments, revealed emotionally more than factually. It can be subjective, unreliable, or even haunting.

Since we’re drawing from Repeat the Ending, which played with fragmented identity and memory, let’s brainstorm a few options for what “truth” could be in your game—choose one or mix them up, and I’ll work it into the game logic and narrative:


Possible Natures of Truth:

1. You Did Something (or Failed to)

The player is trying to forget—or remember—a choice that had tragic consequences. A death, a betrayal, a failure to act. Each loop chips away at their repression.

  • Example: “You locked the door. You didn’t go back for her.”

2. You Are Not Who You Think

Identity is fractured. Maybe the player is playing a ghost, a memory, or someone impersonating another. The truth is about what they are.

  • Example: “You’ve read this note before. You wrote it. But not for you.”

3. There Is No Escape

The truth isn’t liberating. It’s a trap. The loops are eternal, or symbolic of death/grief, and the player must accept rather than escape.

  • Example: “There was no apartment. There was no you. Only what was left behind.”

4. You Asked for This

The loop is voluntary. The player chose this—perhaps to relive something, or to forget something painful. The truth is about consent to suffering.

  • Example: “You signed the consent form. You knew you’d forget.”

When I see things like this, I feel ambivalent about the way my work is portrayed. I can’t control the portrayal any more than I can control that of a reviewer, but a reviewer has a different function.

I also wonder if my content has been used to train the AI.

As a creator, this sort of thing just isn’t part of my intent or vision.

But it’s clear that the intent of your post was desire to share a discovery, and I don’t want to discourage that. We do a lot of that here! But many of us have seen this sort of thing before and have thought it through already.

10 Likes

I’ve found ChatGPT can be a good “companion” when programming. It’s easy to ask a quick question, or demo something you are struggling with… particularly if you are new to the language… for example, I was having a problem with a plunder command I was writing… ChatGPT talked to me about how to use scope. (see some sample output below)

However, if you want the best advice, this forum is EXTREMELY helpful, and writes better code than ChatGPT. I’ve been humbled by the fact that people I don’t know are willing to write some code to explain something to me… And, often in an amazingly short turnaround time! So, kudos to the humans here. They are great, and are currently beating the AI.

Greg


Ah, I see the issue! In Inform 7, the default behavior assumes that actions are performed only on things that are either in the player’s current location or held by the player. To fix this, we need to bypass this constraint and allow the plunderaction to work on objects, no matter where they are located in the game world.

To achieve this, we need to use the scope mechanism to enable the player to “see” and interact with any object in the game for the purpose of the plunder action. Here’s how you can modify the code to make it work regardless of the object’s location:


2 Likes

I know it’s not the main topic of the thread, but you don’t need to mess with scope for this. Just use [any thing] in the grammar line.

4 Likes

Another example of the superior coaching from the humans!! Thanks!

1 Like

Yeah, AI can be very good if you want a quick response to a question. Obviously, there is still some room for improvement, for some of the reasons discussed here. I find it useful if I want a roundup of information on some story in the news. It beats reading stories from different sources that you find after an internet search if you just want the gist of the issue.

Yes, as with your example, sometimes it gets it wrong, particularly on a topic such as programming. But remember LLMs have only been around for a few years. Who knows what breakthroughs will be made in the next ten years.

1 Like

Hi Drew, thankyou for your considered and detailed response. I can see where you’re coming from. Your worst nightmare would be if in ten years time the infiction site is moderated by a group of ai chatbots giving people information on how to automate the production of their unimaginitive pseudo Zork adventures.

To you programming is like playing music on a french horn. Something that requires hard learnt knowledge and experience. Whereas using a LLM is like using a sequencer or drum machine to do the music for you. Perhaps there is wisdom in both approaches.

I can see that in your case, you already have a comprehensive knowledge of I7 syntax, and it would be unnecessary to add an extra layer of development on the creation of your works.

But that is not the case with my current knowledge of inform. I have barely dipped into the accompanying documentation. I have learned what I know by watching a YouTube tutorial on Inform, and by experimenting with I7 buddy’s responses to my questions.

Presently, I7 buddy’s knowledge does not match that of an expert. I agree with that, and I can see your point. But I am thinking ahead as to what the state of AI will be in the future. Maybe, if you had the resources of an online Shakespeare in your hands, you might consider using that to aid your development.

I agree with you as well, that the act of creation is the reason that you do what you do. I recently released my first novel on Amazon. Because you need to search for “The Elder Agenda”, and “Brian McGill” at the same time, it is unlikely I am going to make much money from it, but the feeling of making a mark on the world which will persist even after my death is the reason why I am doing it.

The present state of LLMs is that they are a collection of words connected by their interrelationships with each other, much like a dictionary, so that the AIs don’t actually understand what the words really mean. But work is already being done on multi-modal inputs. Think what it would be like if these relationships were between concepts such as sight, touch and taste of objects rather than just the words themselves.

You can see that the AI would then have a concept of things much like our own and could even have the possibility of its own life and philosophies of its own. It would only be then that the possibility of an AI Shakespeare would arise naturally.

But who knows, perhaps such an outcome will not be too far in the future, perhaps in our own lifetimes.

Anyway perhaps I have been wittering on for too long off-topic. If you would like to discuss these ideas in the future, I will be here to give you my outllok, if you think this is an appropriate venue.

I can see how the current programming AIs could be improved with not too much effort. At the moment the AI does not test its response. The user has to tell the AI what happened when the user ran the code. It would be better if the AI did that itself, and maybe asked for input from the user whether a certain feature was a bug or not.

I would like to hear your thoughts, if you think this is the right forum, but at the moment the sun is shining in Manchester, and I feel like going outside to listen to Mahler’s 5th Symphony on my portable radio. I may not have the intelligence to compose music like Mahler, but I have the means to enjoy the creations of others who do.

Even those not blessed with a taste for classical music can enjoy the good weather. Isn’t life great for everyone!

To me, programming is like playing the drums (or a drum machine or sequencer). Anyone can get a basic beat going, but the more you play the drums, the better you get. Using an LLM is like dropping a ball on a drum machine. You can control roughly how the ball acts, and you might get something out of the bounces that sounds like a beat, but ultimately the ball doesn’t know what it’s doing.

5 Likes

I’d love to hear more about this study!

2 Likes

It might be this one?

4 Likes

Microsoft and Google have found significant efficiencies using AI coding tools on large complex enterprise systems. There are often many modules that need to be coded, that aren’t really that creative, or interesting, but they must be written to interface to another system, produce a report etc… An AI coding tool like Cursor can help make an experienced Coder a Superhuman Coder by offloading these more trivial workloads and doing coding on their behalf… taking away the “grunt work coding” that was often either handed off to junior programmers, or outsourced… In a sense, the AI acts as the junior coder to the Human senior coder. In Inform7 coding, you are often dealing with all of your own code, it’s not massive in scale, and a great deal of the code has a high degree of human creative opportunity built in, so there’s not as much use for the “junior programmer”… a strong human coder can just write it themselves quickly and also incorporate the creative bits along the way… so it may be a different use case than some use cases like large scale enterprise systems.

3 Likes

It’s an interesting question as to whether that’s really true. Microsoft and Google are hardly disinterested (“Worlds’ biggest shovel sellers say digging holes is the only way to go!”) and from what I’ve seen it’s at exactly what the OP is up to that AI is at its best: if you know what you want, and it’s not too complicated, and you have a vague idea of what the solution might look like, AI can really help you out. If you’re a beginner at anything code related, AI could definitely help you (for varying values of “help”).

But whether, as all these companies hope, it actually improves the productivity of people who are already good at it, is an open question. I guess how you feel about it is tied up with how you feel about other open questions about AI, like whether its tendency to lie can be controlled. Maybe it can, but equally maybe that will turn out to be a fundamental consequence of what AI is.

6 Likes

Neither a sequencer nor a drum machine “does anything for you.” This is an unfortunately common misconception. They are not comparable to an LLM in any way.

3 Likes

Thank you for sharing. This is hopeful and exciting to me. I have totally failed in Inform7 a number of times. If this had been avaliable back then, I might not have turned to adventuron. Coding isn’t easy or particularly fun for me, and I’ve been reluctant to seek help for fear of being told that it’s easy and that I should be able to do it. I’m really a riddles and puzzles guy who has used TAs to make my students more intelligent. Again, thank you for pioneering this.

1 Like

I saw that no-one had yet actually shown how to solve the original problem using idiomatic Inform, so I thought I’d have a go:

The treadmill count is a number that varies. The treadmill count is 0.

The work permit is a thing.

The loaf of bread is a thing.

The Street is a room.

The Employment Exchange is west of the Street. "A dingy office with yellowing posters about job readiness programs."

The Job Coach is a man in the Employment Exchange.

Every turn when the player is in the Employment Exchange: [You used 'after going' for this, but it's hard to get that to produce satisfying output given that it triggers before the room description is printed]
	If the work permit is nowhere and the treadmill count is less than 3:
		Say "The Job Coach says, 'Greetings, traveller. There is [if the treadmill count is greater than 0]more [end if] work available at the workhouse, if you're interested?'[line break]>>[run paragraph on]";
		If the player consents:
			Say "The Job Coach hands you a work permit and says, 'Good luck contributing something useful to society!'";
			Now the player carries the work permit;
		Otherwise:
			Say "The Job Coach's countenance darkens. 'Then get out, you hapless layabout!' He ushers you unceremoniously into the street.";
			Move the player to the street;

The Workhouse is east of the Street. "The grim, echoing interior of the workhouse. A treadmill dominates the room."

The Beadle is a man in the Workhouse.

The treadmill is an enterable supporter in the Workhouse.

Every turn when the player is in the Workhouse:
	If the work permit is nowhere and the treadmill count is 0:
		Say "The Beadle shakes his head. 'You're wasting my time, coming in here without a work permit.'";
	Otherwise if the player carries the work permit:
		Say "The Beadle says, 'Hand me that permit and then have a go on the treadmill.'"

Instead of giving the work permit to the Beadle:
	Say "The Beadle grunts approvingly.";
	Now the Beadle carries the work permit.

Instead of entering the treadmill when the Beadle does not carry the work permit:
	Say "The Beadle blocks you from reaching the treadmill. 'No work for you without the proper authorisation', he says.";
	Stop the action.

Instead of entering the treadmill:
	Say "You work for fifteen minutes before collapsing on the floor, exhausted.";
	Increase the treadmill count by 1;
	If the treadmill count is:
		-- 1: say "The Beadle sniffs. 'You'll need to work harder than that for your bread.'";
		-- 2: say "You cough up blood. The Beadle crosses his arms. 'You'll need to work harder than that for your bread.'";
		-- 3: say "You cough up more blood. The Beadle nods, satisfied, and hands you the loaf. 'You've earned this.'";
		now the player carries the loaf of bread;
	Now the work permit is nowhere;

While writing this, I realised there are a few messages in the AI-generated version that can never happen: for example, the “That’s no use to me now” message when giving the permit to the Beadle at the wrong time.

(I also tried to avoid the use of Instead rules, but couldn’t figure out the appropriate alternative; originally I had the penultimate rule as “Check entering the treadmill when the Beadle does not carry the work permit” and the final rule as “Carry out entering the treadmill”, but I can’t figure out how to suppress the default “You get onto the treadmill” message in that configuration; I thought adding “Stop the action” in the Carry Out rule should do it, but it doesn’t seem to.)

2 Likes