Mass simulation with statistical maps

Started by
8 comments, last by AngleWyrm 10 years, 7 months ago

I haven't played the last SimCity, but I remember from the old games (i.e. SimCity 2000) that you had these maps showing pollution, wealth, energy, water, etc. And I guess other games like GTA used the same technique. Now from a first person perspective, the entities that the player finds in the city will reflect the conditions given by these statistical maps. For example in a polluted zone there will be more garbage or fog in the streets, and a wealthy zone will have more luxury houses and cars. I'm exploring ways to use this concept to simulate a massive ecosystem. If there is a river and mountains in a map, the influence of water on vegetation could be mapped so that there will be higher tree densities. Then vegetation levels will influence density of herbivores. Now, resources are static and rather easy to map, but then vegetation could be harvested or catch fire, then it will be dynamic. And animals could migrate and increase/reduce population due to mating seasons and plagues. It's like a complex version of Conway's Game of Life, and not all "masses" have the same pattern. What techniques exist to process such system? What optimizations could be performed, having in mind that the system could have no constrains?

Advertisement


you had these maps showing pollution, wealth, energy, water, etc. And I guess other games like GTA used the same technique

GTA is more of an open world shooter. there's no real simulation going on behind the scenes, like in SIMCity, to generate the info displayed on the maps in SIMCity.


If there is a river and mountains in a map, the influence of water on vegetation could be mapped so that there will be higher tree densities. Then vegetation levels will influence density of herbivores. Now, resources are static and rather easy to map, but then vegetation could be harvested or catch fire, then it will be dynamic. And animals could migrate and increase/reduce population due to mating seasons and plagues. It's like a complex version of Conway's Game of Life, and not all "masses" have the same pattern. What techniques exist to process such system?

in the open world fps/ rpg / person sim i'm working on (CAVEMAN), elevations on the world map determine the path taken by flowing water during generation of the world map at new game start. vegetation is influenced by both elevation and water. resources are modeled, both animals and vegetation. so vegetation can come and go from harvesting, wild fires, and climate / environmental change. animals can be temporarily hunted out in a given area. and of course, it uses encounter tables based on terrain type, which models the influence of environment on what you find there in the way of critters.

no special techniques are used. world generation uses an "elevation splatting" technique. this elevation map then influences the generation of water on the map. water and elevation both influence the initial generation of vegetation coverage, which is generated next.

for resources, i give every 5x5 mile world map square 1000 resource points. harvesting resources or hunting animals in the map square reduces the resource points. resource points can be replenished when "the gods change the map" (see below).

at this time, the resources points in a map square do not influence the chance of encounters, until resources go to zero in the map square. then the chance of encounters goes to zero until "the gods change the map".

once per game day at midnight, the god change the map. this has a chance to replenish resource points, and models changes in water and vegetation based on climate conditions. so the weather engine and water table modeling controls the filling and drying out of creeks and waterholes etc. as the weather turns hot and dry or cold and wet, vegetation coverage can change. the general progress from cold/dry to hot/wet is: sand, dirt, scrub, prairie, tallgrass, savanna, woods, jungle. bands of cavemen come and go too, as do the animals occupying caves.

here are some other ways the world map in CAVEMAN influences the simulation:

the number and distance of hostile NPC bands determines the chance of your shelter being raided.

the number and distance of any NPC band determines resource point depletion due to nearby bands in the area. IE each band depletes resources in a given radius from their shelter.

there are probably others too that don't come to mind at the moment.

about the only thing that didn't run fast at first was changing the map. i was looping through 250,000 map squares for each type of change (such as prairie to tall grass). i switched to looping through the map once, and doing all the changes for a map square at once. ran so fast, i didn't even need to display a "The gods are changing the map..." message, which is what was done in the original version of the game (first written in 2000).

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php


What optimizations could be performed, having in mind that the system could have no constrains?

You could simulate every object, aka a squirrel eats a nut and there is one less nut in the forest, maybe a bird dies of starvations that would otherwise have eaten the nut.

In such a system it would be very easy to implement player-interaction thus making it a game.

