AI Rework – Rapidly losing control…

It’s fascinating how one thing in development leads to another, which leads to another, which in turn means a major change in gameplay.

In implementing the emotional systems, I’ve subconsiously stumbled into a Needs-like system, requiring that every emotion be coupled to a specific action: creature’s eat when hungry, flee when afraid, mate when amorous, etc.

This has lead to me having to work out the need for Pain. It’s a given that a Pain meter needs to be implemented (because reasons. SCIENCE reasons), but what actions can a creature take to reduce pain? They could flee the source, but that’s what fear does: we don’t need a duplicate of fear. And pain fades on it’s own: there’s no real *decision* one can make to reduce pain after it occurs: pain in real life is a preventative measure. There’s no appropriate biological response to it except to…

… rest and recover.

And thus, the creatures in Species will, as of 0.8.0, have the ability (and need) to sleep.

Pain will be generally reflect the percentage of health, while Hunger will generally reflect the total percentage both health and energy. Thus, a starving creature (no Energy and low HP) will have a higher hunger than pain value and will prioritise food, while an injured one (high Energy, low HP) will have a much higher pain.

This high pain value will cause the creature to lose consciousness, which will trigger rapid healing: creature’s healing rate will be vastly reduced when awake.

So, why not call it ‘tiredness’ then? (aside from the absolute necessity of having a pain meter for aforementioned SCIENCE reasons). Well, Pain has the advantage of being triggered by other means, such as rapid dealing of damage. This provides an interesting selection pressure for combat-oriented creatures: rather than trying to kill their prey outright, they could aim for maximum pain so as to knock their prey unconscious The Pain Threshold gene is thus exposed to two competing selection pressures: high enough to ensure prompt healing, but low enough to prevent the loss of consciousness when attacked.

Hyperbole and a Half

‘To the pain’ also becomes a viable solution for non-lethal intra-species disputes, opening up feature creep possibilities like fighting for food and mating rights.

This does lead to an odd situation, though. If creature’s sleep to heal, they will empty their energy bar. That energy bar is what they use to reproduce. Thus, it would probably be to their benefit NOT to sleep, and just act like baby factories, eating food and immediately converting it to babies in order to maximise production and put out hunnards o babbies.

The obvious solution is to treat ‘energy’ the way it was originally supposed to be treated: as a measure of the amount of undigested food in their stomach. I don’t intend to use it *quite* like this just yet: I still intend to take some metabolic and walking energy requirements from it. But moving the reproduction energy requirement to health seems like a good idea: eat, sleep, digest, THEN make baby.

Which in turn leads to another odd situation. Pain is triggered by rapid drops of health. Giving birth takes quite a bit of energy from health in an instant. Did I just accidentally a pain of childbirth?

That’s… actually pretty cool. Or possibly cruel, I often get those two mixed up.

That said, the instant energy drop is a bit absurd: it triggers just as much pain as being slaughtered by a malevolent god (as determined by statistically significant testing). Well, I can at least reduce that by making the energy drop over a certain period of time, rather than- I just did it again, didn’t I?

So, um… pregnancy! That’s a thing now.
I think I need to repeat myself here:

“It’s fascinating how one thing in development leads to another, which leads to another, which in turn means a major change in gameplay.”

I am so glad I finally got around to upgrading the AI.


Since I wrote this post, it just. kept. happening. Moving reproduction loss to health had side effects, and I’ve had to keep making changes so that creatures could remain capable of reproduction without killing themselves in the process. The pain value is looking more and more like “exhaustion” and may have to be renamed, creature’s are deciding of their own volition not to reproduce in uncomfortable zones, a starving creature actually falls unconscious shortly before dying, and NONE OF THIS WAS PLANNED.

