I ran into the same problems you did, any variable leads to an exponentially large state. Other than, "scoping" as you put (or branch merging as I put it), the most space-efficient way I found to keep state was to ask the player to remember a passcode. So the player can keep track of the state, but I don't have to (ie. exponential space savings!). Even when entering the password, you can keep the space small (n*2 rather than 2^n) see [0]. Players used to retro PC games will remember entering passwords found in their instruction manual, so it's an added nostalgic appeal.
Let me know when your error dialogs game is done. If you want to collaborate on some games, hit me up, I too love games where they shouldn't be.
0: https://github.com/mmulet/code-relay/blob/main/markdown/how/...
In the end, because it's a book and not a computer game, we could just ask the user: "If you have a key, turn to page 43..." and it just depends on the user being honest (or as honest as any reader of a CYOA book is, with nine fingers stuck between pages).
I assume there were similar books in the past that used the same mechanic -- maybe the Fighting Fantasy books? I forget.
Or if you wanted to make them work a little harder and maybe teach a little math, "17 times the number mod 47".
Of course they can still be dishonest, but it gives them an opportunity to have solved a simple puzzle. They get to the correct page because they "won".
The other thing we did, slightly simpler, was introduce a plethora of choices where only prior knowledge would get you (easily) to the page.
E.g. You can land on page A a number of different ways, but only from one path do you find out the suspect is in a certain city. Then from page A you're asked if you want to go to B, C, D, E or F. Without the prior knowledge there are too many choices.
Overall, awesome stuff :D Ever since I read [0], I knew you could do some funky stuff with ligatures, but I never imagined you could take it this far :D
0: https://blog.janestreet.com/commas-in-big-numbers-everywhere...
You have to keep going past the ending (GameOver) keep typing. You'll revive and beat the boss.
Amazing project BTW, had a lot of fun!
0: https://github.com/mmulet/code-relay/blob/main/markdown/Secr...
This is years beyond the statute of limitations so I can finally talk about it - in my youth I broke into one of LANL's servers for kicks; some Lotus/IBM Domino machine, saw nothing of interest except for a project directory which even the admin didn't have access to... I didn't want to escalate privileges any further because it'd require permanent changes and would probably trip a flag - but then I found a bizarre folder.
Someone coded a series of directories within Domino and made a maze game, maybe a Zork 'lite'. I spent a few minutes exploring and got bored.
Plenty of similar stories about other better known orgs/corps but this isn't the venue for those :)
This week I stumbled upon John Robertson for the first time. He made an choice based Adventure game called The Dark Room, which (in its first iteration) was realized with YouTube Annotations, then performed live, and now he streams it on Twitch. It's an interesting combination of preparation and improvisation