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

[READY] [CR] Freezer & freeze mechanics overhaul #24228

Merged
merged 20 commits into from Aug 16, 2018

Conversation

Projects
None yet
9 participants
@nexusmrsep
Copy link
Contributor

commented Jul 7, 2018

What does it do?

This PR introduces:

Minifreezer to freeze your food solid:

  • Minifreezer item, and a vehicle part
  • Minifreezer consumes x1,5 more energy then standard minifridge (lower temperature = more power, higher delta temperature = faster energy transfer)
  • Minifreezer firstly cools food, and then it freezes it (it's a process, not an on/off switch)

New freeze mechanics:

  • FROZEN flag for frozen food,
  • Frozen food has to defrost to be eaten (applies to frozen liquids too),
  • EDIBLE_FROZEN food flag allows some food to be eaten in frozen state (it's not a morale flag),
  • Frozen food can be heated to defrost,
  • Cold environmental temperature (winter, ice lab) will first cool, then freeze your food solid.
  • Frozen food will thaw to cool state (COLD flag), and cold food will go to normal temperature. Unless environment temperature is too cold for it to thaw.
  • If food is not eaten cold (see cold drinks, EATEN_COLD flag) the above transition of states bypasses cold state and goes: normal <--> frozen.
  • NO_FREEZE food flag causes instant rot of frozen item with this flag [edit:] MUSHY flag and drop of joy from eating, some food don't like to be frozen at all (freezing irreversibly damages some food items rendering them inedible)
  • NO_FREEZE flag has a feedback for the player in [e]xamine option as a warning not to freeze this food.
  • fridge temperature was set to 37F/2,5C and moved to game_constants.h
  • rot calculation for fridge stored items uses true temperature calculation and not flat values like before
  • make it so that lightly frozen food can be still eaten (to prevent binary 0-1 effects)
  • add more debug info for [e]xamine to probe HOT/COLD/FROZEN flags "depth" levels
  • slow-down cooling process (it was drastically fast!)
  • MUSHY flag and mechanics (see comments)
  • NO_PARASITES flag and mechanics (see comments)

TODO:

  • apply EDIBLE_FROZEN and NO_FREEZE flags to json-ized comestibles
  • make temperature change speed dependent on difference between threshold and actual temps (water would freeze faster in -20C then -1C)

Rationale:

Follow the initial discussion and ideas presented at: #24145

nexusmrsep added some commits Jul 7, 2018

@DracoGriffin

This comment has been minimized.

Copy link
Member

commented Jul 7, 2018

Looks great, the freeze mechanic seems quite interesting!

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Jul 7, 2018

freeze mechanic seems quite interesting!

Guys and gals playing "nuclear winter" scenarios will either love me or utterly hate me for that, but that's how it is, I guess, when you present such a change.

} else {
target.item_tags.insert( "HOT" );
target.active = true;
target.item_counter = 600; // sets the hot food flag for 60 minutes

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Jul 8, 2018

Member

Food remains hot for an hour?

This comment has been minimized.

Copy link
@nexusmrsep

nexusmrsep Jul 8, 2018

Author Contributor

This is a legacy value. I haven't changed it. Should I?

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Jul 8, 2018

Member

IMO it should be changed to 10-15 minutes.

This comment has been minimized.

Copy link
@nexusmrsep

nexusmrsep Jul 9, 2018

Author Contributor

How about making it weight related? Same with defrost moves consumption. More mass, more energy "stored",  longer the time needed to heat/cool. For ex. heating a small sausage takes less time then defrosting a galon of wood's soup. Also this sausage will be cold sooner then this amount soup. I know that IRL its also volume dependant and environment temperature plays big role too, but using only weight would be
sufficient aproximation IMHO.  Can't say at this moment if its possible to do so, but will look at it asap.

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Jul 9, 2018

Member

Sounds good.

This comment has been minimized.

Copy link
@nexusmrsep

nexusmrsep Jul 9, 2018

Author Contributor

Done some research and found some interesting data that I have to share: THIS paper on Newton Law of Cooling says that boiling water (100C) in room temperature drops to 37C (human body temp) in about 43 minutes, but excluding evaporation (adding oil film to the water) it drops to 42C in 60 minutes. Law scales with delta temperature and other variables, but I'm sane enough to don't even think of using the real math for this. However as for cooling from hot to normal, I now think that this 60 minutes was not that off, considering just the Newton's Law.

This comment has been minimized.

Copy link
@nexusmrsep

nexusmrsep Jul 9, 2018

Author Contributor

Still, as THIS great explanation says heat capacity plays huge role, so smaller objects lose temperature faster then larger ones. I have an idea of implementation now, and will try to present some results soon, as my free time allows me.

target.item_counter = 600; // sets the hot food flag for 60 minutes
if( target.item_tags.count( "FROZEN" ) ) {
target.item_tags.erase( "FROZEN" );
target.item_tags.insert( "HOT" );

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Jul 8, 2018

Member

I feel the process of consecutive defrosting and heating should be longer than simple heating.

This comment has been minimized.

Copy link
@nexusmrsep

nexusmrsep Jul 8, 2018

Author Contributor

You mean regarding moves consumed?

This comment has been minimized.

Copy link
@Night-Pryanik

Night-Pryanik Jul 8, 2018

Member

Yes. Regular heating consumes 300 moves, while defrosting+heating should consume more.

src/map.h Outdated
* Governs HOT/COLD/FROZEN status of items in a fridge/freezer or in cold temperature
* and sets item's fridge/freezer status variables.
* @param it Item processed.
* @param freezer If true its a freezer if false its a fridge, for temperature calculation.

This comment has been minimized.

Copy link
@Night-Pryanik
@Night-Pryanik

This comment has been minimized.

Copy link
Member

commented Jul 8, 2018

freezing irreversibly damages some food items rendering them inedible

Can you provide examples of such products?

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2018

Can you provide examples of such products?

According to THIS source food that doesn't suffer freezing well are:

  • Cooked egg whites
  • Cream based soups and sauces
  • Cucumber
  • Desserts with meringue
  • Fried foods (become soggy)
  • Frostings/icing that include raw egg whites
  • Fully cooked pasta (can be frozen in dishes if undercooked)
  • Fully cooked rice
  • Gelatin
  • Hard-boiled eggs
  • Lettuce
  • Mayonnaise and mayo-based salads (tuna salad, egg salad)
  • Sour cream

THIS source says:

  • Apples & Pears – they discolor and turn mushy. Cooked apples and pears in pies or pie filling are OK though.
  • Celery – like onions they turn to mush when thawed but are ok in cooked dishes.
  • Citrus – Thawed citrus that has been frozen is not going to compare to fresh. Juice your lemons, limes, grapefruits and oranges instead and freeze that. However frozen slices of citrus make for pretty ice floats in lemonade, iced tea and party punches.
  • Cucumbers – again these turn to mush. Don’t freeze.
  • Grapes – fine to eat frozen (in fact frozen grapes are one of my kids favorite summertime treats) but they are pretty gross when thawed.
  • Mushrooms – they turn to slime when frozen. Don’t freeze.
  • Onions – fresh onions when frozen are mushy when thawed. They are fine in soups, stews and casseroles but don’t expect them to be any good on a hamburgers.
  • Peppers – ok in cooked dishes but otherwise you don’t want to eat thawed peppers.
  • Potatoes – raw potatoes cannot be frozen, they turn a funky color and taste horrible. You can however freeze well cooked potatoes. If I have extra potatoes I usually make a large batch of Totally Loaded Mashed Potatoes and freeze that instead.
  • Salad greens – lettuces and other greens turn into a soggy mess when thawed. However fresh spinach can be frozen and used in dishes that call for frozen spinach such as this Spinach Dip.
  • Sprouts – thawed frozen sprouts are a mushy mess.
  • Watermelon – turns to mush when thawed. If you have excess fresh watermelon you can juice it or puree the flesh in a blender and freeze that instead for smoothies. If you want to eat your melon frozen you can do that too.
  • Herbs – Basil, chives, parsley and other soft herbs are no good frozen on their stems, however you can make them into pesto or blend with oil or water and freeze in ice cube trays and plop those ice cubed into soups and stews.

The Do Not Freeze List by THIS
• Vegetables: Celery, cucumbers, lettuce, onions, peppers (especially green), potatoes (especially raw), radishes, sprouts, salad greens
• Fruit: Apples, grapefruit, grapes (unless you're planning on eating them frozen), lemons, limes, oranges (but DO freeze citrus zest!), watermelon
• Dairy: Cheese (especially soft varieties), cottage cheese, cream cheese, custard, eggs in shells (crack them open and try this technique instead, mayonnaise, sour cream, salad dressing, yogurt
• Herbs (if frozen alone in sprigs): Basil, chives, parsley, other soft herbs
• Other: Crumb toppings on casseroles and baked dishes, frosting (egg white and cream based), fried foods, pasta, rice, sauces (especially those made with cornstarch or flour)

Lot of other sources on that too.

I hope @Amariithynar might help to narrow this list or expand it if needed. For now I only added the mechanic, and not flagged any food. Same with EATEN_FROZEN. Food like granola, hardtack and other dry food in my opinion could be eaten while frozen, as inherent lack of moisture prevents them from going solid hard.

@TechyBen

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2018

Some of the cooked items separate, so it's down to our choice if that counts as "rotten" or just "no morale gain" as it can be eaten, just the ingredients resperate (or as the example with fried foods, go soggy/rubbery). [edit] Ah... this might have an easy (?) fix, of allowing frozen foods in some recipes. So "frozen onion" is ok for soups, but "(unfrozen) onion" is needed for onion rings... with frozen turning rotten instantly if unfrozen/thawed?

Others (such as fruit) turn into a mush, which is still edible but not pleasant. More like "fruit pulp" that we already have.

So I wonder if adding a direction for a vector of change in some items? Can we specify what they "freeze" into (as suppose to "rot" into for rotting mechanics)?

Could allow a simple drink + freezer = ice lolly + food processor = ice cream or slush puppy. XD

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2018

If the separation of ingredients is reversible, and safe - ok. If mixing it again won't work, or its separation is a potential danger to the consumer - lets allow to consider it rotten.

If defrosting lettuce converts it to a mushy pulp that literally melts in your hands, than thank you but no, I'm not eating it ever.... You Sir, however, are free to do what your stomach tells you. :)

I see the potential for triming/expanding the list, and that we can certainly discuss.
As for conversion mechanic, i can look at it, but I'd rather do it out of the scope of this PR, as it already has much in it.

nexusmrsep added some commits Jul 8, 2018

@TechyBen

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2018

Oh. I've worked with people on liquid diets. If it is not "rotten" it is edible in any material phase (we had thickener to turn juice/coffee into soup/paste). But as said, it becomes mush, so morale/enjoyability is much much lower. I'd just find it interesting if frozen veg went from veg -> mush -> rotten if defrosted in game (but that might be taking simulation far to far, as you say).

[edit] Remember, this game lets you eat many things (bleach?!?!), but some it does not (uncooked flour). :P

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2018

Oh. I've worked with people on liquid diets. If it is not "rotten" it is edible in any material phase (we had thickener to turn juice/coffee into soup/paste).

I agree, throw lettuce in a blender, and its perfectly edible, but after a freeze & defrost I'm not so sure. I think it's not mechanical damage but destruction on cellular level. But on this topic I'm not an expert, so feel free to add any thoughts or sources found.

@TechyBen

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2018

Higher effect on cooking than freezing for vitamin/nutrition:
http://nutritiondata.self.com/topics/processing (I think the game pulls a lot of data from that site? :D )
https://extension.umn.edu/preserving-and-preparing/science-freezing-foods

Seems it is just texture. But actually cooking/eating such things is very difficult. They certainly would be like starch/pulp/flour is treated in game "does not look edible" or massive morale hit. I may make a note to look at those files if json-ified later, to see if I could list fruit/veg that would become mushy after defrosting.

I'm all for keeping the list as is. It's more a future thing, to instead of not letting a player freeze them... letting a player discover a frozen cucumber is great for adding as flavoured ice cubes to a gin and tonic, but not in a defrosted cucumber [now mushy] sandwich! XD

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2018

Found a "bug" where drinks (contrary to solid food) are not processed so they never have the chance to pass the process_food() and included in it apply_to_fridge() function that would set them active. I'd need to somehow activate them from outside or allow them to be processed, if I figure out what stops them from being processed or what solid food has that drinks don't that they are processed. Any ideas to help me out?

[edit]: Perishables are preactivated, that might be must be the reason.

[edit 2] I would add ( is_food() && g->get_temperature( item_location( this ) ) <= FRIDGE_TEMPERATURE ) ); to needs_processing() but function such as item_location( this ) doesn't exist as a simple query of item's location on a map and I can't think of a way to query item's location on a map from within item.cpp. Any ideas?

@Amariithynar

This comment has been minimized.

Copy link

commented Jul 8, 2018

Regarding most of the foods, especially vegetables, that are listed as breaking down when frozen- they do so because they are high in water content, and the water crystals formed from freezing ruptures cell walls and destroys the firm texture we prefer; the taste isn't greatly changed, it's more about the mouthfeel. Egge whites for example have a gummy texture to them, but are perfectly edible. If they aren't cooked on their own but instead mixed with other ingredients, the effect is minimized as well. Rice freezes perfectly fine after being cooked, but the grains have now swelled with water so they suffer the same issue; a gummy mouthfeel, which isn't present if UNCOOKED eggs are frozen, as the cooking process causes a chemical reaction that alters the structure of the proteins and makes them rigid; if you've ever had undercooked scrambled eggs where there was some mushy, almost liquid bits to it, and felt how it didn't taste BAD but it didn't FEEL good in your mouth, that's basically the same thing. Some sources: https://indianapublicmedia.org/amomentofscience/lettuce-frozen/ https://www.foodsafety.gov/keep/charts/eggstorage.html ("do not freeze" is refferring to end quality of product, not "cannot be eaten") https://www.thekitchn.com/freezer-friendly-the-do-not-freeze-list-167949

Normally I'd say for things like mayo that it's fine if you're incorporating it into another dish, but the only recipes I have that use it are sandwiches, and... yeah, no. Separated mayo on sandwiches is DISGUSTING. https://www.youtube.com/watch?v=IRHgEJib3DI however, you CAN reincorporate it quite easily, too, by using another container and adding a little bit of water to it, then slowly adding the broken mayonnaise and stirring vigourously the entire time; https://www.youtube.com/watch?v=aCWjXzkkljY

What I'd recommend to do for those vegetable ingredients listed is to instead be changed upon either gaining or losing the FROZEN tag (if possible) to change into "mushy <vegetable/fruit>", edible still but with a really nasty Enjoyability rating, which can be used in making soups, or drinks just fine, can still be dehydrated into "dehydrated vegetable chips" and something that should be added is that they should be able to be ground down (quern, mortar & pestle, food processor) into "dehydrated vegetable powder" to make Veggie Drinks/Shakes (this really needs a recipe/to be in the game, with a secondary recipe using the food processor to make them directly from the fresh produce instead; I want a kale smoothie, dammit! ;P). Here's an example where one person does it with lettuce; doesn't matter how mushy the leaves are from being frozen if you dehydrate them and powderize them. https://momwithaprep.com/dehydrate-lettuce/ and it doesn't matter the texture of tomatoes when you're just boiling them down to make a sauce anyways. Basically, "does the original crispness of the ingredient matter for the end product?" and if the answer is yes, then frozen veggies of that kind shouldn't be usable for that recipe. Reading off the list I have in-game: Anything that's pickled/fermenting should be excluded, as should vacuum-packed veggy/fruit pieces, the Japanese-inspired dishes (like hosomaki), onion rings, and all sandwiches. Everything else should be fine,

Most dry prepared foods that I'm aware of actually are perfectly fine to eat frozen; I actually prefer to freeze granola and granola bars because it gives it a more satisfying crunch and chew, but then I fully acknowledge that it's also much harder to eat when not in bar form, as well, because you're having to basically shatter the frozen chunks (most dried foods have some water content still, even if just like 1%). I'd have frozen dried finished goods like granola still be edible without a general reduction in enjoyability, but maybe introduce a minor morale penalty for eating it frozen still; "jaw sore from eating a frozen meal" perhaps, as a counterpoint to "recently enjoyed a hot meal"?

Note that you can actually eat fresh-cut raw meats that have been frozen with minimal risk, since freezing it so quickly after butchering it prevents the growth of bacteria. That's actually how sushi is done commercially; with the fish being bought extremely fresh, freezing it at very low temperatures to ensure that any parasites are destroyed (though careful preparation and proper selection of fish can also render that moot, IRL, as some fish take to being parasitized more than others) for a week, and then kept just above freezing before being prepared. https://www.esquire.com/food-drink/food/how-to/a24118/raw-meat-safety/, http://www.foodauthority.nsw.gov.au/foodsafetyandyou/special-care-foods/raw-meat-safe-eating, https://www.seriouseats.com/2017/05/how-to-prepare-raw-fish-at-home-sushi-sashimi-food-safety.html and http://www.bccdc.ca/resource-gallery/Documents/Educational%20Materials/EH/FPS/Fish/SushiSafety.pdf for some sources. Worth noting is that eating meat freshly carved from the carcass has risks of parasites, but none for food poisoning, unless there was a botched butchery job involved, nicking the intestines, etc.

@Worthstream

This comment has been minimized.

Copy link

commented Jul 11, 2018

Just to point out, there are dishes where the vegetables have to be frozen then defrosted.

For example, the italian cassoeûla, derives most of its flavor from the nutrients that get out of the cells broken during the freezing process. It would be a different dish if prepared by only boiling the cabbage, as most of the flavor would be trapped inside the strong vegetable cells membrane.

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Jul 11, 2018

@Night-Pryanik
Just pushed a commit that hopefuly answers the problem of heating time (HOT) flag and makes it variable based on item's weight - more weight more time to make it HOT. Also item.counter for HOT flag is variable and based on weight. I assume here that smaller items loose their heat faster the bigger ones.
There is some work left there to do (debugging, and finding a way to apply it to COLD/FROZEN), but I wanted to show the initial approach.

I still can't find an easy answer for the problem with non-perishables not getting FROZEN. Reason: there are multiple protections that prevent needless processing of items for efficiency. What I need is a way to activate/process non-perishables in a way that also checks for temperature at item's location.
Adding new conditions in needs_processing would be best I think to allow process() but without arguments I can't find a way to get (query) item's location.
Other approach might be activating them or even processing them when temperature drops below certain level, but I can't determine where to put those functions as of now.
At this rate this PR is gonna be a long time WiP.

@Amariithynar
As for MUSHY flag, it certainly is technically possible to apply, and I will try to design a way to introduce it, so that it will work mostly the way you and @TechyBen described it. It's a slight overkill but if you take one step then you have to take another.

As for NO_FREEZE & EATEN_FROZEN list I will try to drop an initial commit(s) including your research ASAP. It will take some time as I have little free time, have to go through all coded comestibles, and I'm often distracted by other smaller PR that come along and/or interesting development discussions that goes with other PR's. Little patience gladly welcomed.

nexusmrsep added some commits Jul 14, 2018

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Jul 14, 2018

Ok, sum-up of new committed changes:

  • MUSHY flag - food with NO_FREEZE that thaws/defrosts gets this flag.
  • MUSHY food is tasteless, but edible -> enjoyability = -5 & feedback when eaten / examined
  • it can still be used in recipes,
  • if MUSHY food get frozen again it spoils
  • deeply frozen food with parasites gets NO_PARASITES flag that invalidates (kills) parasites + good cook can notice that while examining food

FYI - committed code as of now has some debugging code woven into it as well as some commented '//' experimental snippets that I need to test possibilities of finding a way around food processing exclusions. This will be cleaned-up when I find a way (or someone gives me a good idea) and they will become obsolete.

@nexusmrsep nexusmrsep closed this Jul 14, 2018

@nexusmrsep nexusmrsep reopened this Jul 14, 2018

nexusmrsep added some commits Jul 14, 2018

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Aug 12, 2018

Following the discussion with the devs (Kevin mostly) on Discord, I unlocked processing for all food, perishable or not, to allow it to cool/freeze/thaw. Also if not COLD/FROZEN (and HOT) the processing speed is reduced so hopefully the hit on performance will be negligible. If not, there is room for future tweaks. Testing proves that it works now, and non-perishables freeze too.

Unfortunately Travis seem to have problems with building it on every compiler - seg fault? why? - even though Appveyor seem to digest it fine. [edit: compiled version doesn't crash for me either]

@nexusmrsep

This comment has been minimized.

Copy link
Contributor Author

commented Aug 15, 2018

Final PR dropped, PR is ready.

It seems that some tests fail in Travis but I don't have the expertise in this area to check whats wrong.

@nexusmrsep nexusmrsep changed the title [WiP] [CR] Freezer & freeze mechanics overhaul [READY] [CR] Freezer & freeze mechanics overhaul Aug 15, 2018

@kevingranade kevingranade merged commit 76b57b2 into CleverRaven:master Aug 16, 2018

2 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
gorgon-ghprb Build finished.
Details

@nexusmrsep nexusmrsep deleted the nexusmrsep:freezer branch Aug 16, 2018

@paulenka-aleh

This comment has been minimized.

Copy link

commented Aug 17, 2018

Everything in my RV fridge that was turned off frozen solid overnight, even though it was in garage. I tried to boil stomach to eat something. Now it's both hot and frozen at the same time. Anyway I cannot get my breakfast eaten...
Heating helped but frozen flag ramined. It doesn't work with liquids though, I cannot heat them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.