10.1. Gases

| Chapter 10: Physics: Substances, Ropes, Energy and Weight |

| 10.1. Gases

Inform normally assumes that everything is solid. It has no built-in support for gases or liquids, because they have so many different behaviours. For instance, is the important thing about gas that it diffuses, or that we breathe it, or that it mixes with other gases to react, or that it sometimes obscures vision? The answer depends on what we are trying to write, and for this reason Inform leaves it up to us.

Gases are easier to deal with than liquids, because they tend to be everywhere in their location at once (unlike a liquid which might form a pool on the floor) and because they diffuse and mix by themselves (rather than being carried around or brought into contact with each other by the player). On the other hand, unlike liquids, gases are compressible: they can be present at low or high pressures, that is, in low or high concentrations.

The simplest approach is the one in Only You..., where rooms are either filled with smoke or else smoke-free. Smoke gradually fills through the map, obscuring vision: no attempt is made to conserve the total quantity of smoke, as we assume that some fire is churning it out continuously to replace what diffuses away.

Lethal Concentration 1 and 2 simulate a gas diffusing through a three-dimensional maze of rooms, and becoming dangerous above certain concentrations. There is just one possible gas, and it is modelled by giving each room a number which represents the concentration (in parts per million). This enables us to conserve the total amount of gas, or to have it released or captured by sources and sinks of given capacity.

This could be extended by giving each room similar concentration levels for other gases, and providing for the diffusion rule to notice when different gases come into contact; or by giving a concentration (and also, for realism, a volume) to each closed container, applying rules for capturing and releasing gases as containers are opened and closed.

74
| Example Only You... Smoke which spreads through the rooms of the map, but only every other turn. |
WI

394
| Example Lethal Concentration 1 A poisonous gas that spreads from room to room, incapacitating or killing the player when it reaches sufficient levels. |
WI

395
| Example Lethal Concentration 2 Poisonous gas again, only this time it sinks. |
WI

This is a slight variation on the previous gas diffusion example: the main difference is that gas preferentially moves towards lower rooms, and will gradually settle in the bottom floor. We do this by calculating the probability of movement separately for each pair of rooms. "Lethal Concentration" A concentration is a kind of value. 200.9ppm specifies concentration. 200.9 ppm specifies concentration. A room has a concentration called current concentration. A room has a concentration called former concentration. To decide what number is the probability inverse between (space - a room) and (second space - a room): let guess be 20; let way be the best route from space to second space; if way is up, let guess be 50; if way is down, let guess be 10; if the guess is less than 10, decide on 10; decide on guess. If we wanted, we could introduce other concerns into the calculation here: open and closed doors, windows between rooms, rooms that are outdoors vs. those that are indoors, and so on. The possibilities are numerous, so we will stick with the simple principle that our poison gas sinks. Every turn: follow the diffusion rules. The diffusion rules are a rulebook. A diffusion rule (this is the gas movement rule): repeat with space running through rooms: let sum be 0.0 ppm; repeat with way running through directions: let second space be the room way from the space; if second space is a room: let incoming be the former concentration of the second space divided by the probability inverse between second space and space; let outgoing be the former concentration of the space divided by the probability inverse between space and second space; let difference be incoming minus outgoing; increase sum by the difference; now current concentration of the space is the former concentration of the space plus the sum. A diffusion rule (this is the resetting concentration rule): repeat with space running through rooms: now the former concentration of the space is the current concentration of the space. The last diffusion rule (this is the lethal dosage rule): if the current concentration of the location is greater than LC50: say "The concentration in the air overpowers you..."; end the story; otherwise: if the current concentration of the location is greater than TLV-STEL: say "You feel extremely uncomfortable in this environment." Instead of doing something when the current concentration of the location is greater than TLV-STEL: if going, continue the action; say "You can't work in this environment: your eyes and nose sting and it hurts to breathe." Room 1A is west of Room 1B. Room 1B is west of Room 1C. Room 1C is west of Room 1D. Room 1D is west of Room 1E. Room 2A is west of Room 2B and below room 1A. Room 2B is west of Room 2C and below Room 1B. Room 2C is west of Room 2D and below Room 1C. Room 2D is west of Room 2E and below Room 1D. Room 2E is south of Room 1E and below Room 1E. The former concentration of Room 1C is 800.0 ppm. The status grid is a device carried by the player. The status grid is switched on. And just for fun, this time we'll make the grid prettier, too: Every turn: try examining the grid. Instead of examining the status grid: say "[unicode box drawings light down and right][top bar][unicode box drawings light down and left][line break]"; say "[unicode box drawings light vertical]"; say "[state of room 1A][state of room 1B][state of room 1C][state of room 1D][state of room 1E] upstairs[line break]"; say "[unicode box drawings light vertical and right][middle bar][unicode box drawings light vertical and left][line break]"; say "[unicode box drawings light vertical]"; say "[state of room 2A][state of room 2B][state of room 2C][state of room 2D][state of room 2E] downstairs[line break]"; say "[unicode box drawings light up and right][bottom bar][unicode box drawings light up and left][variable letter spacing][line break]" Include Unicode Character Names by Graham Nelson. To say top bar: repeat with N running from 1 to 9: if the remainder after dividing N by 2 is 0, say "[unicode box drawings light down and horizontal]"; otherwise say "[unicode box drawings light horizontal]". To say middle bar: repeat with N running from 1 to 9: if the remainder after dividing N by 2 is 0, say "[unicode box drawings light vertical and horizontal]"; otherwise say "[unicode box drawings light triple dash horizontal]". To say bottom bar: repeat with N running from 1 to 9: if the remainder after dividing N by 2 is 0, say "[unicode box drawings light up and horizontal]"; otherwise say "[unicode box drawings light horizontal]". TLV is a concentration that varies. TLV is 30.0ppm. [Long-term exposure maximum, safe for 8 hours a day.] TLV-STEL is a concentration that varies. TLV-STEL is 50.0ppm. [Short-term exposure maximum, safe for fifteen minutes max.] TLV-C is a concentration that varies. TLV-C is 150.0ppm. [Absolute exposure ceiling.] LC50 is a concentration that varies. LC50 is 300.0ppm. [Concentration at which 50 percent of test subjects die of exposure, usually expressed in terms of time and body weight; in our LC50 these are factored in for the player's weight for one minute.] Include Basic Screen Effects by Emily Short. To say state of (space - a room): if the current concentration of space is less than TLV, say blue letters; if the current concentration of space is TLV, say blue letters; if the current concentration of space is greater than TLV, say green letters; if the current concentration of space is greater than TLV-STEL, say yellow letters; if the current concentration of space is greater than TLV-C, say red letters; say "[unicode square with diagonal crosshatch fill]"; say default letters; say "[unicode box drawings light vertical]". Test me with "z / z / z / z / z / z / z / z".

Previous | Contents | Next