Modeling a crowd

I’m trying to create in Inform a system I recall from an old MUD I used to play on, but with a few other ideas I came up with. I want to create crowds. Not every room has a crowd, but I’d rather add them automatically to certain kinds of rooms without having to individually create them. Crowds can be either small or large. Unfortunately, I can’t quite get Inform to do what I want.

Crowd size is a kind of value. Crowd size is none, small or large. Crowd size is usually none.

A crowd is a kind of thing. “A [crowd size] crowd mills about.”

A crowd has a crowd size.

A crowd is in every room.

Of course, this prints “A none crowd mills about.” in rooms where I don’t intend for there to be a crowd, and presumably lets you interact with the crowd (“examine crowd”) for instance. If there is no crowd, you shouldn’t be able to interact with it.

What I initially tried was something like (pseudocode, I’m a non-Inform coder trying to familiarize myself with its natural language syntax):

A room is either crowded or uncrowded. A room is usually uncrowded.


A crowd is in every crowded room.

But this threw an error about that not being possible because the property could change. If I could mark the crowded/uncrowded property as const that’d be fine, since that property will never change, and presumably that would fix the error. Not sure if this is possible, though.

Maybe this is entirely the wrong way to go about modeling this? My ultimate goal is to model various aspects of crowds (calm/nervous/unruly) and various demographic makeups (lawful/neutral/chaotic), let the crowd create interactable characters based on these properties, and maybe trigger scenes based on whether several NPC kinds are in the same location. I’d also like for the player to, say, “find guard in crowd” to create a guardsman with whom they might have certain types of interactions. It makes sense to me that the crowd should be a kind of thing to facilitate this, but maybe I’m going about it the wrong way?


If you define a kind of room:

A crowded room is a kind of room.

then “A crowd is in every crowded room” works.

Perfect! Thanks.

You can also just implement one crowd and make it a “backdrop”, which can appear in multiple rooms.

I thought about that too. I’d like for crowds to behave specifically based on what happens in their locations. So let’s say a player picks a fight with someone. A calm, lawful crowd would likely turn panicked. A lawless, unruly crowd would probably circle up to watch. If a player did something not obviously connected with them, like caused a distraction, the crowd in a specific area might panic, while the crowd in the next room might only be nervous. I’m not sure how far I can take this type of simulation in Inform, but I very much want each room’s crowd to be distinct. As such, I’m not sure if the backdrop approach would work.

OK, here’s my next challenge. I’m trying to modify the crowd’s description based on its characteristics. Here’s what I have:

A crowded room is a kind of room.

A crowd is a kind of thing. “A [crowd size] crowd [if the temperament of the crowd is calm]moves about in an orderly manner[else if the temperament of the crowd is nervous]mills about with nervous energy[else if the temperament of the crowd is unruly]rushes about in a state of panic[end if].” It is fixed in place.

Crowd size is a kind of value. The crowd sizes are small or large. Crowd size is usually large.

A crowd has a crowd size.

Temperament is a kind of value. Temperament is calm, nervous or unruly. Temperament is usually calm.

A crowd has a temperament.

A crowd is in every crowded room.

Unfortunately, I can’t get the conditional right. [if calm], [if the temperament is calm], nothing works. How am I supposed to check against three possible values?

Sorry for all the silly questions. I code Javascript, Ruby, Python, Haskell, Rust, Scala and various other languages. Wrapping my head around Inform’s syntax is probably the most challenge I’ve faced from a language in a while. :slight_smile:

You can refer to “the item described” in a description or appearance or such, and it will act something like “this” or “self” in most other languages (i.e. it will refer to the specific instance of the class in question).

So in this case you could say “[If the temperament of the item described is calm]”

Or if you don’t need to use temperament as anything other than an adjective for crowds, it might be a little more natural to declare “A crowd can be calm, nervous, or unruly (this is its temperament property).” That would allow you to write “[if calm]” or “[if the item described is calm]” while still also being able to write “A [temperament of the item described] crowd mills about” or something like that.

One tip is that if a crowd is a kind of thing you almost never want to write “the crowd”–Inform won’t know which. Also you don’t want “Temperament is usually calm,” unless I’m mistaken–temperament is a kind of value the way you have it, so it’s like writing “A number is usually 0.” You could write “The temperament of a crowd is usually calm” if you’ve defined it as a kind of value or “A crowd is usually calm” if you’ve defined it as a property.

Here’s the extension I wrote to model the horde of children in “A Killer Headache.” It’s out of date with Inform now, but it might give you some ideas: … Crowds.i7x