Creating a guess-the-next-powered-object puzzle

This is my first post on intfiction.org.

I can’t seem to figure out how to make this puzzle in Inform 7:

-There are 7 walls, one in each compass direction except southeast where the entrance/exit is.

-There is a “power” in one of the walls.

-Every turn the power switches to another wall, along with a message indicating which wall it went to. It always goes through the same order.

-The player needs to TOUCH THE (DIRECTION) WALL at the right time, using their previous observation to guess which wall the power is in.

What code do you have, and where do you get stuck?

[code]“Crystal Puzzle Attempt” by Anonymous

A wall is a kind of thing. A wall is scenery. The description of a wall is “[if powered]It looks like it is glowing.[otherwise]Looks like a regular wall to me.”

Definition: a wall is powered if it incorporates the power.

The Crystal Room is a room. “This octagonal room seems to have a wall in every compass direction except the southeast where you came from.” Placeholder is southeast of the Crystal Room.

The north wall is a wall in the Crystal Room.

The northeast wall is a wall in the Crystal Room.

The east wall is a wall in the Crystal Room.

The south wall is a wall in the Crystal Room.

The southwest wall is a wall in the Crystal Room.

The west wall is a wall in the Crystal Room.

The northwest wall is a wall in the Crystal Room.

The power is part of the north wall.

Instead of touching a wall (called checkedwall):
if checkedwall is powered:
say “You feel finished here…”;
end the game saying “Test Complete.”;
otherwise:
say “You feel nothing other than a bare wall.”. [/code]

I suspect there is a far better way to make walls, but, beside that point, I haven’t had any luck making a rule for moving the power to another wall each turn.

There would also be some code preventing saving and undoing in this room, but I am aware on how to make those.

Try this.

[code]“Crystal Puzzle Attempt” by Anonymous

Include Conditional Undo by Jesse Mcgrew.

Rule for deciding whether to allow undo:
if the location of the player is the crystal room begin;
say “Oh no you don’t!”;
deny undo;
end if.

A wall is a kind of thing. A wall is scenery. The description of a wall is “[if powered]It looks like it is glowing[otherwise]Looks like a regular wall to me[end if].”.

Check touching a wall (called the checked wall):
if the checked wall is powered begin;
say “You feel finished here…”;
end the game saying “Test Complete.”;
otherwise;
say “You feel nothing other than a bare wall.”;
end if.

Definition: a wall is powered if it incorporates the power.

Every turn:
now the power is part of a random wall that does not incorporate the power;
say “[The random powered wall] is now powered.”. [Testing line, can be removed.]

Check saving the game when the location of the player is the crystal room:
say “Oh no you don’t!” instead.

The Crystal Room is A Room. The description of the crystal room is “This octagonal room seems to have a wall in every compass direction except the southeast where you came from.”. The Placeholder is southeast of The Crystal Room.

The north wall is a wall in the Crystal Room. The northeast wall is a wall in the Crystal Room. The east wall is a wall in the Crystal Room. The south wall is a wall in the Crystal Room. The southwest wall is a wall in the Crystal Room. The west wall is a wall in the Crystal Room. The northwest wall is a wall in the Crystal Room.

The power is part of the north wall.[/code]

This will move the power to a random wall on each turn. This will also prevent saving and undoing in the crystal room, although you will need the “Conditional Undo by Jesse Mcgrew” extension for the undo prevention to work. You can find it here.

Hope this helps.

That’s not quite what I’m going for, but thanks a lot for the help with the undo. I thought I could do it without an extension like saving…

The problem with that code is that I need the room to have a specific order it goes through rather than random. I also need the movement to occur before the command does: so you have to stay in the room for a bit, notice the pattern, and predict the next part of the pattern.

Oh yes, I missed that bit. In that case, try this.

[code]“Crystal Puzzle Attempt” by Anonymous

Include Conditional Undo by Jesse Mcgrew.

Rule for deciding whether to allow undo:
if the location of the player is the crystal room begin;
say “Oh no you don’t!”;
deny undo;
end if.

A wall is a kind of thing. A wall is scenery. The description of a wall is “[if powered]It looks like it is glowing[otherwise]Looks like a regular wall to me[end if].”.

Check touching a wall (called the checked wall):
if the checked wall is powered begin;
say “You feel finished here…”;
end the game saying “Test Complete.”;
otherwise;
say “You feel nothing other than a bare wall.”;
end if.

Definition: a wall is powered if it incorporates the power.

A first before rule:
if the power is part of the north wall begin;
now the power is part of the northeast wall;
otherwise if the power is part of the northeast wall;
now the power is part of the northwest wall;
otherwise if the power is part of the northwest wall;
now the power is part of the south wall;
otherwise if the power is part of the south wall;
now the power is part of the southwest wall;
otherwise if the power is part of the southwest wall;
now the power is part of the east wall;
otherwise if the power is part of the east wall;
now the power is part of the west wall;
otherwise if the power is part of the west wall;
now the power is part of the north wall;
end if;
say “[The random powered wall] is now powered.”.

Check saving the game when the location of the player is the crystal room:
say “Oh no you don’t!” instead.

The Crystal Room is A Room. The description of the crystal room is “This octagonal room seems to have a wall in every compass direction except the southeast where you came from.”. The Placeholder is southeast of The Crystal Room.

The north wall is a wall in the Crystal Room. The northeast wall is a wall in the Crystal Room. The east wall is a wall in the Crystal Room. The south wall is a wall in the Crystal Room. The southwest wall is a wall in the Crystal Room. The west wall is a wall in the Crystal Room. The northwest wall is a wall in the Crystal Room.

The power is part of the north wall.[/code]

Here, the movement occurs as early as is reasonably possible and is predictable. You can also mix and match the order of the walls to suit your purpose.

Hope this helps.

That worked perfectly! Thanks.

Just out of curiosity, though, what in that code caused it to not loop through all of them each turn?

EDIT: Nevermind, I worked it out from the documentation. The otherwise if only applies when the previous ifs and otherwise ifs don’t. Good to know.