cyphesis
cyphesis copied to clipboard
Metabolizing property
Pull contains working implementation of metabolizng property for both plants and characters. Character metabolise function was deleted and its functionality moved to the property. Metabolizing property relies on following new numercial properties:
- massreserves
- reservelimit
- mass
- status
- grows
Growth code from Plant.cpp
was moved to metabolizing property aswell.
Currently entites that are alive have two kinds of mass:
- mass - total mass of entity
- massserseves - biomass that can be changed into energy without triggering death.
You can think of it as 'fat' in case of animals, fruit mass in case of trees etc. reservelimit - is maximal mass reservers of an entity. It is normalized value a number between 0 (entity cannot store energy as mass) and 1 (entity can be made entirely of fat).
Things that require attention:
- Writing proper integration tests.
- Adding
<metabolizing></metabolizing>
property to entity classes that should be able to metabolize.
I'll take a closer look, however at the moment I'm trying to focus on getting physics in there.
I would however want to see some tests for metabolizing sanity. I.e. that things grow to max size, wither and die in accordance to the rules. A test where you send 1000 Ticks to a metabolizing entity and then check that the rules are followed.
This is because this is one of those tricky game logic things where errors can be both hard to catch (are things really growing as they should) and have large consequences (all trees have died).
I've tried out this branch now. First thing that sticks out it that characters don't metabolize. I tested this by spawning a standard human character and eating a ham. Status is unchanged, even after a couple of minutes.
Also, am I right to assume that with these patches plants won't metabolize at all, as there's no default metabolizing property on them?
And I still would really want to see proper tests for this property. I.e. "what happens after 100 ticks" and so on.
I wasn't sure to which parent class attach "metabolizing" property therefore characters don't metabolize yet. Should I attach the property to mobile class or something else? From what I've seen its shared for all animals. The other class possessing metabolizing property would be plant - would that be right?
I'll get you know after those tests will be ready.
I took a look at this again, but the code doesn't compile. I got some errors in Plant.cpp. Also note that we now use CMake, so you need to add your files to the CMakeLists.txt file and remove the Makefile.am files.
Don't change the density though. Even if that sounds like the proper way to mimic the real world, I'm confident that we'll get a much more complex game with regards to how we can write rules and gameplay if different entities of the same type have different density.
/Erik
2017-12-05 15:55 GMT+01:00 pifthemagicdragon [email protected]:
Thank you, also I need to change some in relation to mass being readonly. My idea is to split mass changes into "size change" (aka volume) and (density).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/worldforge/cyphesis/pull/28#issuecomment-349328033, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFcYFMppWMyV3LrnhxMnrBxs-gYtIKCks5s9VlQgaJpZM4JDtVC .
Ok, this also would also implicate that storage of energy via getting fat would not increase the real mass (since this would have to change the entity size). But I assume everyone is ok with that (its certainly simpler).
Could you walk me through the difference between getting fat and growing, in the current system? I haven't looked at the code in a while.
/Erik
2017-12-18 13:50 GMT+01:00 pifthemagicdragon [email protected]:
Ok, this also would also implicate that storage of energy via getting fat would not increase the real mass (since this would have to change the entity size). But I assume everyone is ok with that (its certainly simpler).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/worldforge/cyphesis/pull/28#issuecomment-352416955, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFcYHksHNam35N8OARUuCs7tu_ejtluks5tBl-NgaJpZM4JDtVC .
In current code (that as you pointed out in e-mail a while ago - is wrong): Growing is increasing mass due to volume increase. Getting fat is increase of mass that cannot be accounted by or associated with size increase. The way I allow both of them to happen at the same time is by keeping track of two variables:
mass // total mass
massReserve // mass of fat
Whenever there's some food consumed and status is high enough so both fat and size should grow. The growth is calculated according to forumals:
double coreMass = mass-massReserve;
...
// Getting bigger (growth) is a size multiplier
growth = 1.0f + (1.0f - 0.5*reserveLimit)*massChange/coreMass;
// Getting fatter
massReserve += reserveLimit * massChange;
// Mass
mass += massChange;
reserveLimit is a just a constant that says what is the energy policy of animal (how much energy into growth how much into reserves)
However this is wrong because it doesn't play nicely with density (and I'm not suppose to modify mass). I hope that helps.
Now another change is needed to get this code updated for density. When I look at this I agree that this bring too much complexity just because I want to be physically accurate. The solution that satisfies your constraint of having constant density comes with a cost of having fat entities and skinny entities (of the same type) with the same mass.
If you OK with that I am too.