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

Stomach #8419

Merged
merged 6 commits into from Aug 8, 2014

Conversation

Projects
None yet
4 participants
@Reaper42
Copy link
Contributor

commented Aug 3, 2014

See the code..

@@ -8242,12 +8256,16 @@ void player::consume_effects(item *eaten, it_comest *comest, bool rotten)
hunger -= ((comest->nutr) * 0.66);
thirst -= ((comest->quench) * 0.66);
health += ((comest->healthy) * 0.66);
stomach_food -= ((comest->nutr) *= 0.66);
stomach_water -= ((comest->quench) *= 0.66);

This comment has been minimized.

Copy link
@KA101

KA101 Aug 3, 2014

Contributor

This would require a rewrite of GIZZARD, since the mutation indicates a smaller GI tract. I'd go with half-size stomach, rather than the reduced-input-value which I modeled in the original.

This comment has been minimized.

Copy link
@Reaper42

Reaper42 Aug 3, 2014

Author Contributor

This stomach has no max size, if you about it.
Only one function implemented - vomit.

Reaper42 added some commits Aug 3, 2014

@kevingranade

This comment has been minimized.

Copy link
Member

commented Aug 4, 2014

Really cool concept, only two issues, one of which can happen later.
The main thing is speed, unless I'm reading the code wrong, the stomach will essentially empty out within 50 minutes of eating, even if you're on the verge of starvation beforehand.
Assumptions:
A digestion tick happens once every 10 minutes.
The minimum amount that will digest in a tick is 10.
The range of hunger values that will drop to less than 10 is 11-50.
The range of hunger values that will drop to less than 50 is 51-250.
The range of hunger values that will drop to less than 250 is 251-1250.
The range of hunger values that will drop to less than 1250 is 1251-6250.
6000 hunger is when you die of starvation, so the full range of digestion will happen in 5 ticks, or 50 minutes.
Even more so, the vast majority of it is front-loaded, so you generally aren't going to care if vomiting is triggered as long as it's at least 20 min after eating.
I'd suggest making the consumption rate more constant, so it digests up to a certain amount of food per tick instead of a certain fraction, and targeting 1-2 hrs for the total digestion process.
Something like dec_stom_food = 50;
If you eat a day's worth of food, it'll go:
300 -> 250 -> 200 -> 150 -> 100 -> 50 -> 0, or 60 minutes.
Overeating will make it take longer, small meals will clear out faster. If you absolutely gorge yourself it might take a very long time.
For sources, see:
http://www.mayoclinic.org/digestive-system/expert-answers/faq-20058340
https://answers.yahoo.com/question/index?qid=1006060227970
http://en.wikipedia.org/wiki/Digestion

The second issue is that if we're tracking stomach contents, it would be nice to have eating only put the contents in the stomach, and then only have that apply against hunger and thirst when it's digested, so vomiting doesn't make you lose nutrition, you haven't absorbed it yet, and you're just losing the contents of your stomach. This isn't critical for this PR and can be added later.
Another neat thing this would let us do is lower stomach capacity, so that there's a certain total amount you can eat at once (adjusted by mutations and traits) instead of being able to eat enough all at once to go from starving to totally well-fed. Also there might be penalties for gorging yourself seperate from your nutrition level.

@Reaper42

This comment has been minimized.

Copy link
Contributor Author

commented Aug 4, 2014

I think about more realistic digestion simulation. But there is many hunger++ in code. I plan do it but not now. It very complex work, i think need to create class "body" and something like it.

@kevingranade

This comment has been minimized.

Copy link
Member

commented Aug 4, 2014

Yes it's rather involved, that's why I said the rate thing is the only critical thing for this PR.

@Reaper42

This comment has been minimized.

Copy link
Contributor Author

commented Aug 4, 2014

You just need max_stomach_size right?

@kevingranade

This comment has been minimized.

Copy link
Member

commented Aug 4, 2014

The most important thing is reducing the rate at which the stomach empties out. I proposed 50 units/10 turns, but anything in the ballpark of taking between one and two hours for a large meal to empty out of the stomach is fine.
For the other thing, max_stomach_size would get us part of the way there, probably in the ballpark of 1000 units by default or so?
I'd still want to adjust it to interact properly with mutations, and make it where you get nutrition as food is digested rather than when you eat it, but that's secondary IMO.

@Reaper42

This comment has been minimized.

Copy link
Contributor Author

commented Aug 4, 2014

Now stomach empties out rate is 20% per 5 minutes. (50 turns). Min reduce is 10.
100->80->64->51->40->30->20->10->0 (45 minutes) (2 minute if 50 units/10 turns)
500->400->320->256->204->163->131->104->... (85 minutes) (10 minutes/100 turns)
6000->4800->3840->3072->2457->1966->1572->1258->1006->805->644->515... (145 minutes) (120 minutes)
All ok. I don't see big problem.
Also this way not so suffer for large stomach size.
50 units/10 turns is so fast.
50 units/50 turns - may be, but 5000 food will pass 500 minuets (~83 hour) -> need max_stomach_size, rewrite consume_effects, rewrite interface and more.

@kevingranade

This comment has been minimized.

Copy link
Member

commented Aug 4, 2014

Your logic is backwards, assume u.stomach_food == 1000:

int dec_stom_food = u.stomach_food * 0.8;
// Now dec_stom_food == 800
dec_stom_food = dec_stom_food < 10 ? 10 : dec_stom_food;
// No change, dec_stom_food == 800
u.stomach_food -= dec_stom_food;
// Now u.stomach_food = 200

I still think a constant emptying rate is a better approximation of reality short of tracking age of the food in the stomach, but fix it to be 20% instead of 80% per tick and I won't complain.

@Reaper42

This comment has been minimized.

Copy link
Contributor Author

commented Aug 4, 2014

Ouch.

Reaper42 added some commits Aug 5, 2014

Merge branch 'master' into stomath
Conflicts:
	src/player.cpp
	src/player.h
	src/savegame_json.cpp
Fix
@Reaper42

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2014

I make fix.

@Reaper42

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2014

And...so what?

@KA101

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2014

I imagine Kevin's busy; I'm handling a lot of other Stuff at the moment so haven't been able to look into this one as much as I'd want to. Sorry.

@Rivet-the-Zombie

This comment has been minimized.

Copy link
Member

commented Aug 8, 2014

Works good.

The gross things I made my test character do in order to test this PR shall never be spoken of again.

Rivet-the-Zombie added a commit that referenced this pull request Aug 8, 2014

@Rivet-the-Zombie Rivet-the-Zombie merged commit 1c6c4d3 into CleverRaven:master Aug 8, 2014

1 check passed

default This has been rescheduled for testing as the 'master' branch has been updated.
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.