Use Gillspie Algorithm to simulate NPC, faction, and monster activities when off-map. #27226
Labels
[C++]
Changes (can be) made in C++. Previously named `Code`
Character / World Generation
Issues and enhancements concerning stages of creating a character or a world
<Enhancement / Feature>
New features, or enhancements on existing
Map / Mapgen
Overmap, Mapgen, Map extras, Map display
NPC / Factions
NPCs, AI, Speech, Factions, Ownership
(P5 - Long-term)
Long-term WIP, may stay on the list for a while.
Is your feature request related to a problem? Please describe.
When the player travels into a new area, the state of that area is not modified based on the time since the cataclysm occurred. As such there is a strange player-centric effect that occurs where the world state near the player progresses differently than the state of the world elsewhere.
Describe the solution you'd like
When a new area is entered, or an area is re-entered after some amount of time has passed, run forward a very basic simulaion of the area based on populations of NPCs, animals, monsters, and resources.
This simulation can follow the Gillspie Algorithm, treating actors being modelled as particles with specified interactions and outcomes.
The key benefit of this algorithm is that when the interactions are infrequent enough, it is very efficient to calculate when the "next" interaction will occur and step time forward to that encounter. In the case of dda, the expectation is that encounters between NPCs and monsters (the primary actors) are actually fairly infrequent, and that large timespans can be processed with little computation occurring. A key part of this is that interactions that do not change the state of one of the involved actors are irrelevant and are not tracked.
Some example interactions:
NPC interacts with resources to restock their store of resources. This destroys resources and promotes the NPC to a "NPC with resources".
Over time, "NPCs with resources" decay to "NPCs without resources".
Over time, "NPCs without resources" decay to "Starving NPCs", and eventually die.
NPCs may interact with special resources to be promoted to "Well-equipped NPCs".
Membership in these various populations adjust the frequency and outcomes of subsequent interactions. NPCs with resources will tend to prioritize safety over resource acquisition and therefore interact less often with monsters. NPCs without resources gain an interaction with resources, but also have their rate of interaction with monsters increased. Well-equipped NPCs might have better rates of success in all of their interactions. Likely we will want a 2D matrix of "resources possessed" and "level of equipment/preparedness". Like with monsters, as time goes on, the survivors are the ones who have managed to survive and therefore the better equipped ones.
NPCs of all kinds can have one of several interactions with monsters:
NPC dies
Monster dies
NPC is wounded, monster dies
NPC escapes, monster is provoked (becomes a "wandering monster")
As outlined above, the rate of occurrence of these different interactions depend on the state of both interacting actors (the monster and the NPC).
Monster evolution is also modelled in that monsters can spontaneously change state.
Zombies evolve to stronger zombies, though the specific type is irrelevant.
Fungal and triffid monsters mostly multiply, though we may add other developments at some point.
Natural animals may multiply and may be harvested by NPCs or monsters. They may also be ignored.
Once this simulation has run its course, the resulting population and state data can be injected into overmap-scale generation to place actual entities representing the populations. (monster populations, resources, surviving NPCs, animal poplations)
The text was updated successfully, but these errors were encountered: