Handling large rooms

Hi all,

Still chugging along. But now I have a scene in mind which takes place in a “large room” where the player has to move around to reach different areas within that room. I read in the docs there are basically two ways to go about it (I can think of a third way but not sure if that would work for me):

[1] create “rooms within the room”: I could create containers like “the south east corner” and then the player would be shown as (in the south east corner) etc. I would need to handle navigation in a custom way however, since moving e.g. east would need to move the player from one container to another container directly east of the first one. (unless there is a better way of handling this).

[2] use actual rooms and use some method of “distant objects” because to the player other parts of the large room would still be visible (although they cannot directly interact with these). Navigation can then be handled in a standard way, but looking would then need some special treatment.

What would you recommend and why?

2 Likes

#2 with backdrops and Far away mostly so you can use backdrops and Far away; the relevant customization of looking should be pretty easy.

(The technique at the heart of Far away is easy to imitate if you don’t want to include the extension.)

5 Likes

Just chiming in with the super-useful contribution of saying that as always, Zed’s advice here seems right on to me. In addition to the container approach requiring new movement code, seeing from one container to another is also going to take some work, so the actual-rooms method seems strictly superior.

2 Likes

The above answer is great for simpler situations with a single large open space. However, I find the methods it describes to be insufficient when designing more complicated areas, with sub-zones, one-way connections, and barriers. The techniques suggested below are fairly complex, but they handle a detailed situation reliably.

In A Matter of Heist Urgency, one scene takes place in a large 3-dimensional space with different positions located in it. Not all positions have line-of-sight to each other, not all positions are adjacent (i.e. one move action away), and most positions have only two or three exits in different directions. The positions are abstract ideas - not linked with coordinates or map positions, but simply descriptions of areas such as “behind the chair” or “at the entrance.” This setup is easily adapted to other situations.

Implementation notes

Under the hood, the entire scene takes place in a single room, mainly so everything was by default visible and touchable. Positions are a kind of thing, for internal reasons - I defined them with a table, so they could have a name, description, etc. - and everything has a position property, which only becomes relevant in this scene. As a kind, the positions can be affected by Understand statements, so the “south east corner” is the same as the “southeast corner”.

Blocked line of sight is a relation between positions; a “deciding the scope” rule applying during the scene constructs the entire scope of the player from scratch, including any objects in the room whose positions have line of sight to the player’s, and any omnipresent objects such as backdrops. (This is the least elegant part of the system, but with appropriate abstractions, it’s not too much overhead.) Similarly, an action-processing rule stops actions that require a touchable noun (and second noun) if the noun (or second noun) is not in the current position.

Moving between positions is handled with a special “transiting” action that is used instead of going during the scene. Sadly, since relations in I7 are binary only, this was handled by a Table of Transits, each record possessing a start, end, and direction field. Transiting would check through this table, and if a record matching start and direction was found, you would move to end. Otherwise, it would print out a standard “You can’t go that way”-type message. For extra polish, I added a going to action, that would let you >GO TO SOUTHEAST CORNER. This used the “next step” phrase combined with an “adjacency” relation.

Inventory management is an additional question that becomes relevant in this situation. Simple dropping and taking can be handled by ensuring that dropped objects enter the player’s position, and objects must be in the player’s position to be taken. Another difficulty is describing the position of objects and actors when looking or examining. “You can also see” is inadequate, but the “writing a paragraph” activities are helpful here. There is little to say here, since the desired behavior is highly game-specific. Yet another problem arises when entering or leaving the large area. This can be handled with special cases, however.

I’ve included a small demo of the system I described above, illustrating some of the many wrinkles in the implementation of any complex behavior. I don’t plan to release this as an extension, since the needs of any one game are unique, and the system will require extensive tweaking to work with what you have in mind.

Code
"Basic Positions Demo"

Part - Positions

A room can be large or small. A room is usually small.

A position is a kind of thing. The positions are defined by the Table of Position Definitions.

Chapter - Position Property

A thing has a position.

Chapter - Looking

Carry out looking in a large room (this is the large room looking rule):
	say "[description of the location] [description of the position of the player][paragraph break]";

