Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Realistic population dynamics  (Read 1118 times)

Andrew Ridgely

  • Escaped Lunatic
    • View Profile
Realistic population dynamics
« on: November 17, 2006, 01:14:00 pm »

It seems like a great deal of care has been placed into managing the number of dwarfs that immigrate to a fortress based on food, mined tiles, etc. Currently however, pet and livestock populations grow slightly faster than exponentially until they hit a ceiling, at which they stop breeding. These dynamics can be troublesome, as evidenced by the recent slowing of pet growth rate to prevent early forts from having war dog plethoras. I'd like to propose a solution to the growth rate of pets and livestock that I think is both realistic and fun for the player.

I'd like to use dogs as an example here, without loss of generality.

Current dynamics are similar to the following curve: dogs increase somewhat exponentially, as more dogs means more breeding pairs which means even more dogs.
   
Slowing the breeding rate of dogs (by increasing time to maturation) slows this exponential growth, but does not change the basic shape of the curve. More dogs still means faster growth, until the ceiling is reached.

Many dynamical models exist for describing the growth rate of populations with a finite resource, including the logistic model, the Ricker model, and the Beverton-Holt model. It is this third I'd like to focus on because it precludes the possible oscillating and chaotic dynamics of the other two (see May and Oster's papers if interested).
   
The Beverton-Holt model in its simplest form describes population growth as:

N(t+1) = rN(t) / (1 + [r-1]N(t)/k),

where N is the population size, r is the growth rate when the population is infinitessimally small, and k is the carrying capacity (most dogs allowed).

These curves apply for semalparous organisms (those that die immediately following reproduction). Dogs are iteroparous, surviving to reproduce multiple times, but although this makes analysis complicated it does not affect the ability to use Beverton-Holt dynamics in the game. To do so is computationally inexpensive as well. When two dogs conceive, simple apply the following probability to decide whether or not they create a puppy:

1 / (1 + [r-1]N(t) / k).

Here the quantity [r-1] should be greater than zero and less than one (the smaller it is the slower the population will grow), N(t) should be the current dog population size (this can consist of only adults, only reproductive females, or, as would likely make most sense, all dogs including puppies), and k should be the limit of the population size. In psuedocode:

[CODE]
function breed
   while(mom = get.next.breeding.female && dad = get.random.breeding.male)
      if (rand(0,1) < 1 / (1 + rate * pop_size / max_pop_size) )
         create.puppy
      end
   end
endfunction
[\CODE]

To make the game interesting, k can be scaled with the amount of available food or the number of dwarfs. Or if dogs are perfectly capable of sustaining themselves with whatever they find, a cap of say 200 can be applied from the beginning of the game.

[ November 17, 2006: Message edited by: Andrew Ridgely ]

Logged

Maximus

  • Bay Watcher
    • View Profile
Re: Realistic population dynamics
« Reply #1 on: November 17, 2006, 02:19:00 pm »

The "new" curve you propose is barely different from the old one: breeding slows down a bit above 150 dogs, but otherwise it's the same.

I think realistic husbandry will come in combination with animals that actually consume food -- and dogs should eat meat only, which is not always easy to procure.

Logged

Andrew Ridgely

  • Escaped Lunatic
    • View Profile
Re: Realistic population dynamics
« Reply #2 on: November 17, 2006, 02:28:00 pm »

It's supposed to be the same at low population sizes, when resources become more scarce breeding slows down. That's the new addition I'm proposing. For slower growth rates, the flattening is more pronounced. Compare the two green curves especially.

The advantage this has over modeling specific husbandry and so forth is that it is a one-line addition to the code of the game.

Logged

qalnor

  • Bay Watcher
    • View Profile
Re: Realistic population dynamics
« Reply #3 on: November 17, 2006, 02:31:00 pm »

quote:
Originally posted by Maximus:
<STRONG>actually consume food -- and dogs should eat meat only, which is not always easy to procure.</STRONG>

Absolutely. While this idea is interesting, the shape of the curve is only minimally different, and also there is no reason that population growth shouldn't be exponential.

Availability of food is the only thing which prevents population growth from being exponential.

Logged

Andrew Ridgely

  • Escaped Lunatic
    • View Profile
Re: Realistic population dynamics
« Reply #4 on: November 17, 2006, 02:45:00 pm »

I should also add that there are reasons to suggest dogs don't require meat (from dwarven stockpiles) to survive: they can catch their own rodent prey, they can eat scraps, gnaw bones, etc. Dogs are rather omnivorous. A model incorporating food-limited population growth based on the level of scavengable resources, dwarven food donations, and dog hunger levels is nice but much more ambitious than what I'm proposing.

I also do think there are real qualitative differences between the curve I'm suggesting and simple exponential growth, especially when iteroparity is taken into account.

Logged

Rooster

  • Bay Watcher
  • For Chaos!!!
    • View Profile
Re: Realistic population dynamics
« Reply #5 on: November 17, 2006, 03:19:00 pm »

I quess you have forgotten about the possible food chain. Dogs SHOULD breed in such speed but ONLY if a lot of them dies. Also dogs shouldn't breed with their offspring ,beacause its unnatural.

few examples what might kill a livestock animal:
Dragon or other ultra-mighty beasts
sieges
crazy dwarfs
lava,steam,flood
ambushes
bucher

i guess there are alot of ways to die in DF

Logged

Maximus

  • Bay Watcher
    • View Profile
Re: Realistic population dynamics
« Reply #6 on: November 17, 2006, 07:49:00 pm »

