Simulation games are hierarchies of interconnected systems. I need to identify the best practices for how to design and build simulations composed of multiple systems.
Example Systems
The passage of time. Night/Day cycle. Time sensitive opportunities and consequences. Aging and decay.
Weather: Wind, Clouds, Rain, Heat, Cold
Towns: Market Places, Educational Systems, Judicial Systems
Agent Autonomy
What is a system?
A system is the sum of its parts.
A human system has a purpose.
A mechanical, informational, or social system has a function.
Systems have inputs and outputs.
Complex systems have emergent behavior.
System Architecture Needs
Cyclical looping of systems providing feedback to each other.
Holistic monitoring of all systems.
Probably unnecessary, but it would be cool to structure the various systems using a node graph, where each system's parameters are exposed as fields on a visual node using DearPyGUI's Node editor. Each node could specify how many
ticks should go by for example for it to be evaluated.
System parameters should be in data files not code. Ideally, you should be able to force the engine to reload a systems
configuration files while a sim is running.
Performant systems. Everything needs to be able to operate at 32 FPS.
Consider that some systems could be evaluating faster than others. Dwarf Fortress takes this to the extreme.
"
What does the main game loop look like?
In dwarf mode, say. It starts with some announcement checks and considers autosaves, etc. A lot of the rest doesn't happen every tick. Every hundred ticks, for instance, it'll check job assignments and 'strange moods.' Armies are moved on the world map. Every hundred ticks (staggered from the job check), it handles job applications by dwarves, a kind of invisible auction that it uses to manage the various competing priorities. Every ten ticks it advances the seasons, which actually does all kinds of things with the weather and map (both locally and in the world), and it also does a check for certain plot element advances (diplomats, sieges, etc.), and it checks whether your fort is still alive.
Then it hits some things that it does every tick. Fluids and other map tile information is advanced (though there are various optimizations here so that not every tile is necessarily checked every turn, and there are various flags so that entire sections of the map can be skipped if nothing has happened.) Vermin running around are updated. Other 'events' on the map, like active fires, are handled.
If a flag is set, wounded/thirsty/hungry dwarves that can't care for themselves get an update, and every so often, dead dwarves 'think' about their burial arrangements so that jobs can be set. Caged and chained creatures update their thoughts and situation periodically.
Then creatures leave the map if they are set to at the edges.
Every fifty ticks, staggered from other updates, all of the taverns, temples, libraries, etc. get their information updated. Stockpiles, staggered on a different tick, also work this way. Similarly with storage job creation, though that process is complicated with various optimizations and lengthening ping times and so forth, and it's still slow, since at some point, 50000+ boulders will cause trouble.
Every thousand ticks, objects that have been marked for deletion and removed from the game are actually deleted and freed. This happens more often with items, every fifty ticks, along with a building use check (mostly updates for wells and some other flags that often need checking.)
We hit another every tick update at this point. Projectiles are moved. Activities (which range from dances to martial training to storytelling) get updated as needed. Dwarves and other creatures decide on and advance their immediate actions (movement to an adjacent tile, working at a workshop, etc.) -- the bulk of their AI (outside of job selection) is here.
Every hundred ticks, items are rotted. Every tick, vegetation is advanced (though there are various staggers and flags here.) Building states are updated every tick as needed, and minecarts are moved. Hauling routes are advanced. Temperature is updated (there are various optimization flags here, but this is still an unfortunately slow process.)
Finally the camera is updated to follow the creature you are following, if any.
"
Simulation games are hierarchies of interconnected systems. I need to identify the best practices for how to design and build simulations composed of multiple systems.
Example Systems
What is a system?
System Architecture Needs
In dwarf mode, say. It starts with some announcement checks and considers autosaves, etc. A lot of the rest doesn't happen every tick. Every hundred ticks, for instance, it'll check job assignments and 'strange moods.' Armies are moved on the world map. Every hundred ticks (staggered from the job check), it handles job applications by dwarves, a kind of invisible auction that it uses to manage the various competing priorities. Every ten ticks it advances the seasons, which actually does all kinds of things with the weather and map (both locally and in the world), and it also does a check for certain plot element advances (diplomats, sieges, etc.), and it checks whether your fort is still alive.
Then it hits some things that it does every tick. Fluids and other map tile information is advanced (though there are various optimizations here so that not every tile is necessarily checked every turn, and there are various flags so that entire sections of the map can be skipped if nothing has happened.) Vermin running around are updated. Other 'events' on the map, like active fires, are handled.
If a flag is set, wounded/thirsty/hungry dwarves that can't care for themselves get an update, and every so often, dead dwarves 'think' about their burial arrangements so that jobs can be set. Caged and chained creatures update their thoughts and situation periodically.
Then creatures leave the map if they are set to at the edges.
Every fifty ticks, staggered from other updates, all of the taverns, temples, libraries, etc. get their information updated. Stockpiles, staggered on a different tick, also work this way. Similarly with storage job creation, though that process is complicated with various optimizations and lengthening ping times and so forth, and it's still slow, since at some point, 50000+ boulders will cause trouble.
Every thousand ticks, objects that have been marked for deletion and removed from the game are actually deleted and freed. This happens more often with items, every fifty ticks, along with a building use check (mostly updates for wells and some other flags that often need checking.)
We hit another every tick update at this point. Projectiles are moved. Activities (which range from dances to martial training to storytelling) get updated as needed. Dwarves and other creatures decide on and advance their immediate actions (movement to an adjacent tile, working at a workshop, etc.) -- the bulk of their AI (outside of job selection) is here.
Every hundred ticks, items are rotted. Every tick, vegetation is advanced (though there are various staggers and flags here.) Building states are updated every tick as needed, and minecarts are moved. Hauling routes are advanced. Temperature is updated (there are various optimization flags here, but this is still an unfortunately slow process.)
Finally the camera is updated to follow the creature you are following, if any. "