Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

water rework part 1 #72252

Merged
merged 14 commits into from
Jun 4, 2024
Merged

water rework part 1 #72252

merged 14 commits into from
Jun 4, 2024

Conversation

nornagon
Copy link
Contributor

@nornagon nornagon commented Mar 8, 2024

Summary

Content "Add murky water, make regular water safer"

Purpose of change

Ref #72. The goal is to make water purification more accurate and interesting,
exposing more of the simulation to the player (while also simplifying the
simulation in some dimensions).

Describe the solution

Water from moderately-clean sources like flowing rivers and from rain is now
mostly safe to drink. It has no parasites, and carries a small chance of
contracting a waterborne disease (roughly, giardiosis or cryptosporidiosis).

Note: I'd prefer to have water have a very small but non-zero chance of
having parasites (say, 1 in 1000), but currently any chance of parasites
turns the item red and gives it a "not safe to drink" warning, which doesn't
seem appropriate here.

Water from murky sources like puddles and swamps now gives a new item, "murky
water", which must be filtered using either purification tablets or a gravel/sand
filter to become regular water. Murky water is still technically drinkable, but
has a 20% chance of parasites and will guaranteed make you sick.

I've added a new type of water filter, an improvised slow sand filter, which can be used to filter murky water into water. Arguably this sort of filter could even produce clean water, but given the improvised nature and the fact that I haven't modeled any time for biofilm creation or maintenance, I think this is a reasonable compromise for simplicity.

Changes
  1. Add water_murky.
  2. Add water_spring.
  3. water from rain, toilets, rivers and ponds is no longer poisoned, but instead has a small chance to inflict bad_food or highly_contaminated_food.
  4. Combine SPAWN_WITH_LIQUID and FRESH_WATER into SPAWN_WITH_WATER.
  5. Add water_filter_sand, a slow-sand biofilter.
  6. Changed water filtration using tablets or other purification methods to use survival instead of cooking.
  7. Added a recipe for deriving water from water_murky using a slow-sand filter.
  8. Added a recipe for deriving water from water_murky using a water purification tablet
  9. Changed disease contamination chance from int to float.
  10. SPAWN_WITH_WATER + MURKY on terrain now spawns water_murky.
  11. Terrain with "examine_action": "water_source" now give water_murky if it has the MURKY flag.
References

Describe alternatives you've considered

  1. Maybe environmental water post-Cataclysm is actually much more dangerous than it was pre-Cata. Are there decaying corpses in it? Or did all the corpses get zombified and so they aren't really decaying? This direction is kinda unclear to me from a lore perspective, so if someone wants to chime in with lore details here I'd be happy to shift direction. Otherwise, I'll stick with a roughly present-day idea of how safe environmental water is to consume.
  2. Maybe the specific area from which you draw your water should matter more. This requires either (a) adding a bunch more different types of water, which seems annoying from a UI/crafting recipe authoring perspective, or (b) making water contaminants largely hidden from the player, which I think is uninteresting—if the player can't see it, it might as well not exist, and random chance will do a pretty decent job at letting the player perceive a good story from their actions.
  3. SODIS, i.e. SOlar DISinfection, is an extremely simple method for treating water (just leave it out in the sun for 6h!). This should probably be in the game, but it's so simple it might render other water purification methods basically useless?

Testing

Additional context