The room description body text rule does nothing when the player is in a large room.

The large room looking rule is listed after the room description heading rule in the carry out looking rulebook.
	
Chapter - Describing positions of objects

After examining a thing when the player is in a large room and the noun is remote:
	say "It is currently [prepositional description of the position of the noun]."
	
Chapter - Replacing the inadequate you-can-also-see

The you-can-also-see rule does nothing when the player is in a large room.

Rule for writing a paragraph about a thing (called X) when the player is in a large room:
	if the player has line-of-sight to X:
		say "[The X] is [prepositional description of the position of X].";
	otherwise:
		now X is mentioned.

Part - Moving

Chapter - Transiting

Transiting is an action applying to one object.

Instead of going a direction in a large room, try transiting the noun.

The transiting action has a position called startpoint.
The transiting action has a position called endpoint.
The transiting action has a truth state called success.

Setting action variables for an actor transiting:
	now success is false;
	now startpoint is the position of the actor;
	repeat through the Table of Transits:
		if start entry is the position of the actor and direction entry is the noun:
			now endpoint is end entry;
			now success is true.
			
Check an actor transiting:
	if success is false:
		if the actor is the player, say "You can't go that way from this position.";
		stop the action.
			
Carry out an actor transiting:
	now the position of the actor is endpoint.
	
Report an actor transiting:
	say "You head [noun] from [abbreviated name of startpoint] to [abbreviated name of endpoint]."
	
Chapter - Go to <position>
	
Closeness relates various positions to various positions. The verb to border on means the closeness relation.

When play begins:
	repeat with A running through positions:
		repeat with B running through positions:
			repeat through the Table of Transits:
				if start entry is A and end entry is B:
					now A borders on B.
	
Rapid moving is an action applying to one visible thing. Understand "go to [any position]" [ignores scope] as rapid moving.

Carry out rapid moving:
	let NS be the next step via the closeness relation from the position of the player to the noun;
	if NS is nothing:
		say "There doesn't seem to be a way to get from [abbreviated name of the position of the player] to [abbreviated name of the noun].";
	otherwise:
		repeat through the Table of Transits:
			if start entry is the position of the actor and end entry is NS:
				now the position of the actor is end entry;
				say "You start by moving [direction entry] to [abbreviated name of NS]."

Part - Line of Sight and Scope

Chapter - Blocked Line of Sight

Blocking relates various positions to each other. The verb to block implies the blocking relation.

To decide whether (P - a thing) has line-of-sight to (Q - a thing):
	if the position of P does not block the position of Q, decide yes;
	decide no.

Chapter - Scope Rule

Rule for deciding the scope of the player when the player is in a large room:
	repeat with O running through objects:
		if O is a direction, place O in scope;
		if O is a position and rapid moving, place O in scope;
	repeat with X running through things in the location of the player:
		if X is a backdrop, place X in scope;
		if the X has line-of-sight to the player, place X in scope;
		if the player encloses X, place X in scope. [backup]

Part - Touchability

Instead of an actor doing something when action requires a touchable noun and the actor is in a large room:
	if the actor does not enclose the noun and the position of the actor is not the position of the noun:
		if the actor is the player, say "You can't reach [the noun], [prepositional description of the position of the noun], from where you are [prepositional description of the position of the player].";
		stop the action;
	otherwise:
		continue the action.
		
Instead of an actor doing something when action requires a touchable second noun and the actor is in a large room:
	if the actor does not enclose the second noun and the position of the actor is not the position of the second noun:
		if the actor is the player, say "You can't reach [the second noun], [prepositional description of the position of the second noun], from where you are [prepositional description of the position of the player].";
		stop the action;
	otherwise:
		continue the action.
		
Definition: a thing is remote:
	if it is enclosed by the player, decide no;
	if the position of it is not the position of the player, decide yes;
	decide no.

Part - Inventory

Carry out an actor dropping something in a large room:
	now the position of the noun is the position of the actor;
	continue the action.

Part - The Scenario

Huge Room is a large room. "You are in a truly huge room."

[Room exits:]

