EDIT: Reading my third post, below, will probably save you some time. I discovered some new data that simplifies things.
Hi everyone,
New to IF, new to Inform 7. Some experience with programming languages.
Problem: I want a character to move each turn through any random available door to the adjacent space. However, using “a random door” in my Source causes Inform to eliminate already-chosen doors each turn until there are no doors in current space’s “list of doors.” I wonder if “purely at random” can be used (see “Writing with Inform” §5.7 on random text), or if I should just solve it all differently.
My basis is “Mistress of Animals,” Recipe Book §6.14 and §7.13. However, in my Map, each room is separated by a door. As the example says,
“The implementation would become more complicated if there were doors which might block transit between these locations.”
My Map has 3 rooms (Red, Blue, Yellow), separated by 3 doors (purple, orange, green). The “showmes” are how I debug. Pay attention to the “list of doors” produced each turn.
Source:
[code]“traveling custodian”
The Red Room is a room. The purple door is a door. The purple door is east of the red room and west of the blue room. The green door is a door. The green door is southwest of the blue room and northeast of the yellow room. The orange door is a door. The orange door is northwest of the yellow room and southeast of the red room.
The custodian is in the Red Room.
Every turn:
if the custodian is in a room (called the old space):
showme the location of the old space;
showme the location of the custodian;
showme list of doors in the old space;
let xanadu be a random door in the old space;
showme xanadu;
let the new space be the back side of xanadu;
showme the location of the new space;
if the custodian is visible, say “The Custodian heads to [the new space].”;
move the custodian to the new space;
if the custodian is visible, say “The custodian arrives from [the old space].”;
showme the location of the custodian.
[/code]
Story:
traveling custodian
An Interactive Fiction
Release 1 / Serial number 160905 / Inform 7 build 6L38 (I6/v6.33 lib 6/12N) SD
Red Room
You can see an orange door, a purple door and a custodian here.
z
Time passes.
“location of the old space” = room: Red Room
“location of the custodian” = room: Red Room
“list of doors in the old space” = list of doors: {orange door, purple door}
“xanadu” = object: purple door
“location of the new space” = room: blue room
The Custodian heads to the blue room.
“location of the custodian” = room: blue room
z
Time passes.
“location of the old space” = room: blue room
“location of the custodian” = room: blue room
“list of doors in the old space” = list of doors: {green door}
“xanadu” = object: green door
“location of the new space” = room: yellow room
“location of the custodian” = room: yellow room
z
Time passes.
“location of the old space” = room: yellow room
“location of the custodian” = room: yellow room
“list of doors in the old space” = list of doors: {}
“xanadu” = object: nothing
“location of the new space” = room: nothing
[** Programming error: tried to “move” custodian to nothing **]
“location of the custodian” = room: yellow room
Can anyone see a way to either implement “purely at random” to stop Inform from eliminating options each turn, OR just solve the whole thing differently?
Thank you!
Brooke