View Full Version : Simple formula to simulate complex real life situations
marcuslee
09-11-2010, 16:57
I had an idea a while back for a simulation game. The more I think about it, the bigger and more complicated the idea. That's okay because that's how I roll. Ha! :dance1:
I enjoyed playing the Sim City series. There are other simulation games that I enjoy as well. Currently I am playing a browser game through Facebook called Metropolis. It is similar to Sim City, though much simpler. Since I started playing that game, I've wanted to create my own city management game.
I think I have come up with a way of simulating the complexities of real life. I would like to know what you think. Let's take population as an example.
Here's the formula I've come up with:
population = former_population + births - deaths + move_ins - move_outs
Move_ins and move_outs are the changes in immigration. This formula is the easy part. Figuring out a way to calculate the number of births, for example, was a different matter all together. Here's what I have come up with:
birthrate = RNDF(low_birth, high_birth)
births = (birthrate/100) * former_population
The birth rate will be a random number between the lowest possible birth rate and the highest rate. This range will grow and shrink based upon the decisions you make in the game. There are four possible directions for the birth rate. Both the high rate as well as the low rate can go up or down. So, game decisions can narrow the birth rate, increase the overall birth rate or lower it based upon the playing style of the player.
For example, building a hospital can have a big impact on the number of successful pregnancies. Because of the range in the random birth rate formula, though, the change from the hospital won't necessarily be seen right away. The collective changes a player makes to the low and high birth rates will affect the number of births over time, which I believe mirrors real life pretty good.
What do you think?
Mark
Michael Hartlef
09-11-2010, 17:16
Good start Not only hospitals have impact on birthrates. Eductation, economy, environment. But the way you want to calculate it, is good.
Petr Schreiber
09-11-2010, 19:28
That sounds like a start of very interesting project!
I spent some time with game called "Mobility" (http://www.mobility-online.de/en/downloads/en_windows.html) (but it was more oriented on traffic), I like the sim games a lot.
What would be the purpose of the game - would it have some goal, or would it be played just for the sandbox pleasure of observing various consequences of the actions?
Petr
marcuslee
09-11-2010, 20:00
What would be the purpose of the game - would it have some goal, or would it be played just for the sandbox pleasure of observing various consequences of the actions?
From a design standpoint, I think it would be better to program the sandbox mode. Later having scenario challenges wouldn't be that much harder to put in, such as playing for a limited amount of time in order to achieve a certain stat.
There are also some other ideas that I am toying with. After I think about them some more, I will probably ask for input. Right now, in fact, I am working on a weather/event system for the game. There's no code yet ... just an idea.
The one problem I see with a sandbox mode is that some stats could get larger than a program can dimension for ... not sure how to limit that except for putting caps on the higher end so that population, money, etc ... don't reach the upper limit.
Mark
Petr Schreiber
09-11-2010, 20:17
Imagine how long the people on Earth are, and there is "just" 6 000 000 000 of them.
DWORD datatype can store values up to ~4 000 000 000, QUAD up to 9 * 10^18, which is enough I guess :) Then there is the extreme datatype EXT, which can store even more.
But the key is that the numbers will be most probably kept down by the simulation itself - too much people on too little space will decrease life quality and so on.
If you will setup the simulation well and set some natural border (as limited life compatible surface of simulated planet), the overflow problems could be avoided this design way.
Petr
I just watched this interesting video about game logic. It is part of course on Data Structures. But this lecture shows how very clever algorithms can be used for games like tic tac toe or chess. In this lecture he shows tic tac toe. It opened up new ways of looking at problems for me and might be of interest to others.
http://www.youtube.com/watch?v=Unh51VnD-hA&feature=channel
You can skip to the 3 minute mark to go to the start of the game logic part.
Michael Hartlef
10-11-2010, 00:32
If you will setup the simulation well and set some natural border (as limited life compatible surface of simulated planet), the overflow problems could be avoided this design way.
Petr
Yes, I think you should have city limits. That will be a natural border like Petr mentioned.
Btw. my wife loooooves these kind of games. So you will have a play tester right there.
marcuslee
10-11-2010, 01:16
Imagine how long the people on Earth are, and there is "just" 6 000 000 000 of them.
DWORD datatype can store values up to ~4 000 000 000, QUAD up to 9 * 10^18, which is enough I guess :) Then there is the extreme datatype EXT, which can store even more.
I guess I looked at the info on variables crossed eyed. I guess there won' be a problem, will there? Ha!
But the key is that the numbers will be most probably kept down by the simulation itself - too much people on too little space will decrease life quality and so on.
If you will setup the simulation well and set some natural border (as limited life compatible surface of simulated planet), the overflow problems could be avoided this design way.
My thoughts exactly!
A crowded city is an unhealthy city, which raises the death rate, which keeps the population at or below a certain level. If all else fails, do this:
'pseudo code
If Population >= MaxPopulation Then DeathRate += SomeVeryHighNumber
Or have a natural disaster triggered which kills X number of people. The possibilities are endless, I suppose.
Mark
marcuslee
10-11-2010, 01:17
Btw. my wife loooooves these kind of games. So you will have a play tester right there.
Thanks. I bounce from one hobby to another pretty often, so I hope I get that far. The support here is wonderful, though. So, the fault will lie with me. None other.
Mark
marcuslee
10-11-2010, 01:21
I just watched this interesting video about game logic. It is part of course on Data Structures. But this lecture shows how very clever algorithms can be used for games like tic tac toe or chess. In this lecture he shows tic tac toe. It opened up new ways of looking at problems for me and might be of interest to others.
http://www.youtube.com/watch?v=Unh51VnD-hA&feature=channel
Thanks for this. I watched it all the way through instead of watching Law and Order. Now, I have to watch the other lessons.
I can see where a complicated game would have a pretty extensive game tree. The idea of pruning would be very important then.
Mark
Petr Schreiber
10-11-2010, 09:26
I learned the approach described on the video at university (one of the courses which made sense). If you'll need advice implementing it, I can be of help.
If you remember the Peg Solitaire game, the solver for it was one of the homeworks solved using graph algorithms.
Petr
marcuslee
10-11-2010, 17:45
I learned the approach described on the video at university (one of the courses which made sense). If you'll need advice implementing it, I can be of help.
Thanks. I don't know what help I will need, but I am sure you or some other super smart TB user will be of help.
I think I have read about other similar algorithms. I should learn a lot with this exercise. ;)
Mark
gungadout
11-11-2010, 07:44
Hi Mark,
A semi tongue in cheek look at your statement,
For example, building a hospital can have a big impact on the number of successful pregnancies.
Did you plan to include a positive correlation, or a negative one?:wink:
http://www.compleatmother.com/homebirth/hb_safety.htm
http://www.joyousbirth.info/homebirth-realities-research.html
http://books.google.com.au/books?id=zSl7VvHJIX4C&pg=PA355&lpg=PA355&dq=childbirth+deaths+hospitals+%22home+births%22&source=bl&ots=3ZLlsBhrMZ&sig=9PkMjO6_8DJE-cxHgN2rOUSSO2M&hl=en&ei=P4DbTIXqL4PyvQOG_fTZCQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBQQ6AEwADgK#v=onepage&q=childbirth%20deaths%20hospitals%20%22home%20births%22&f=false
All the best with your fascinating project.
Fun regards,
Peter H.
marcuslee
11-11-2010, 09:14
Hi Mark,
A semi tongue in cheek look at your statement,
Did you plan to include a positive correlation, or a negative one?:wink:
Thank you so much for the stats. Not exactly tongue in cheek, though, for I didn't take it with a grain of salt. :wink:
I think I would like to make this exercise as balanced and realistic as possible. The problem is ... stats can often be used to say whatever you want. I don't know for sure with infant mortality, but I do know something about death rates.
Some of the doctors with the highest death rate are some of the best doctors. Their death rates are high because they receive the worst patients, patients that would have died anyway, patients that other doctors won't touch with a ten foot pole. This fact is not usually stated in a general stat or if you want to make other doctors look better.
The same could be of hospitals and infant mortality. At home stats might look better because more serious cases are at the hospital. These cases would have been at home before a hospital was built, affecting the overall stats. It was not uncommon for a family a hundred years ago to have ten kids with only a few to survive. My guess is (without research) infant morality is down overall due to better health services and institutions.
In the end, though, doing things the modern way doesn't mean positives across the board. An interesting challenge with this exercise will be to capture negatives even with things that bring about positives most of the time, such as health, education, and technology.
Mark