@github-actions github-actions bot added [JSON] Changes (can be) made in JSON Items: Food / Vitamins Comestibles and drinks Crafting / Construction / Recipes Includes: Uncrafting / Disassembling [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Mechanics: Weather Rain, snow, portal storms and non-temperature environment labels Mar 8, 2024
@Inglonias
Copy link
Contributor

Inglonias commented Mar 8, 2024

You mentioned flowing sources and clearly stagnant ones - what about ponds and lakes? Those were not mentioned (unless I am VERY bad at reading). Any changes there?

@GuardianDll
Copy link
Member

did you consider the approach of #72224, aka having parasites, toxic, dirt, chemicals etc being vitamins?

@RenechCDDA
Copy link
Member

did you consider the approach of #72224, aka having parasites, toxic, dirt, chemicals etc being vitamins?

I think that would be somewhat pointless in this case, as all the recipes would have to be using NUTRIENT_OVERRIDE to get rid of them. That would be more likely to accidentally allow inheritance than anything else.

@nornagon
Copy link
Contributor Author

nornagon commented Mar 9, 2024

You mentioned flowing sources and clearly stagnant ones - what about ponds and lakes? Those were not mentioned (unless I am VERY bad at reading). Any changes there?

These still give water currently (i.e. mostly-safe drinkable water). I'm not sure whether pond water or lake water should be murky water—for standing water, most particulates will fall to the bottom of the body of water through gravity. I'm not sure if it's more likely that still water or flowing water would be more likely to contain cryptosporidium, giardia, etc. or other waterborne disease-causing agents. If you're able to find good actual data on this I'd love to see it! In the absence of good data, I think it's reasonable to say—if a survivor is at a pond, probably some of the water is safe-ish (i.e. clear and not full of algae). When you examine it, let's say your survivor is smart enough to get the clear stuff and not the full-of-algae stuff. That's what water is intended to model with this PR.

did you consider the approach of #72224, aka having parasites, toxic, dirt, chemicals etc being vitamins?

I didn't consider this. @RenechCDDA's point about accidental inheritance is a reasonable one, though I'd also like to allow non-accidental inheritance (i.e. cooking something with water without boiling it sufficiently will give you a result which has a chance to cause disease). I'm not sure that's possible with this approach.

That said, I think we could take it in that direction in future if it makes sense. I still think we should split murky water out from regular "clear, somewhat unsafe" water in either case :)

@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Mar 9, 2024
@PatrikLundell
Copy link
Contributor

This is draft and the first commit is part 1, so I guess the potentially huge task of adding the new type of water to all relevant recipe is intended to be tackled in future parts.

I would suggest the definition of a few different water groups recipes would draw from, rather than directly adding the new water variant to each applicable recipe (introduction of groups would still touch almost every water containing recipe, but at least make future recipes easier to define and make maintenance (and possible future further expansion) easier).

@Qrox
Copy link
Contributor

Qrox commented Mar 9, 2024

I didn't consider this. @RenechCDDA's point about accidental inheritance is a reasonable one, though I'd also like to allow non-accidental inheritance (i.e. cooking something with water without boiling it sufficiently will give you a result which has a chance to cause disease). I'm not sure that's possible with this approach.

Out of the scope of this PR, but we can probably change the crafting system to make some cooking methods reduce the nutrient/vitamin of the resulting item, so boiled water has no pathogen (and boiled vegetable losses vitamins).

@RedMisao
Copy link
Contributor

RedMisao commented Mar 9, 2024

I'm not sure if it's more likely that still water or flowing water would be more likely to contain cryptosporidium, giardia, etc. or other waterborne disease-causing agents. If you're able to find good actual data on this I'd love to see it!

For what I know, "still" water is a much higher risk regarding its safety for consumption when compared to any "flowing" source of water.
Important note: regardless if it's still or flowing, according to the ANSI/IICRC S500 standard (paylocked), the "IICRC considers all water originating from seawater, ground water, surface water, rising rivers and streams, and wind-driven rain from hurricanes and tropical storms to be Category 3." source.

stagnant water
(text from)

Why stagnant water is considered worse than flowing water can be divided into at least three factors.

One is that still water has a relatively lower level of dissolved oxygen (DO), which is a direct parameter for the quality of water (tl;dr water microbiota use oxygen to degrade organic matter, so they will consume most stuff that falls into the water with enough dissolved oxygen (and enough time). The alternative is that organic matter is not degraded and persists for much longer). Abnormal levels of organic matter in the water are (almost always) caused by human activity, therefore DO is a direct parameter for the quality of water and an indirect parameter for human pollution. DO levels do not affect Giardia viability and have a negative correlation for Cryptosporidium. I did not mention examples of anaerobic bacteria and DO tolerance, but their survival is also inversely proportional.
By the way, this is a direct physical consequence of flowing water allowing more mixing than simple diffusion allows for still water.

Another factor is temperature. You can imagine that low temperatures allow stuff to persist for longer, whereas high temperatures (relative to the environment) proportionally reduce viability according to the temperature reached and time. For Giardia's viability, it is "significantly affected by temperature; as the temperature increases, survivability decreases". There's this very old study that tested the same thing over different seasons, with the same conclusion. For Cryptosporidium, freezing and high temperatures are able to reduce its viability. (which is interesting because freezing is not considered a safe way to decontaminate food)

A third factor is that still water allows the formation of bacterial biofilm (in depth review article and a summary by EPA although it's for pipelines and not environmental water), which is bad by itself, and serves as a substrate for other organisms to grow and survive. For human pipelines, the worst case scenario is when the biofilm is produced by pathogenic bacteria (Legionella, E. coli, Pseudomonas, etc), cannot be cleared and serves as a "seed" for further contamination; biofilm itself is very difficult to clean once is stablished. You can imagine it's worse for environmental sources of water. At the same time, it's somewhat balanced by the fact environmental water does not have just pathogens living in it.

Something up to debate is given water is virtually never sterile, why people are not sick all the time. The short answer is there's a tolerance threshold thanks to pathogenic load in the volume of consumption and each individual's immune system. Disease happens when this balance is compromised. It also explains asymptomatic humans as carriers for certain pathogens, i.e. cholera outbreaks.

If you're able to find good actual data on this I'd love to see it! In the absence of good data, I think it's reasonable to say—if a survivor is at a pond, probably some of the water is safe-ish (i.e. clear and not full of algae). When you examine it, let's say your survivor is smart enough to get the clear stuff and not the full-of-algae stuff. That's what water is intended to model with this PR.

IMO the best approach. The probability of not getting sick by drinking random, untreated water is modeled by two different types of water out there, with the survivor tolerating some amount of pathogens for the cleanest kind, most of the time.

Additional references: This article contains the most common organisms monitored for contamination.

@ADekema
Copy link

ADekema commented Mar 9, 2024

On the suggestion of using vitamins to model disease agents. I think that vitamins is a bad way to model biological diseases. The reason is that these are organisms that can reproduce on their own so even a little bit of exposure has a chance to make you sick. The chances of getting sick increase the higher dose (drinking more) you are exposed to but it is still a chance not a certainty. It would be better to just have a flat chance of getting sick for every unit of unsafe water you consume.

Vitamines would be a good model for more chemical polutins and toxins. It takes a set amount of polutins and toxins to get you sick. As long as you don´t go over this it should be fine (besides the health impact). So using vitamins to model the amount of a polutents or toxins in your systeem and how fast you eliminate them is a good idea.

@nornagon
Copy link
Contributor Author

This is draft and the first commit is part 1, so I guess the potentially huge task of adding the new type of water to all relevant recipe is intended to be tackled in future parts.

For most recipes water_murky isn't appropriate (e.g. it shouldn't be an option for any cooking recipe), so it shouldn't be that huge a change in the recipe department.

I would suggest the definition of a few different water groups recipes would draw from, rather than directly adding the new water variant to each applicable recipe (introduction of groups would still touch almost every water containing recipe, but at least make future recipes easier to define and make maintenance (and possible future further expansion) easier).

Agreed, groups are the right tool here.

If you're able to find good actual data on this I'd love to see it! In the absence of good data, I think it's reasonable to say—if a survivor is at a pond, probably some of the water is safe-ish (i.e. clear and not full of algae). When you examine it, let's say your survivor is smart enough to get the clear stuff and not the full-of-algae stuff. That's what water is intended to model with this PR.

IMO the best approach. The probability of not getting sick by drinking random, untreated water is modeled by two different types of water out there, with the survivor tolerating some amount of pathogens for the cleanest kind, most of the time.

Thanks for the detailed research @RedMisao, this seems to confirm that the current approach in the PR lines up more or less well with reality. We could potentially get more detailed here in future.

@nornagon
Copy link
Contributor Author

Bringing this out of draft as I think this is ready for wider review.

@nornagon nornagon marked this pull request as ready for review March 13, 2024 03:52
@nornagon
Copy link
Contributor Author

To add some context for why this is labeled "part 1", here are some things I'd like to address in followups:

  1. water_clean in an unsealed container should decay to water over time.
  2. Recipes which use water but don't reach boiling point should carry the chance of contamination.
  3. Some recipes/constructions which accept water should also accept water_murky or water_spring (and maybe even water_mineral too).
  4. Disease from bad food or contaminated water shouldn't onset immediately upon consumption, but rather incubate for some time before affecting the character.
  5. Audit the various water purification methods (water purification tablet, water purifier, charcoal water purifier, large charcoal water purifier) for accuracy, and expand to allow water_murky inputs where relevant.

@XygenSS
Copy link
Contributor

XygenSS commented Mar 18, 2024

shouldn't water purification tablets purify murky water directly into clean water?

@nornagon
Copy link
Contributor Author

shouldn't water purification tablets purify murky water directly into clean water?

This is getting reworked in #71971, the idea with the single-tab recipe is that it takes twice as many tabs to take a given volume from murky to clean, and since the recipes are about to get reworked anyway I went with this mid-way solution.

@RanikOrtega
Copy link
Contributor

RanikOrtega commented Mar 26, 2024

  1. I'd recommend adding buckets and/or the new 5 gallon buckets to the slow sand filter recipe rather than only jerry cans.
  2. I might include "Water Filters" in home sinks as a rare-ish item that could be used for less primitive or more effective water filter buckets or in the future more advanced water filtering appliances.

1 is an easy add. 2 may be more of a future addition

@nornagon
Copy link
Contributor Author

@RanikOrtega Yeah, now that my 5gal bucket PR has been merged I can update this to use those instead of jerrycans. Jerrycans was a temp fix until the 5gal buckets were in, can update now :)

@osuphobia osuphobia mentioned this pull request May 1, 2024
data/json/recipes/recipe_food.json Show resolved Hide resolved
data/json/recipes/recipe_food.json Outdated Show resolved Hide resolved
data/json/recipes/recipe_food.json Outdated Show resolved Hide resolved
data/json/items/tool/cooking.json Outdated Show resolved Hide resolved
Co-authored-by: osuphobia <78858975+osuphobia@users.noreply.github.com>
Copy link
Contributor Author

@nornagon nornagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @osuphobia

data/json/recipes/recipe_food.json Outdated Show resolved Hide resolved
@kevingranade
Copy link
Member

Maybe environmental water post-Cataclysm is actually much more dangerous than it was pre-Cata. Are there decaying corpses in it?

IMO it's a hard sell to claim there are ENOUGH corpses upstream of or in water sources to meaningfully change this. It could certainly be the case if a particular source was contaminated though (as established by mapgen).

Maybe the specific area from which you draw your water should matter more.

The one area where I think this would be meaningful would be "industrial type" contamination like heavy metals or other toxic substances instead of biological pathogens, since they have a different set of purification criteria. As for a bunch of types, probably just one type of "chemically tainted water" would be sufficient, along with places for it to spawn.

Co-authored-by: osuphobia <78858975+osuphobia@users.noreply.github.com>
Co-authored-by: osuphobia <78858975+osuphobia@users.noreply.github.com>
nornagon and others added 2 commits May 30, 2024 11:19
Co-authored-by: osuphobia <78858975+osuphobia@users.noreply.github.com>
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 31, 2024
@Maleclypse Maleclypse merged commit c8164e3 into CleverRaven:master Jun 4, 2024
23 of 27 checks passed
@Maleclypse
Copy link
Member

SODIS, i.e. SOlar DISinfection, is an extremely simple method for treating water (just leave it out in the sun for 6h!). This should probably be in the game, but it's so simple it might render other water purification methods basically useless?

Do I remember correctly you need it to be in a transparent container and the sun needs to be shining fairly brightly on it for six hours? I don't think there's anything wrong with it I just wonder if the problem wouldn't be our ability to use solar radiance to track if it received enough sun, but more so that the PC is unerringly able to intuit which water has received the full six hours needed to be safe versus water that had not received that safe amount of sun.