Well, eventually dogs and livestock ought to be changed so that they're not auto-generating maintenance-free food/defense -- regardless of what the curve looks like.  

Toady has not shied away from realism or detail in any aspect of the game, and having to feed animals would put a nice realistic constraint on populations, and add an interesting layer of gameplay.  It's not a one-line change, but given the kind of game Toady has created, I do expect him to implement something along these lines at some point.

Edit: Oh:

# Bloat247, HERBIVORES AND LIVESTOCK AND SO ON, (Future): Herbivores should be able to eat grass outside, people can bring livestock, not as pets...

[ November 17, 2006: Message edited by: Maximus ]

Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Realistic population dynamics
« Reply #7 on: November 17, 2006, 07:53:00 pm »

Pets used to eat.  It made them worthless.  If it goes back in, there has to be more meat.  Dogs ate bones and it didn't help much.  The livestock also ate plump helmets instead of grazing.  I'd like them to eat, but there need to be a lot of changes.  If dogs also ate chunks it might help enough.  I'd rather add more game elements than model it.
Logged
The Toad, a Natural Resource:  Preserve yours today!

Maximus

  • Bay Watcher
    • View Profile
Re: Realistic population dynamics
« Reply #8 on: November 18, 2006, 03:39:00 am »

Dogs could eat less often than dwarves, which would keep you from having to inflate meat stores.  Having them eat chunks is a great idea.  Seeing them swarm around a battle or the butcher's shop... what an image.  In ascii.

It's not that hard to produce lots of meat from horses.  That would change when they start eating again, too.  But I wouldn't mind feeding them crops; once you get the hang of it, you can produce a huge surplus of food.  But they should graze as well.

If you can get the dynamics tweaked right, actively tending animals sounds like a fun additional challenge.

Did I just say "inflate meat"?   :eek:

Logged

20,000leeks

  • Bay Watcher
    • View Profile
Re: Realistic population dynamics
« Reply #9 on: November 18, 2006, 04:24:00 am »

The problem at the moment is that even early on the fortress, animal population can become a serious problem. Animals get in the way, they follow their owners around, and unless you have two or more butcheries churning out foodstuffs day and night, you can't really make an impact on this. And then you have to deal with byproducts, like fat (which is all well and good, but I end up trading most of my fat to the caravans, since you can't process *that* fast enough and it takes up an awful lot of space).

Having pets eat could clear up both of these problems. Fat could be made into low-grade pet-food (not exactly healthy, but I have my doubts about the nutrition of some modern pet foods), possibly through a special job at the kennels, or a workshop all on its own. This way, to get a large population of wardogs, you have to have the infrastructure to support them. Plus it limits the number of wardogs you can support, since you have to have at least some livestock (cows that exist on grass, or special cave-grass or something like that) to feed them. Since this also requires at least some infrastructure, you can't use dogs as cheap mid-game defenses.

Logged

Disruptive Idiot

  • Bay Watcher
    • View Profile
    • http://www.relicnews.com
Re: Realistic population dynamics
« Reply #10 on: November 18, 2006, 09:48:00 am »

Having pets hunt for their food (cats and dogs)and grazing animals actually graze outside would simplify things. More vermin would probably be needed to sustain the cats and dogs.

When your pet population is too big to be supported by vermin, creating pet food out of chunks and bones would be pretty useful. By then you'll be able to support such a system.

Logged

Angela Christine

  • Bay Watcher
    • View Profile
Re: Realistic population dynamics
« Reply #11 on: November 18, 2006, 01:18:00 pm »

Hmm, maybe you could use the designation menu to designate an outdoor area for animal foraging, and animals would be attracted to it?  Like a meeting hall, but for animals.  Animals roaming in the forage area would manage to kill/eat any bushes they walked across, and occasionally might even kill saplings (stripping the leaves, peeling off and eating the bark, etc.)  That way when you set an area for for grazing it isn't "free" you are losing some of the potential lumber and wild strawberries you could have harvested.  Ideally the grazing areas would be surrounded by a coral, but it's ok if the animals "just know" where they are supposed to go.  Starving animals would be less likely to respect the restrictions, and might break out into the area set aside as a wilderness preserve, or even start stealing food from the food and refuse stockpiles.


Perhaps animals could also be given differing levels of loyalty, attention, or neediness.  Sure, a pet dog will follow you around all day long, but a pet cat is likely to just check on you occasionally and then go do his own thing or take a nap.  Sometimes they follow their dwarf, sometimes they wander aimlessly or go outside, and sometimes they go back to their owner's room, if he has his own room.  

"Follow owner" could be a job, like other jobs.  If a pet is doing Follow Owner and he encounters an obstacle like a tightly closed door, he won't just stand by the door flashing a blue ? forever, waiting for the door to open or the owner to return.  Eventually he'll move on to another job like like "wander around" "lick genitals" "hunt vermin" "eat" "go outside" or "go home".

Logged

Maximus

  • Bay Watcher
    • View Profile
Re: Realistic population dynamics
« Reply #12 on: November 18, 2006, 05:42:00 pm »

I like having animals follow their owners/assignees -- what I don't like is that the pets often insist on being in the same square as them, slowing down their work.  At some point I'd like to be able to change who a work animal is assigned to as well (but obviously not for pets).

There's several good solutions for large pet population congestion: wide corridors (50 dogs squeezing through a 1-by is a disaster); cages (perfect for horses and cows... although "stables" should eventually replace them); and just keeping them outside (which will probably be the norm when grazing goes in).

"lick genitals"... lol.

Logged