Secret identities in Dwarf Fortress (2017)
ojs.aaai.org
ojs.aaai.org
Somewhere I saw a blog post about Prison Architect, a game inspired by and with similar mechanics to Dwarf Fortress, that described one aspect of the task system:
Instead of giving NPCs task lists, tasks are assigned to objects - say, a door that is not installed yet. The door would contain the instructions: "(1) move me to location [x,y] (2) install me at my current location", and idle NPCs would lookup objects with fitting tasks to their abilities/priorities and then execute the instructions.
But how to combine this with needs is unclear to me, I would love to see a good explanation of this. Here is the insane list of needs a Prison Architect NPC has: https://github.com/originalfoo/Prison-Architect-API/blob/mas..., and Prison Architect, while already displaying emergent behavior, seems to still only have a fraction of the detail and complexity and emergence that Dwarf Fortress has.
All the hype is about neural networks now, but these don't display this kind of emergent, social and constructive behavior, resource awareness and https://en.wikipedia.org/wiki/Homeostasis that these NPCs can.
A utility system is basically a codification of Maslow’s hierarchy: the system continuously re-evaluates possible behaviors’ utility functions and then chooses the top-scoring behavior.
Also, why games like Minecraft have not long implemented such smart and interesting NPCs yet!
Never underestimate how hard it is to create the game experience you want. There's a reason why a lot of NPC AI in videogames are dead simple: it's easy to implement, players easily interact with it, without being confused, it follows rules carefully crafted for the game experience, it's easy to debug and test etc. etc.
Also, how many games like rimworld, DF exist in 3D ? That's right, none that I know of. Making this kind of AI in a free 3D space becomes a whole other story. I think it works well with 2D minimalistic games, because the player uses its imagination a lot. In 3D you can't really leverage this. Anyways that's my 2 cents on why not every game implements it.
Most likely because actually implementing it is dead-simple, which is a major selling point of this technique. Short of adding it as a building block for non-coders in game engines such as Unreal, there is really no point in trying to prefab it. Most projects will be better served by just coding it in a way that is uniquely tailored to their needs and integrated with their game.
Noticing that an NPC has a work schedule requires that you stalk random NPCs all day. It works with the Sims, and similar games, because the game essentially forces you to watch them, and to be the stalker.
It's so hard to get players to notice the AI is doing anything that one technique is to make NPCs yell their decisions at the player. That's why enemies exclaim things like "grenade!" or "flank him!" in FPS games. They are trying to force you to notice the AI is doing something.
As with other creative communities there are some distinct threads, like some people are into very heavily survival focused, up-against-it packs, where e.g. gravity works properly, mobs understand the game rules and will climb up to get you, or set fires, they will upgrade their gear, etc. while people like me prefer ascend-to-godhood type gameplay where you quickly dispense with monsters and become untouchable not far into play.
In the latter style there's not a desire for "smart and interesting NPCs", in fact it's often played alone or in small groups, intentionally. In the former style the NPCs are somewhat smart, but they're a threat so if you make them too clever they'll just always kill the players which isn't much fun after a while.
I think NPCs with the type of independence of a Dwarf Fortress dwarf wouldn't be attractive to either of the sorts of player I mentioned, it may be that such people just don't play Minecraft. But it's also possible somebody has implemented it and I've never run into it. There are a lot of Minecraft mods. Curseforge lists literally thousands of them, there could be hundred like you describe and I wouldn't have noticed.
Packs might typically have a few hundred of those thousands, I might play four or five packs per year, but often the same mods recur because they're so useful or well-liked, like Just Enough Items gets used a lot, so does Refined Storage, but some weird dwarf intelligence mod could easily go under the radar not because people don't like it but because they didn't know it existed.
I reckon a lot of people had never really used Compact Machines for example until Compact Claustrophobia took off, and in that the machines are absolutely mandatory and you use them from the first minutes so you have to get very familiar with them.
Whereas I rather liked some bee stuff. Maybe not over and over again, but I played Valdan's Sky Bees a while back and I really enjoyed that again, with modern huge bees and so on.
The long answer is that the game is in a managed decline. The target audience is small children so anything not targeted to them doesn't get implemented. "Smart NPCs" isn't a feature like that, so there is zero chance of that being included into the game.
[0] four videos here https://www.youtube.com/watch?v=GK6Vr9mcgjM&list=PL8t707flkq... and playing through the mod/ tweaking as he went here https://www.youtube.com/playlist?list=PL8t707flkqpcAWeVeAUSh...
The end result? AI programmer resorted to state machines, because it was difficult to control character's behavior. For example, there were oscillating behaviors without any advancement on character's part. Team lead had to agree because there aas no budget to tune each character needs and actions to make game playable.
I think this anecdote can explain why objects, needs and actions are seldom used.
They are all tailored experiences to form what is known as the game.
A little more visibility into how all of this stuff works, and someone might be able to suggest that there's an algorithm that does this or that bit with a much lower order of complexity. A few of those and you can let a game run maybe twice as long.
Bear walks into tavern. Some panic, others are slower to react / notice. A very drunk dwarf might never notice, or offer a beer to the bear.
some inefficient ways off the top of my head: create a threshold filter on the object with logic something like "only agents with need > X allowed", or iterate through the agents until you find one with the greatest need score that is pertinent to the object, or a combination of the two to reduce the list size that must be iterated. sprinkle in agent range from object and specific traits preferably before the list generation to further reduce iterations needed.
i've thought about all of this a lot because i'm addicted to games with agency and emergent behavior. rimworld is a lot of fun in that regard because it's easy to jump into modding it, which makes agency experimentation a lot of fun.
Dwarves will, assuming they don't have other jobs at the time, pick a job from that list as long as they're allowed to do so by their labor selections + workshop availability (if that is possible). Do note that this doesn't actually account for pathfinding or if the job is even possible. The game will gladly tell you over and over that a job is being cancelled if for whatever reason the items needed for it are inaccessible/don't exist. Just a small note.
If the dwarf in question has no current jobs, the first priority will be for them to check their needs and try to fulfill them. Needs more or less are in two categories - "essential" and "non-essential". Non-essential needs used to be more obvious - it was the On Break part of a dwarfs schedule. Basically every once in a while, a dwarf goes "On Break", effectively making them unable to do anything except take care of their essential needs. Nowadays it's a set of activities derived from the unique identity of the dwarf (On Break doesn't exist anymore) - religious dwarves will want to play, while dwarves that seek musical entertainment will try to do so with a musical instrument.
Essential needs on the other hand are things like drinking/eating and sleeping. These pretty much come in two degrees, "want" to do and "need" to do. Want to do means the dwarf will immediately get a job to fulfill the need once the criteria are hit - if a dwarf gets hungry while hauling a rock, they'll grab a bite to eat after. When a need progresses to "need to do", it just will straight up interrupt any non-need job they're currently doing[0] (the game even tells you this) and create a new job to do it. Its how a dwarf will fall asleep on the spot if they're extremely tired.
Mental breakdown and tantrums are similarly "essential" needs, just with their own triggers that can't be interrupted by the player.
[0]: With the notable exception of military duties, which is one of the reasons militias in Dwarf Fortress have to be on a rotating schedule - dwarves will not eat or drink if they're on active duty, no matter what. They will sleep in a barracks though.
Bladder 9
Bowels 9
Sleep 8
Food 8
Safety 7
Hygiene 7
Exercise 6
Family 6
...
I found it interesting that maslow's heirarchy of needs shows much more detailed heirarchy: "physiological", "safety", "belonging and love", "social needs" or "esteem", "self-actualization" and "transcendence"...and the physiological needs are broken down further and slightly differently:
Physiological needs include:
Air
Water
Food
Heat
Clothes
Urination
Excretion
Shelter[2]
Sleep
https://en.wikipedia.org/wiki/Maslow's_hierarchy_of_needsI believe that’s how Will Wright designed The Sims too
I had an opportunity to play it for a few hours. It's not perfect - it didn't always keep up with my deductions, and on one instance it leaked unknown info via the UI - but on the whole it succeeded at a convincing mechanic.
It has some tempo management to work through I think, sometimes crimes are too obvious to solve and others are essentially dead ends unless you brute force your way to the info you need (which means talking to every NPC randomly or fingerprinting the whole city). And as you said, sometimes you have made a deduction, like who someone is thus linking their other details, but it's not relfected in the UI.