If you want a better answer you 'll have to explain what you're trying to make, and where you get into trouble.


You could simulate every object

Actually what I want to achieve is the contrary to simulating entities, that is simulating a mass as a whole, and giving the player samples from that mass to fake entities. While in GTA this information is static, I still think the same technique can be applied dynamically. What you find in the city are samples of the conditions in a given zone.
When writing the original post I was thinking on pixel "clouds", that could for example represent the density of members in a flock in the map. In order to move the flock from one place to another, pixels could be moved from back to front of the cloud, which is determined by the direction That way the area/volume of the flock will be constant. Physics could be solved this way, for example if the flock enters a city, it could move thru the streets. Probably this is mostly related to fluid simulation. At the moment I'm not sure if it would be better to make it using pixels or using polygons. Pixel operations are easier to design and program but might be slower, while polygons could be more powerful to solve the simulation but the math could be quite challenging.

Looks like SimEarth, which is probably a graphically crude by computationally interesting version of what you're describing is up for download with a quick google search. Also, things like dwarf fortress sound right up your alley.

This is my second attempt to simulate masses, in Unity :) I started creating something similar to a Game of Life with different rules. But now I have to tweak the code to perform calculations on population densities, instead of two-state cells. The GoL is a cellular automation, but this will be a population automaton. Also, there will be map layers, and population will interact with other maps.

http://gamelix.com/demos/simulation/MassSim.unitypackage

MassSim.jpg

I have transformed the code to process on population densities. Previously it worked as a cellular automaton with two states, but now it's actually a calculating on float values as a population automaton. Also enhanced the grouping algorithm that defines the preference of a species to move together or individually. The patterns formed are pretty interesting. Here is a totally individual migration (grouping = 0f):
MassSim1.jpg
And here a grupal migration (grouping = 1f):
MassSim2.jpg
If someone is interested here is the new source code:
The grouping value can be changed at runtime (0..1) to see how the behavior of the population changes. This could help when simulating a situation in which a herd detects a predator, for example.

hey cronocr,

I really like where you're going with your project. I myself have been interested in the concept of employing a comprehensive simulation to manage NPC interaction, world population, and physical modelling, but the Math involved is way beyond me.

Do you have any links to to video game research relating to statistical maps, because most of the links found by Google are related to neuroscience?

Hi BarefootPhilosopher, cool name, I actually do philosophy myself :)

Well, in the past I have read a few artificial intelligence and robotics articles/books, and implemented my own algorithm finding ordered paths to wire protoboards with electronic components in place. Now I quickly searched for mass simulation algorithms too but couldn't find anything useful, just like you did. So I'm just programming everything that I need, learning and creating tools from this experience. This resulted to be similar to image processing, on which I experimented several years ago (from CGA/EGA days to DX/OGL).

My inspiration is based on how "species" are controlled in a game like GTA, which is static, and trying to make it as massive and dynamic as a sim game. I have this moving image of how water, garbage, vegetation, herbivores, predators, people, transit, clouds, etc. interact in realtime... living in a third world city surrounded by jungle this isn't difficult biggrin.png When the player navigates this world, the game instantiates agents of each "species" for his first person interaction. If the player follows an agent it will behave individually, and once he gets out of view the instance will disappear.

Feel free to tweak the code or come with your own methods. I would love to share ideas with others on how to achieve this simulation. I'll take my algorithm to the point that it roughly controls most behaviors and interactions, then I'll put it on hold for several months. My actual goal is not this system, since it is just a part of the communication layer, but I need to develop it because it will be a foundation for several mechanics of the option layer:

http://forum.unity3d.com/threads/181564-Gamelix-Advanced-Mechanics-Online-(GAMO)

Also, there will be map layers, and population will interact with other maps.

This provokes in my mind the idea of heat maps and hill climbing. There was a college paper on crowd movement modelling that used a score system for possible destinations. That score system was a three layer heat map of Distance, Time and Discomfort.

--"I'm not at home right now, but" = lights on, but no ones home

This topic is closed to new replies.

Advertisement