# Lethal Concentration 1

A technical note: it would be possible to write "repeat with space running through rooms… repeat with second space running through rooms adjacent to the space" instead, but in practice this loops through all the rooms * all the rooms again * all the directions (to determine adjacency). Phrasing the loop this way omits the second multiplier. For a map of 25 rooms, this means that the loop runs 25 times faster than it would otherwise, and of course for a larger map the effect would be even more dramatic.

And, for testing purposes, a square grid of rooms:

For variety of testing, here is another room set-up, this time with some corridors and walls within; uncommenting it, and commenting out the connected grid, will let us explore what would happen in alternative cases, to prove to ourselves that the model works consistently.

For the sake at least of seeing what's going on in the example, let's also provide the player with the means to view the gas diffusion graphically:

The values set for these would depend on the type of poisonous gas in question; we'd want to adjust appropriately.

Now, in theory we might also want to account for sources and sinks, items that either inject poisonous gas into the environment or remove it again. For simplicity, we will assume that these contributions can also be calculated in ppm and that the total number of inert and poisonous gas molecules in a room never changes (so if poison gas molecules are added, an equal number of inert molecules are removed). If room pressure were able to change, our model would have to be improved, so let us assume for now that that never happens. We want this sink/source business to calculate before any other portion of the diffusion rulebook, so set it as a first diffusion rule.

## Test me with "z / z / z / z / z / z / z / z".

>(Testing.)

>[1] z

Time passes.

----------------------------------------------

| 0.0ppm| 2.5ppm| 0.0ppm| 0.0ppm| 0.0ppm|

----------------------------------------------

| 2.5ppm| 40.0ppm| 42.5ppm| 0.0ppm| 0.0ppm|

----------------------------------------------

| 0.0ppm| 42.5ppm|640.0ppm| 40.0ppm| 0.0ppm|

----------------------------------------------

| 1.5ppm| 0.0ppm| 40.0ppm| 0.0ppm| 0.0ppm|

----------------------------------------------

| 27.0ppm| 1.5ppm| 0.0ppm| 0.0ppm| 0.0ppm|

----------------------------------------------

>[2] z

Time passes.

----------------------------------------------

| 0.2ppm| 6.6ppm| 2.2ppm| 0.0ppm| 0.0ppm|

----------------------------------------------

| 6.6ppm| 76.5ppm| 70.5ppm| 4.1ppm| 0.0ppm|

----------------------------------------------

| 2.3ppm| 70.5ppm|520.3ppm| 64.0ppm| 2.0ppm|

----------------------------------------------

| 4.1ppm| 4.2ppm| 64.0ppm| 4.0ppm| 0.0ppm|

----------------------------------------------

| 51.5ppm| 4.1ppm| 2.0ppm| 0.0ppm| 0.0ppm|

----------------------------------------------

>[3] z

Time passes.

----------------------------------------------

| 0.8ppm| 12.0ppm| 5.7ppm| 0.3ppm| 0.0ppm|

----------------------------------------------

| 12.0ppm|109.0ppm| 89.0ppm| 10.0ppm| 0.3ppm|

----------------------------------------------

| 6.0ppm| 89.0ppm|429.7ppm| 77.7ppm| 4.9ppm|

----------------------------------------------

| 7.8ppm| 10.4ppm| 77.7ppm| 9.6ppm| 0.3ppm|

----------------------------------------------

| 73.8ppm| 7.8ppm| 5.1ppm| 0.3ppm| 0.0ppm|

----------------------------------------------

>[4] z

Time passes.

----------------------------------------------

| 1.9ppm| 18.4ppm| 9.9ppm| 1.0ppm| 0.0ppm|

----------------------------------------------

| 18.4ppm|137.3ppm|101.4ppm| 16.3ppm| 1.0ppm|

----------------------------------------------

| 10.5ppm|101.4ppm|360.5ppm| 84.8ppm| 8.0ppm|

----------------------------------------------

| 12.6ppm| 17.4ppm| 84.9ppm| 15.4ppm| 0.9ppm|

----------------------------------------------

| 94.2ppm| 12.5ppm| 8.6ppm| 0.9ppm| 0.0ppm|

----------------------------------------------

>[5] z

Time passes.

----------------------------------------------

| 3.5ppm| 25.5ppm| 14.4ppm| 2.1ppm| 0.1ppm|

----------------------------------------------

| 25.6ppm|161.9ppm|109.8ppm| 22.4ppm| 2.0ppm|

----------------------------------------------

| 15.5ppm|109.9ppm|307.1ppm| 87.8ppm| 11.1ppm|

----------------------------------------------

| 18.3ppm| 24.4ppm| 88.0ppm| 20.8ppm| 1.9ppm|

----------------------------------------------

|113.1ppm| 18.1ppm| 12.2ppm| 1.9ppm| 0.0ppm|

----------------------------------------------

>[6] z

Time passes.

----------------------------------------------

| 5.7ppm| 33.1ppm| 19.1ppm| 3.6ppm| 0.2ppm|

----------------------------------------------

| 33.3ppm|183.1ppm|115.6ppm| 28.0ppm| 3.3ppm|

----------------------------------------------

| 20.8ppm|115.8ppm|265.5ppm| 88.3ppm| 14.0ppm|

----------------------------------------------

| 24.7ppm| 31.2ppm| 88.6ppm| 25.6ppm| 3.2ppm|

----------------------------------------------

|130.7ppm| 24.3ppm| 15.7ppm| 3.2ppm| 0.1ppm|

----------------------------------------------

>[7] z

Time passes.

----------------------------------------------

| 8.4ppm| 41.0ppm| 23.8ppm| 5.4ppm| 0.5ppm|

----------------------------------------------

| 41.2ppm|201.4ppm|119.7ppm| 32.9ppm| 4.9ppm|

----------------------------------------------

| 26.3ppm|120.1ppm|232.9ppm| 87.3ppm| 16.6ppm|

----------------------------------------------

| 31.6ppm| 37.6ppm| 87.8ppm| 29.6ppm| 4.7ppm|

----------------------------------------------

|147.1ppm| 31.0ppm| 19.1ppm| 4.7ppm| 0.3ppm|

----------------------------------------------

>[8] z

Time passes.

----------------------------------------------

| 11.6ppm| 49.0ppm| 28.5ppm| 7.4ppm| 0.9ppm|

----------------------------------------------

| 49.3ppm|217.3ppm|122.8ppm| 37.1ppm| 6.6ppm|

----------------------------------------------

| 32.0ppm|123.4ppm|207.1ppm| 85.5ppm| 18.9ppm|

----------------------------------------------

| 38.9ppm| 43.6ppm| 86.2ppm| 32.9ppm| 6.3ppm|

----------------------------------------------

|162.6ppm| 38.0ppm| 22.4ppm| 6.4ppm| 0.4ppm|

----------------------------------------------