Variable interaction and game mechanic formulas (population growth)

Started by
7 comments, last by MasqCrew 3 years, 11 months ago

Greetings!

Game mechanics fascinate me, especially how one variable affects another one. Sometimes these are simple and abstract while other times they are complicated and nuanced. Collect a certain resource or resources and build a certain building—simple. Then on the other end of the spectrum you've got grand strategy games like Crusader Kings 2 where one decision might have an effect on several variables, no two play-throughs being exactly the same.

Then there are times when you don't know exactly what affects a game variable, at least not at first glance. For example, population growth in many city building games. First, there's housing capacity. People don't usually move in if there isn't a place to live. But then there's other factors, such as job availability, not to mention various things affecting birth and death rates.

Sometimes modifiers are added or subtracted, such as a plus one to HP for holding a wood shield. Other times they are multiplied or divided, creating a percentage adjustment, such as a 2% increase in production. A complex game might use a combination of all of them, along with other mechanics I'm not even considering.

A population formula, for example, might be as simple as the following pseudo code…

New_Population = Old_Population + Population_Growth

…where Population_Growth is a percentage. Could be positive or negative. Certain variables will increase population growth while others will have a negative effect. I've been racking my brain, trying to figure out how to combine all these various things into one easy formula. I think I have a solution. Let me know what you think.

Each variable which affects population growth will be in the range of -10 to 10, allowing easy conversion to a percentage. (-5 to 5 would also work, obviously)

For example, education gets a score of 5, the presence of a post office gets a score of 2, healthcare gets a score of -3, and various other things get their individual scores. In the end there are X number of things which affect population growth. Add up all the individual scores and divide by X to get an average. That average is converted to a percentage which is added to the previous population.

Making it an average allows me to add whatever I want to the game without throwing the other decisions off balance, at least I think so. I hope so.

All right. What do you think? What's your take?