South of Huge Room is SmallRoom. [name conflict with large/small property; hopefully not a problem in a real game] SmallRoom has printed name "Small Room". The description of SmallRoom is "Oppressively small."

[Here is the hackiest part of the scenario:]

Instead of going south in Huge Room when the position of the player is entrance:
	say "You leave the Huge Room.";
	now the player is in SmallRoom.

Instead of going north in SmallRoom:
	say "You walk into the entryway of the Huge Room.";
	now the player is in Huge Room;
	now the position of the player is entrance.
	
[You could create another system with a Table of Entrances and a Table of Exits, then adjust the transiting action to check through these. But in a setup with only one large room with a few exits, it doesn't really seem worth it.]

South of SmallRoom is Diminutive Room. The description of Diminutive Room is "Incredibly diminutive."

A broom is in Huge Room. It has position alcove.

A red ball is in Huge Room. It has position center.

A blue ball is in Diminutive Room.

A clock is in Huge Room. It is fixed in place. It has position balcony. It has description "It says [time of day]." [just for fun]

Chapter - Table of Positions

Table of Position Definitions
position	printed name	abbreviated name	prepositional description	description
entrance	"in the entrance"	"the entrance"		"in the entryway"	"You are in the southernmost part of the room, in the entrance. North lies the center of the room, overlooked by a balcony."
center	"in the center of the room"	"the center of the room"	"in the center of the room"	"You are standing in the expansive center of the room, under a large balcony. East lies an alcove which bends away to the north, while the entrance is south."				
alcove	"in the eastern alcove"	"the alcove"	"in the alcove"	"You are in a small alcove. A spiral staircase leads up, and south lies the center of the room."
balcony	"on the balcony"	"the balcony"	"on the balcony"	"You are on a high balcony overlooking the Huge Room. A narrow dark passage leads down to the alcove, which is unfortunately out of sight."

Balcony blocks alcove.

Understand "entryway" as the entrance. Understand "eastern" as the alcove. Understand "high" as the balcony.

Chapter - Table of Transits

Table of Transits
start	end	direction
entrance	center	north
center	entrance	south
center	alcove	east
alcove	center	south
alcove	balcony	up
balcony	alcove	down

Chapter - Miscellaneous Rules

[The situation is simple enough that it can be adapted and changed with special cases:]

Instead of jumping in the Huge Room when the position of the player is the balcony:
	say "You jump with panache down to the center of the room, rolling to catch your fall. Too bad nobody was there to see it.";
	now the position of the player is center.

Part - Test Me

Test moving with "n / s / go to alcove / e / go to balcony / d / s / e / u / jump / s".
Test visibility with "x red / n / e / u / x broom / d / take broom / u / x broom / drop broom / x broom / d / x broom / s / x broom / s".
Test physical with "take red / n / take red / e / drop red / s / take red / e / take red / s / s".
Test integration with "s / s / take blue / n / n / n / take red / s / s / drop red / drop blue".

Test me with "test moving / test visibility / test physical / test integration".

EDIT: Out of curiosity, what was the third way you considered?

3 Likes

This is a pretty cool system. Thanks for sharing it.

-Wade

2 Likes

Hi @FLACRabbit, the third way I considered was to create a single room and use a numeric position to track where the player is within the room. All things also have a position, and things with matching position to the player would be touchable by the player. The player can move around by updating the position with a fixed delta depending on the direction (and invalid directions for the position would result in an invalid position) and trying to look to simulate the movement result. Not as flexible as your approach though!

1 Like

I’ve done this to simulate an infinite room. No other way to do that, I think.

1 Like

Shade had a subroom effect that would subtly move the player into a specific subroom if they examined or interacted with something in that part of the room while they were initially located in a different part of the larger room. This movement is not reported, so the effect ends up being a natural and casual shift of focus from one part of a room to another. You’d have to ask @zarf if you want to know how he did it.

1 Like

It was I6 code anyway. The equivalent of an “if object is touchable” check on nearly every action in the game, and then a big hack in the touchability function to move the player if appropriate.

The source code is downloadable here.

2 Likes