Author Topic: Starvation  (Read 1651 times)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Starvation
« on: November 11, 2005, 10:12:14 PM »
First, your total food production must be calculated so it can be added to your total food supply. For each building you own, it's food production is added to a running total. (Note that it is possible for a building other than an agridome to have food production here. The game just doesn't have any other buildings that produce food).

Once the food production is calculated, it is added to the total food stored. Then the game calculates how much food your colony will eat.

The amount of food each colonist eats depends on how many colonists you have.
Code: [Select]
If totalPopulation > 9 then populationFoodMultiplier = 9
otherwise
Code: [Select]
populationFoodMultiplier = 10
(the default value)

Then the amount of food required is calculated.
Code: [Select]
amountFoodRequired = (totalPopulation * populationFoodMultiplier) / 10

So under normal circumstances (totalPopulation > 9) each colonist eats one units of food. Otherwise, each colonist eats 9/10 of a unit of food. (Always round down after the division). If amountFoodRequired is greater than your new amount of food stored, then people will starve.

The amountFoodRequired is not the amount taken from storage however. Your newFoodStored is decreased by totalPopulation, provided you have that much food, otherwise it is decreased by the newFoodStored (to 0). In other words, the amount of food required to prevent starvation is less than the amount of food your colonists will actually eat, if it is available. This is done after the starvation conditions are checked for.


Now, provided starvation is occuring, this is how it's done.

(This part has no effect on the starvation code, but is done anyways. The amount of food you fall short by is calculated:
Code: [Select]
foodDeficit = amountFoodRequired - newFoodStored
)

Code: [Select]
If totalPopulation < 4 then numPeopleToStarve = 1
If totalPopulation >= 4 then numPeopleToStarve = (amountFoodRequired - newFoodStored) / 2
(If for some reason the number of people starving is negative, which should never happen, then add 1 before dividing by 2. Also, note that newFoodStored is oldFoodStored + totalFoodProduction, and does not include the amount subtracted from what people eat during this round).

Now that we know how many people will starve on this round, we need to select which types of people we will starve (kids, workers, scientists). For this we use a variable stored in the Player class, which I shall refer to as starvationCase. Each time someone is starved to death, starvationCase is incremented modulo 5. (It will have a value from 0-4). (If for some reason it's value is outside this range, it's value will be incremented and then taken modulo 5, and execution will continue normally).

As a quick check, if numPeopleToStarve > totalPopulation then numPeopleToStarve = totalPopulation. The game will then kill people off in a certain sequence until numPeopleToStarve have died. The game will cycle through the population classes in the following order: kid, scientist, scientist, worker, kid. This is based on the value of starvationCase. If starvationCase = 0, 4 then a kid is starved. If starvationCase = 1, 2 then a scientists is starved. If starvationCase = 3 then a worker is starved. Hence the cycle of 5 classes given above. If there is no colonists left in that class of colonists when it comes time to starve one, then it is skipped over and starvation continues in the next class.

Example: If 3 people were to starve in one round. And then 7 people were to starve in the next round, they would starve in the following order:
1st round: kid, scientist, scientist (1 kid, 2 scientists have died)
2nd round: worker, kid, (restart cycle here) kid, scientist, scientists, worker, kid (3 kids, 2 workers, 2 scientists have died)

Example: If there are no workers still alive, and 6 people need to be starved, it's done in the following way:
kid, scientist, scientist, (worker is skipped over) kid, kid, scientist (3 kids, 3 scientists have died)



It's kind of amusing to think how morbidly "fair" or "efficient" this game is at killing people off. Everyone gets their turn.  :ph34r: Even if starvation occurs 1000 time marks apart, the game won't have forgotten whose turn it was.  :ph34r:
« Last Edit: November 11, 2005, 10:17:35 PM by Hooman »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Starvation
« Reply #1 on: November 12, 2005, 09:29:43 PM »
This somehow reminds me of Wizard of Oz with everybody singing about murder.
Side note: I hear the witch got 3rd degree burns from the special effects.

Whoever was in charge of starvation must have really hated kids and scientists.
Well, good job I suppose.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Betaray

  • Administrator
  • Hero Member
  • *****
  • Posts: 2897
Starvation
« Reply #2 on: November 12, 2005, 10:37:32 PM »
achelly it reminds me of nazis lol

systamaticly efficant in their killing

I just got done watching Schlindlers List in school lol
I am the nincompoop, I eat atomic bombs for breakfest, fusion bombs for lunch, and anti-matter bombs for dinner

I just hope they don't explode

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Starvation
« Reply #3 on: November 13, 2005, 05:41:39 PM »
Quote
Whoever was in charge of starvation must have really hated kids and scientists.
Probably some disgruntled code monkey.  :P


Probably not incredibly useful info here, but I'd always wondered about the order in which people starve, and why your whole colony doesn't all starve at once. That and it was related to morale, which I have yet to finish posting on. After the colonists starve to death, it of course updates event morale based on how those deaths are supposed to affect it.