(BTW, I'm thinking of creating a game in the form of a text/icon/button user interface where the player has tons of options, each decision potentially interacting with multiple aspects of game flow.)

Advertisement

MasqCrew said:
Each variable which affects population growth will be in the range of -10 to 10, allowing easy conversion to a percentage.

You seem to assume all variables have the same impact, which is generally not true. Having enough water is eg much more relevant than having enough food for survival.

You also seem to assume that all variables act independently, a pair of variables cannot re-inforce each other or cause a major disruption if they happen together.

MasqCrew said:
Making it an average allows me to add whatever I want to the game without throwing the other decisions off balance, at least I think so.

Checking such things can often by done by thinking what will happen if you take the idea to extremes. Here, let's say I have 5 variables, and all seems ok. Now I add 1000 more. What I think will happen is that you converge to an average of 0. Some are positive, some are negative, so they all cancel each other out mostly, and you get about nothing left. To reach an extreme, you need all variables to be highly positive or highly negative, and that happens less often if you have more variables.

Similarly, with 5 variables, if I add 1% to one variable, the result grows by 0.2% (1/5). In the case of 1005 variables, it grows by about 0.0009%, that is, practically nothing thus. To get 0.2% as average result, you need 201 variables to raise by 1 point (0.2 times 1005).

So I think gameplay gets “more average”, you can't get to high peaks and deep valleys any more.

Of course, in the end, it is all about what you aim to model, and how accurate you want it.

@Alberth , thanks for the critique. Some good nuggets to think about.

I can see how certain things are more important than others. Perhaps there are certain variables which are checked for a minimum value before population growth is calculated. A warning message could alert the player to a major issue, an issue which has halted all immigration and maybe even caused a major death spike.

In fact, separating birth rate and death rate from the population growth variable makes sense as well. People might move in at the same time as a ton of people are getting sick and dying. If a death event affects a certain percentage of the population, another alert is triggered, halting immigration.

Possibilities are endless.

You also seem to assume that all variables act independently, a pair of variables cannot re-inforce each other or cause a major disruption if they happen together.

Not sure what you mean by this. An example would help.

Checking such things can often by done by thinking what will happen if you take the idea to extremes.

I very much doubt there would be 1,000 variables … at least not in the final equation. There could be 10 (maybe 20), which could be manageable. At the start of a game, all variables could have the highest positive value, meaning that when you build a house at the beginning of the game, you get full population growth. As the population grows, however, variables would start to drop because it would be harder to maintain perfect balance. The strategy could be to keep things as positive as long as you can. Perhaps achieving a certain population by a certain time period is a winning condition. It would get hard near the end when the average is heading toward zero, but it would be fine as long as it wasn't impossible.

Besides, doubling your population when you are at 500 should be much easier than doubling it once you have a million people. Perhaps population growth is at least 1% as long as there are no alerts. So, even if pop growth is calculated at zero, some people are still trickling in. 1% of a million is 10,000 which isn't too shabby, especially if you can maintain at least zero. A negative number might cut that 1% down even further.

Of course, in the end, it is all about what you aim to model, and how accurate you want it.

Frankly, I'm not sure what I'm modeling. Definitely not so realistic that I would need a statistics degree to even play it, much less design it. It's more of a fun problem to think about.

I do know that I don't want population (among other aspects) to be a simple calculation. If you build a house, they will come. You might also need to build a school and a hospital. Or, you might not be able to build both a school and a hospital, so you would need to decide which. Is population your main goal at that point or are you concerned about a different aspect? Depends on possible win conditions and which one or ones you are reaching for.

Don't know if that helps, i just throw it in.

A real world population size depends on environmental suitability and adaptation (aka niche, imagine selection/adaptation), that it is genetically intact (enough individuals, not to much genetic drift, imagine island population) , nutrient availability and that the products as well as the inputs of the metabolism are somehow repurposed (imagine a space station where individuals are isolated and must be externally cared for. Closed circles don't exist.).

If that fundament works for a few generations, more abstract social constructs, societies, division of work, etc. can emergy from it …

Would be cool to model that. Has anybody seriously tried so yet ? An underlying physics layer that replicates the fundamental processes, and without them working the simulation collapses. Space games got a push recently with the introduction of newtonian physics, society sims could be similarly secularized :-), but it's much more complicated …

Green_Baron said:

Don't know if that helps, i just throw it in.

No, not so much. #sarcasm

I would have little clue how to brainstorm such systems, much less code calculations for them. I'm amazed by mathematicians on YouTube as they explain their stuff. I'm stuck with basic arithmetic for the most part. I was decent at algebra and geometry, but not enough to code a game. I would need to read lots of tutorials.

Adaptability is an interesting mechanic. Lots of ways to tackle this. For example, if the game monitored education levels closely enough, a citizen might not be able to find a job after their factory shut down because there are no jobs at their skill level. Kind of like in City Skylines when skilled laborers have to work unskilled jobs … but in reverse. In that scenario, you might even lose part of your population if they moved elsewhere where unskilled jobs could be had. Or that scenario added to a homeless variable.

MasqCrew said:
Not sure what you mean by this. An example would help.

The current Corona crisis is an example. For simplicity, you have amount of healthcare, and speed of response. Countries with good healthcare and with fast response have (relatively) little trouble, countries with one of them bad do have trouble, but manageable (for as far as you can say that, still a lot of dead people). Countries with both bad healthcare and slow response end up in a nightmare (unfortunately).

So optimal healthcare and fast response is very good, one bad parameter means the healthcare system can manage, two bad parameters is PANIC!

Computationally you can model such behaviour not by adding parameters, which gives you linear growth (x + y), but by multiplying them (x times y) or worse, like 2^(x + y). Such factors grow much much faster.

[The example isn't entirely fair, the disease grows so fast in size, that amount of healthcare is insufficient pretty soon anyway, speed of response is mostly what counts here]

MasqCrew said:
I very much doubt there would be 1,000 variables … at least not in the final equation.

I fully agree. The point is not to have that many variables, but to check whether your claim is true.

If the claim holds, it should work under any number of parameters, shouldn't it?? Thus, also if I would add an insane amount of them. Deficiences in the system are notable most strongly in such an extreme situation, so if you do such an experiment by thinking what would happen and fail to find deficiencies, you can be reasonably sure the claim has no obvious flaws.

If you find flaws in the extreme situation, the same defiences are also present in the system if you have less parameters, but they are less obvious to find and may get over-looked.

MasqCrew said:
I do know that I don't want population (among other aspects) to be a simple calculation. If you build a house, they will come. You might also need to build a school and a hospital. Or, you might not be able to build both a school and a hospital, so you would need to decide which. Is population your main goal at that point or are you concerned about a different aspect? Depends on possible win conditions and which one or ones you are reaching for

Early simcity games have very simple models, you have houses, factories, and shops, and they all need the other two. Roads create connectivity. Busy roads are less connective, high population gives more crime, people don't like crime.

All these values are simulated, and dance around each other, trying to find the optimal point. You may want to have a look at MicroPolis, the open-sourced version of the first simcity game (except for the aircraft crash into a building, which is understandable why they removed it, but still a pity not to keep it original).

You can create complex behavior with very simple equations. For example, swarms of fish in the ocean, or a flock of birds in the air. https://en.wikipedia.org/wiki/Swarm_behaviour

@MasqCrew It's hard to give advice about what specific population models and rules would be suitable for your game, but there are general techniques to design them:

  • Formulas are for the computer and therefore in the “complex simulation” genre they don't need to be simple, at all. For the players, what is important is seeing consistent and realistic consequences for their decisions, not being able to predict exactly future outcomes like in simpler games (e.g. planning a few moves ahead in chess).
  • Design rules iteratively, starting from simple ones, playtesting, and figuring out what refinements would improve the game (satisfying expectations, increasing consistency and realism, making strategy more or less subtle, etc.)
  • Population, like similar aggregate and abstract data, is going to be important in your game only if it has consequences (for example, the player might win if the city increases its population for ten consecutive years, the city could be erased from existence if population falls below a certain threshold, population increases might trigger events like new business opening…).
    The “real” simulation level is that of individual citizens, houses, jobs, objects etc. and what happens to them, reasoning about population is a way to abstract and simplify reality.

Omae Wa Mou Shindeiru

LorenzoGatti said:
Design rules iteratively, starting from simple ones, playtesting, and figuring out what refinements would improve the game (satisfying expectations, increasing consistency and realism, making strategy more or less subtle, etc.)

Seems like a no-brainer, but it's a good reminder. I'm not a world class programmer. The opposite, in fact. I started with playing around with two Javascript arrays, simulating a simple population growth. 20 new people move in each year, ages 1 to 50. Population grows until 99-year-old people start dying off. Then population fluctuates around 1,500.

https://masqcrew.github.io/ages.html

The second line consists of the number of citizen of each age. Population is a sum of that array.

LorenzoGatti said:
Formulas are for the computer and therefore in the “complex simulation” genre they don't need to be simple, at all. For the players, what is important is seeing consistent and realistic consequences for their decisions, not being able to predict exactly future outcomes like in simpler games (e.g. planning a few moves ahead in chess).

They do have to be simple enough for me to understand, but yes, I get your meaning. I do think players like a challenge, trying to understand complex mechanics. I get that after watching a few videos about grand strategy games like CK2 or EU4. But in some ways, the formulas for those games aren't super complex—there's just a ton of them. Hard to keep track of everything going on.

LorenzoGatti said:
Population, like similar aggregate and abstract data, is going to be important in your game only if it has consequences (for example, the player might win if the city increases its population for ten consecutive years, the city could be erased from existence if population falls below a certain threshold, population increases might trigger events like new business opening…).

Either win conditions or game objectives. How many things can the player accomplish in X number of years? The more variety, the more likely replay-ability happens.

LorenzoGatti said:
The “real” simulation level is that of individual citizens, houses, jobs, objects etc. and what happens to them, reasoning about population is a way to abstract and simplify reality.

I'd love to simulate individual citizens, but like you said, I've got to start simple. Besides, simulating groups of different kinds of citizens is complex enough for me. A game with no graphics or very simple static graphics gives room for lots of complexity and nuance.

Thanks for the thoughtful reply.

This topic is closed to new replies.

Advertisement