@nornagon nornagon deleted the water-rework-1 branch June 4, 2024 03:06
@nornagon
Copy link
Contributor Author

nornagon commented Jun 4, 2024

SODIS, i.e. SOlar DISinfection, is an extremely simple method for treating water (just leave it out in the sun for 6h!). This should probably be in the game, but it's so simple it might render other water purification methods basically useless?

Do I remember correctly you need it to be in a transparent container and the sun needs to be shining fairly brightly on it for six hours? I don't think there's anything wrong with it I just wonder if the problem wouldn't be our ability to use solar radiance to track if it received enough sun, but more so that the PC is unerringly able to intuit which water has received the full six hours needed to be safe versus water that had not received that safe amount of sun.

If I think about how I might personally judge this, I'd go something like "a whole day's worth of sun on a sunny day". So fudge the sun-hours up to 8 to account for the PC's caution and fallibility, mix in some "it says 6 hours but 5½ hours is probably still mostly fine" and call it good :)

I think SODIS should probably be a recipe..? i.e. turn container + water into a new "water_disinfecting" item, and have the description mention leaving it in the sun. The item can acquire sun-hours over time and when it gets to 8 it turns into container + water_clean. The annoying thing would be allowing the recipe to use any of the various different transparent containers...

  • jug_plastic
  • bottle_plastic
  • bottle_twoliter
  • bottle_glass
  • jar_glass_sealed
  • bag_zipper
  • bag_zipper_gallon
  • ... etc?

each with different amounts of water.

The alternative would be to check solar irradiance for all water in bottles anywhere, which might be a bit expensive, but would get around the recipe explosion problem.

@Maleclypse
Copy link
Member

SODIS, i.e. SOlar DISinfection, is an extremely simple method for treating water (just leave it out in the sun for 6h!). This should probably be in the game, but it's so simple it might render other water purification methods basically useless?

Do I remember correctly you need it to be in a transparent container and the sun needs to be shining fairly brightly on it for six hours? I don't think there's anything wrong with it I just wonder if the problem wouldn't be our ability to use solar radiance to track if it received enough sun, but more so that the PC is unerringly able to intuit which water has received the full six hours needed to be safe versus water that had not received that safe amount of sun.

If I think about how I might personally judge this, I'd go something like "a whole day's worth of sun on a sunny day". So fudge the sun-hours up to 8 to account for the PC's caution and fallibility, mix in some "it says 6 hours but 5½ hours is probably still mostly fine" and call it good :)

I think SODIS should probably be a recipe..? i.e. turn container + water into a new "water_disinfecting" item, and have the description mention leaving it in the sun. The item can acquire sun-hours over time and when it gets to 8 it turns into container + water_clean. The annoying thing would be allowing the recipe to use any of the various different transparent containers...

  • jug_plastic
  • bottle_plastic
  • bottle_twoliter
  • bottle_glass
  • jar_glass_sealed
  • bag_zipper
  • bag_zipper_gallon
  • ... etc?

each with different amounts of water.

The alternative would be to check solar irradiance for all water in bottles anywhere, which might be a bit expensive, but would get around the recipe explosion problem.

oof yeah recipe explosion indeed. At least we have the transparent flag already for containers you can see through. I really don't know the best way to go forward on this idea though.

@worm-girl
Copy link
Contributor

What about using something like the funnel rain catcher, or failing that, something like a stooking spot? I believe funnels are technically a trap, and stooking spots are hardcoded but it's a simple method to copy.

@PatrikLundell
Copy link
Contributor

Given that it seems to be foggy a third of the time each day and not sunny at other times I think it will be rather tricky to determine when enough sunlight has been absorbed. However, it seems this problem is similar to that of determining the radiation received by solar panels.

@KHeket
Copy link
Contributor

KHeket commented Jun 6, 2024

After this change I cant use swamp not salty water for crafting clay items. Is it a bug or feature?

@nornagon
Copy link
Contributor Author

nornagon commented Jun 6, 2024

@KHeket that's a known piece of remaining work, see #72252 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Items: Food / Vitamins Comestibles and drinks [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Mechanics: Weather Rain, snow, portal storms and non-temperature environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.