0
\$\begingroup\$

How can I simulate the vegetation (of a human being)?

To simulate Hunger for example, I use some kind of saturation based system now. Means that every food-object saturates differently and the saturation influences how much gets substracted from the current hunger level.

But I'm not very satisfied with the result and I don't really have an idea how to realize the same with the needs Fun and Energy.

So, is there a special way to do this? Or is there an algorithm that is used in stuff like The Sims or even Minecraft (which has hunger only, but it has.)?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Wait, I got to pee .... okay, that's done. I think this question is far too broad. And it really depends on what you need or are satisfied with. Simple solutions are easy to come by, but truly simulating the need for hunger, digestion and excretion let alone something as arbitrary and not well-defined yet universally understood as "fun" are subjects of scientific research and there are no simple answers, perhaps not even answers per se. \$\endgroup\$
    – CodeSmile
    Dec 28, 2013 at 18:20
  • 1
    \$\begingroup\$ I think that you really just need to sit down and describe exactly how hunger should it feel to the player, and then the simple system to make that happen will be very obvious. \$\endgroup\$ Dec 28, 2013 at 18:35

3 Answers 3

2
\$\begingroup\$

First, any need can be viewed as a progress bar. Hunger, Fun, Energy, everything. Even non-need related things, like Fear. How the value of the progress bar increases or decreases, is up to the function manipulating the need behind it. The Sims clearly shows this: enter image description here

abstract Need
{
    numeric CurrentValue;        
    external function IncreasingRule;

    function Update()
    {
        IncreasingRule.Apply(this, Params);
    }
    ...
}

Increasing rules are functions that change the state of the needs attached to them. Params in my pseudocode above contains info that the increasing rule needs to use to apply changes to the need.

I do not believe such things as "standard" increasing rules exist. You pretty much have to come up with your own solutions or just copy other people's. Basic examples, to give you an idea:

IncreasingRule HungerRule.Apply(HungerNeed, Subject)
{
     if (Subject.Eating)
     {
            HungerNeed.CurrentValue -= Subject.FoodBeingEaten.HungerValue;
     }
     else
     {
            //Linear development as time passes.
            HungerNeed.CurrentValue = Subject.TimeSinceLastMeal; 
     }
}

IncreasingRule FunRule.Apply(FunNeed, Subject)
{
     if (Subject.DoingSomethingThatCanBeFun)
     {
        //If the thing the subject is doing is among his favorites, the fun 
        //need goes down based on their favorite rank. If, instead, they're
        //doing something boring, or if they absolutely hate what they're doing,
        //the fun need goes up (return value of CalculateFun is negative).
        FunNeed.CurrentValue -= 
        CalculateFunBasedOnListOfFavoriteThings(Subject.FunObjectInUse);
     }
     else
     {
        FunNeed.CurrentValue = Subject.TimeSinceLastDidSomething;
     }
}

//Similar to the one in The Sims.
IncreasingRule RoomRule.Apply(RoomNeed, Subject)
{
     if (Subject.JustEnteredRoom)
     {
         if (Subject.CurrentEnvironment.ContainsNewDecorations)
         {
             RoomNeed.CurrentValue -=
             CalculateBeautyBasedOnSubjectPreferences(Subject,
             Subject.CurrentEnvironment.NewDecorations);
         }
     }
     else
     {
         RoomNeed.CurrentValue = Subject.TimeSinceSeenSomethingNew;
     }
}

Needs' current values should be kept under control, obviously, with a min/max boundary.

\$\endgroup\$
1
  • \$\begingroup\$ The progressbar-thing was no question and is already implemented.(: But I like the idea of handling every need as a class with unique apply-rules attached to them. You also answered my main question pretty good in one sentence: "I do not believe such things as "standard" increasing rules exist.", so I guess I'll have to sit down and do my own increasing-rules. \$\endgroup\$
    – andy
    Dec 28, 2013 at 19:17
1
\$\begingroup\$

I'd model hunger against calories.

A hamburger that has 500 calories will last you for 2 hours assuming 250 calories per hour expenditure.

I don't think you can model fun like this. I'd model energy similarly to hunger, but factor in a reduction in energy for lack of sleep as well.

\$\endgroup\$
1
  • \$\begingroup\$ I like the idea of modelling hunger against calories. So you would say a higher level of calories means that the hunger decreases slower? \$\endgroup\$
    – andy
    Dec 28, 2013 at 19:13
1
\$\begingroup\$

There are many ways to model each type.

Hunger can be calorie based like bobobobo stated.

Energy could be based on hunger: The less hungry you are, the faster your energy regenerates.

Fun could be measured like an hourglass: An activity would recharge your "fun" meter by a certain amount, with some activities providing more "fun" than others. Fun would slowly run out over time, and "unfun" activity may drain it faster.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .