Better Undo

Is there a way to alter the UNDO command?

For example, if you’ve eaten a poison that takes 5 turns to kill you, is there a way to set up UNDO so that it takes you back to before you’ve eaten the poison, so that undo isn’t worthless? (Or so you don’t need to type undo 5 times?).

Maybe some way involving scenes?

Jesse’s extension “Hypothetical Questions” has some code you could adapt to the purpose. It would be quite a job to do, I think.

If you’re allowing multiple undos, I don’t think it’s so onerous to require the player to type undo 5 times in that specific case. Of course, you could also give a bigger clue once the apple is bitten, or just make death instantaneous rather than letting the inevitable play out for 5 turns

-Kevin

You could hack the library to not save undo states on turns after the game has become unwinnable. (It would require some low-level surgery.)

It would be hard to communicate the situation to the player clearly, though. You’d want to say something like “[undoing five turns, to before you drank the poison]”.

Well, not all that many terps allow that many layers of undo – specifically I’m pretty sure Parchment doesn’t. [UPDATE: Never mind, it does now – see Dannii’s post below.] (This caught out one of the authors in the JayIsGames comp.) Anyway, it’d be pretty annoying to have to type undo five times.

Speaking of the JayIsGames comp, there was one game, “I Expect You To Die,” which starts with this text:

Which looks intriguing – but the game was not unbuggy, so I doubt that it did anything too complicated. I suspect that what was going on was that the game was pretty much a series of gated puzzles, so it was possible to just reset you to the beginning of the puzzle on which you died. “Earl Grey” did something similar, I think, and “Everybody Dies” at one point automatically takes you back to the beginning of a scene if you die. But it looks like you want something more flexible.

The issue is not the game being unwinnable as much, moreso that you make choices that have consequences beyond 1 turn, and you might want to go back and take a different branch. More like CYOA I guess.

Parchment now supports an unlimited number of undos. I can’t remember when we added that, but it was probably after the JIG comp.

This was a natural fit for my Undo Output Control extension, so I went ahead and added the capability to stop saving the undo state (Zarf’s suggestion, basically). You can download a test version of the extension here:

dl.dropbox.com/u/947038/Undo%20O … ontrol.i7x

The second code example (also copied below) replicates the OP’s poison-drinking scenario.

Please play around with this and let me know how it goes. If it looks good, I’ll submit the extension.

–Erik

[code]Include Undo Output Control by Erik Temple.

Suicide Room is a room. There is a bottle of poison in Suicide.

Instead of drinking the bottle of poison:
now the printed name of the bottle is “empty bottle”;
say “You drink down the poison in a single draught! That probably wasn’t very smart.”;
disable saving of undo state.

Every turn when the printed name of the bottle is “empty bottle”:
say “[one of]Your cheeks burn[or]Your teeth hurt[or]Your belly twists[or]Your vision fades[the end][stopping].”

To say the end:
end the game in death.

Before undoing an action when save undo state is false:
say “[bracket]Attempting to undo to the moment just before you drank the poison.[close bracket][paragraph break]”;
rule succeeds.

Report undoing an action:
say “[bold type]”;
say “[Location]” in upper case;
say “[roman type]”;
say “[line break]”;
say “[bracket]Undone.[close bracket][line break]”;
rule succeeds.[/code]

I guess I’ll have to give away some spoilers or something- but basically i have a one room game with about 30 different endings.

Some endings involve being drunk or on drugs when you do certain actions.
Others involve you being tied up.
others involve you destroying the room.

I was hoping people could undo to certain key actions, so they could explore a different ending. (Okay, I drowned myself on drugs, now what if i drown myself without drugs?)

I guess that’s what SAVE/RESTORE is for.

Did you see that I posted an extension and an example that do exactly what your original post asked for? As long as the scenarios you’re describing don’t need internal undo states (that is, when the player types UNDO, we jump back to before the drinking/drugs/poison/whatever), you should be able to use the solution I posted for any/all of them. Or at least, you should be able to test that solution–I certainly haven’t hammered at it exhaustively.

–Erik

The problem is that there isn’t necessarily 1 thing you want to undo to the expense of others.

You may want to undo the pills, but you may just want to undo the last turn.
You may want to undo the drinking, which happened before the pills.

Etc.

Seems like you’d have to have multiple undo states, which, upon reflection, is more the venue of save/restore.

Let’s see: if the game is essentially a set of toggles, and inventory and such is unimportant, I think it would be theoretically possible to create a crude internal save state and regress the character that way.

Something like this, perhaps?

[code]Regretting is an action applying to nothing. Understand “regret” as regretting.

An occurence is a kind of value. The occurences are done and undone.

To decide what occurence is the reverse of (reality - an occurence):
if reality is undone:
decide on done;
otherwise:
decide on undone;

Marijuana is an occurence that varies. Marijuana is done.

Carry out regretting:
say “Do you regret [if marijuana is done]taking drugs[otherwise]not trying marijuana[end if]?”;
if player consents:
now marijuana is the reverse of marijuana;
if marijuana is undone:
say “You close your eyes, and it’s like it never happened.”;
otherwise:
say “You close your eyes, and you know you did experiment, back in the day.”;
otherwise:
say “Yes, it’s probably best not to regret the past.”

The Hall of Memories is a room.

The description of the player is “[if marijuana is done]You smoked in your youth[otherwise]You remember envying your comrades for their freedom, but you never did anything illegal[end if].”[/code]

You’d have to figure out a bunch of fiddly bits, and you’d need to make sure that the chain of requirements never broke - if you had to have done drugs to drown, you’d need to make sure regretting drugs undid the drowning.

And I don’t think this would work with anything bigger than what you’re describing - just a bunch of different states. But it might be worth playing with.

I see what you’re doing there. That could work.

Perhaps a way where the game can undo, check to see if the given state is still true, and if so, undo again for you?

To regret pills:
try undoing the action;
if the pill is eaten, regret pills.

To regret drinking:
try undoing the action;
if the player is drunk, regret drinking.

And so forth?

That could possibly work, but it would probably be a bit dangerous/fragile.

Back to the more traditional save/restore approach to this—could you prompt the player to save when she does something dumb?

(It might also be good to allow a third option in that situation–so the player could choose between saving, not saving, or canceling the action.)

There have also been discussions either here or at rec.arts.int-fiction about having defined save points, I think.

–Erik

Precisely, although the beauty of this is that you might never need to actually utilize undo - if you’re only dealing with the internal toggles, it doesn’t matter to the player whether things are “really” undone or just virtually undone. The advantage would be that undo remains as-is, for one-turn errors. It also would have the advantage that undo wouldn’t anticipate the player too much.

I’m picturing the regret function repeating through a table in order of latest state-change. This would be more challenging as the game gets more linear, but I don’t see why a counter couldn’t be implemented.

I think this could be cataclysmically buggy to set up, but the advantage would be the ease with which you could add new states to existing tables, making expansion
semi-trivial.

The nice thing about this, opposed to save-restore, is that the player wouldn’t have to do the routing himself. If there’s ten branches the first play-through, that’s ten saves, each of which have to be clearly marked. That’s a player’s nightmare. If the game’s short enough, I’d restart instead. If it’s long, I think this feature might well make the difference between one-two plays and many more.