- 8,311
- 10,287
That's not AI-type stuff, that's ecology. We had numerous talks with UO devs at Nevrax back when Ryzom was started about it. And the end was that it was a "Turing error" (it was Alan Turing who said something like "when I design a submarine, I don't look at fish biology", and yes, it was his analogy for computer stuff): to make a dynamic world, simulating an ecology isn't the correct answer. The ecology behaved exactly as would an ecology react when you introduce an invasive species of fast reproducing apex predators (the players): it collapsed.There was a post before from someone about UO. They had a nifty AI system or something but they had to scrap it because players would just camp a stage forever, never letting it expand.
If you want a dynamic world, you can use a fields system (that's a physics term: a "field" is an abstraction where you have a value at each point in the world). Take the dynamic orcs the devs have placed as an example.
Ok, first, your world has a population of 10,000 orcs. Not one more, not one less. An orc gets killed, 22mn later, it respawns. No more and no less. But it doesn't respawn at its "spawn point", because there's no such thing as a spawn point. That's where the fields come in.
Ok, your orc likes forests and camping roads to ambush travelers. So, you have a "Forested" field, whose value is equal to all the trees in the current square (you use a square mesh, to keep memory and calculations reasonable) plus all 8 adjacent squares. You also have a "Road" field, with max value on squares where there's a road, and a decreased value in adjacent squares, say 1/2, and a 1/4 on squares once removed, and so on. Those fields are static once the world is generated and change only if the world is altered by a Rallying Cry (or maybe a guild installs itself, build a road to the adjacent city and plants some trees?).
Your orc hates guards, so it has a field "Guarded", which is equal to the number of guards nearby. That's a dynamic field, since guards move, get killed, respawn, etc.
Your orc wants to rob travellers, so there's a field "Travels", which increases every time an humanoid NPC goes thru the square, and slowly decays.
Orcs hate get hunted, so there's another decaying field, "Orc kills", which increases every time you kill an orc nearby, and decays a bit more slowly than the travel one.
Finally, orcs have various degrees of gregarity. Orc Pawns, Scouts and Centurions have no problem being on their own, but an Orc Shaman would like to have at least one friend orc around, while the Orc Legionnaires needs 4-5 orcs to boss, and Emperor Crush never goes without 15 orcs retinue. So there's an "Orc presence" field.
You also add "Orcish Camps" whose presence orcs like (Orc camps put a bigger value than Orc outposts, and the Orc Army Camp that spawns during a Rallying Cry an ever bigger presence).
So, now, you have an Orc Legionnaire that was killed 22mn ago, and who respawns. What happens is that all those fields get combined to make a global field "orc legionnaire respawn", which combines the attractiveness of the area, the risks (guards and kills), the spoils (roads and travellers), the current orcish presence, plus a small random factor, and it gives the Orc Legionnaire a best location to spawn in. Pof, that's where the orc spawns (another Legionnaire spawning 1mn later might spawn close by - but it has a slightly different random perturb, plus things have changed, travellers moved, guards moves, so it could spawn somewhere else).
And you get real stuff. If you have adventurers going around and slaughtering orcs, the orcs are going to leave. Unless there's a lot of merchants travelling the road nearby, in which case the orcs are going to stay a bit longer.
That's a very simple process, it is resilient to player wanton destruction (all it makes is the orcs moving somewhere else), it has an hysteresis built in (once enough orcs have been displaced, the orc camp despawns because its own attractiveness has gone down enough, and without the camp, the orcs leave en masse). It reacts well to changing conditions (the evil minded guild plant copses of wood and create a road that NPC merchants will travel - poof, more orcs incursions around. Divert a stream, chases some guards from the farms close by, and an orc camp will surely get established soon).
And then, of course, there's the combat AI, which is entirely different.
- 1