I had planned to liken this to how Dr Frankenstein must have felt when he lost control of his monster, but frankly I’ve lost control of creations and accidentally set them loose on innocent townspeople before, and this feels different. Less frantic somehow. Maybe it’s the lack of lightning.

  1. #1 by Evan on October 23, 2014 - 8:34 am

    Hey, could pregnancy cost time, rather than energy? Or lower amounts of energy for a period of time, ie: term of pregnancy? Would that alleviate some of the issue?

  2. #2 by richard on October 23, 2014 - 5:20 pm

    Great idea. Pain is such a necessary attribute, it just gets overlooked as a negative all the time. Love the princess bride reference you sneaked in too.

  3. #3 by Ehud on October 25, 2014 - 6:27 pm

    I’m very interested in your advancements on pregnancy. The amount of time, energy and health required to give birth to a more or less developed offspring, or more or less offspring at a time, (and depending how deep you want to delve into that it could obviously take insane amounts of fascinating and difficult balance) further simulating R and K strategies. Big fan of your work on this! I check it out every now and then.

  4. #4 by M.A. on October 26, 2014 - 4:41 pm

    Hm… I’m am not sure if I missed this one, but is there an connection between Energy and Health as in:
    Energy-loss-per-time that is increased by low (procentual) health?

    There are then 2 competitive strategies: Rest to heal fast and have (maybe) a low overall loss of energy, with the risk of got eaten during sleep, or heal very slow and destroy food ressources. Then the pain meter (multiplier) is optimized to favor the one or the other strategy.

  5. #5 by Ekolu on October 30, 2014 - 12:37 pm

    Why not have pain contribute to fear. Fear would be a secondary stat and expanded to be influenced by hunger, amorousness, diet, and stamina. Amorousness could also double as pack behavior stat. Doing this might give you a chance to expand THAT further into a rudimentary herd behavior and give our machines a much needed break by making decisions for groups of animals instead of individuals. In this way we might get some great combinations of lifeforms to make our sandboxes that much more realistic and smooth running!

    Personally id like to see sexes and sexual dimorphism but for right now this game is outstanding. This is the game I wanted when I bought Spore.

  6. #6 by ququasar on October 30, 2014 - 1:50 pm

    Evan: Currently, pregnancy doesn’t actually cost anything: 100% of the energy taken from the parent goes to the child’s starting health, so we can’t actually make it cost less except by giving the baby less energy. You know it’s a geeky game when it rigidly obeys the conservation of energy. 🙂

    Ehud: Even with the upgrade it’s still a very simplistic model at the moment (just subtracting energy over time, rather than all at once) but even so, there’s likely to be some interesting side effects. A pregnancy rapidly reduces health, which makes creatures prioritise hunger and sleep. Creatures with slower pregnancy terms will have more time with low hunger and pain, which will logically see them spending more time seeking mates and travelling to more temperate area’s.

    M.A: I’m not sure it’ll be that exact relationship (I’m moving metabolism and climate loss to health, since otherwise the creatures spend all their time seeking food), but I’m hoping to make it so that *every* stat has both advantages and disadvantages. A balance is far more interesting than simply selecting for the highest value.

    In the case of pain, there’s likely to be a balance between losing consiousness too easily (bad idea to be knocked out with the first hit), vs not losing consiousness rapidly enough (need to sleep some time).

    Ekolu: Fear is specifically tied to the “flee” behavior, so it would cause unusual behavior to have hunger or stamina influence it. It is likely to be triggered by similar things to pain, though: in it’s current incarnation, fleeing followed by sleeping (to heal injuries) is likely to be a common sequence of events.

    It does feel weird to call the sleep-causing emotion “Pain”, though. It really is much closer to exhaustion or tiredness. I may have to simply creating a purely cosmetic stat called “pain”, simply so I can say we’ve got one.

    About herd behavior: I may end up implementing a sort of herd behavior in a future update via a social system, where one creature calls for the help of others and other creature’s respond based on their personality, but it would exist strictly at a personal level. I won’t implement a system that makes decisions on behalf of creatures: I want creatures to always act on an individual level.

  7. #7 by Secale on November 6, 2014 - 9:25 pm

    Interesting stuff, I’m pretty excited to see what kind of behaviors/phenotypes the new AI will lead to. It’s also fun to see emergent properties like pregnancy turn up. I also love that you’re making every stat have advantages and disadvantages,

    What determines when a creature is afraid? Or what it is afraid of? Does fear apply to any other creature, or just ones with certain stats, like high attack or big claws or something?

    A lot of the community seem obsessed with evolving carnivores, but I’m wondering if the new AI could lead to scavengers. Fast small creatures with low attack but high Fear tolerance so they can lurk around predators and eat their kills. (If there is ever enough individuals in a sim for something like that to turn up of-course)

    On the other end of things, what makes a creature select a particular prey to attack? Will predators always attack self, or can they evolve to not attack creatures with certain phenotypes? Could we then have a herbivore that avoids predation by looking like a predator. Or, linking in with the fear thing, a herbivore that scares away competition by looking scary?

  1. AI Rework – EmotionSelector | Species Development Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: