Perceptual Control Theory AI for NPCs?

So, ages ago, when I was a regular Less Wrong reader, I was introduced to the concept of Perceptual Control Theory. Now, I have no idea to what extent this is a fitting description of reality, but I feel like it could work as inspiration for a game AI.

Take, for example, an NPC in the shelter at the beginning of the game. Suppose flips coin he continues to be an unsleeping immortal guardian with no bodily needs whose only interaction with anything other than the conversation tree is fighting monsters. What should his strategy be?

Well, the foundation of the character as far as I can understand is, “At least we’ve got shelter.” In other words, he likes the shelter. He wants the shelter to be a safe place to stay. And his actions should be driven by one of two motives: maintaining the safety of the shelter and not dying. So:

[ol][li]The more dangerous or numerous monsters are, the sooner he will consider them a threat to the shelter. One dog three tiles away? Meh. The same dog inside the shelter? Kill it. Ten dogs, all within three tiles of the shelter, but not a pack? Okay, this is beginning to be a problem, so clear them out.[/li]
[li]If he is brave, a very dangerous but slow monster (e.g. a bloated zombie) that gets close he may try to lead away, returning after he has evaded it.[/li]
[li]A very dangerous and fast monster (e.g. a zombie hulk) he may try to hide from, and if he can’t (i.e. if it is getting too close and too hostile) he will flee and (if necessary) he will seek new shelter to stay in.[/li]
[li]If he runs into something very dangerous while out and about that is not close to the shelter, he will try to evade it and get back to safety.[/li]
[li]He may board up doors or build barricades to repair breaches in the doors or walls if he can.[/li]
[li]Whenever he feels like he doesn’t know what is in a given direction from the shelter (either because it has been a while or because he hears - or doesn’t hear - an expected noise), he will take a peek out the windows (ideally) or go out and look (if necessary).[/li]
[li]If he doesn’t have anything else that needs doing, he’ll go back inside and chill.[/li][/ol]

…and, by “doesn’t have anything else that needs doing”, I mean, “doesn’t have anything that causes his Danger-To-Self or Danger-To-Shelter meters to exceed their thresholds”. If any of you are familiar with Democracy 3 (TotalBuscuit did a video if you’re not) something like their threshold-value interacting-factors stuff is what I’m thinking of.

Obviously there are other things that you can add to this - say, foraging for food if hungry, foraging for liquids if thirsty, sharing food and liquid with you because it’s the apocalypse and you’re not interested in eating their face (unless you took “Cannibal”, obvs, but how would they know?), not wanting to go out in the rain - and other entities that could be modeled in related ways - say, that dog that the one NPC wants you to rescue - but I wanted to present the basic idea and see what reactions people have.

That’s a reasonable way to do things in general for NPC AI, but unfortunately that’s not what’s blocking them acting smarter.
The much harder part of doing game AI is constructing the AI senses (done, so that’s good) and maintaining the AI internal state.

What we need to write to make the elements of your scenario happen:

  1. Evaluating threat levels of monsters, it doesn’t have to be perfect or even right, but it should be somewhat sensical.
  2. This requires evaluating the monster (not too hard on top of #1) and navigating, which is significantly more difficult. I guess that strategy boils down to "walk slowly away from the shelter (ideally in a “safe” direction), then return via a fast and circular path.
  3. Requires understanding LOS so the NPC can hide from the monster while fleeing, and to be effective requires predicting where the monster is even if the NPC can’t see it, and understanding what constitutes a shelter (we can cheat a bit there since the NPC can examine the overmap for a simplified view).
  4. Just avoiding isn’t too hard.
  5. The act of repair isn’t too tough, but finding gaps is. We can cheat again and have the NPC refer to the template for the building, unless it was randomly generated.
  6. The NPC has to maintain a map of the surrounding area in memory annotated with how recently they’ve looked at it, and understand LOS enough to know HOW to refresh different areas. Off the top of my head I don’t know how to make this happen.
  7. This one at least is trivial.

The two really hard things here are having the NPC somehow understand LOS and be able to reason about it in a tractable way, and having them evaluate how secure their shelter is.

Thanks for the input!

I think “maintaining the AI internal state” is the center of the thing I was groping at. And it’s definitely a huge project, but I wanted to try to figure out parts that could be implemented soon - figuring out how to make AIs decide whether you-the-player would mind their eating your food is really hard, but #1 on my list seems totally possible with much hard work. :slight_smile:

i like where this is going.

i’d like to suggest:
8. AI should move to a significantly safer shelter if such exists. (eg. pawn shop vs fire station)
It brings again the question about evaluating shelter safety though.

So on that topic:
Maybe we could link it to building templates and choose it arbitrarily, then have it modified by building additions/changes to the initial building.
Eg. counting the number of traps in and around it, the number of broken windows/doors/walls, and the number of boarded up windows/doors, with all those modifying the initial “safety” value.

Of course all this won’t work that well for randomly generated buildings (even though they could be assigned a safety from mapgen?),
won’t work at all for player built buildings, or even player modified buildings that do not follow the initial walls/doors/windows configuration (like half of an RV dabbling as a building wall)…
…while it is a whole lot of work to do too… so i’m not sure if dynamically calculating shelter safety is a better approach

I don’t think we need to identify large safe zones - in the Cataclysm, I think that’s a contradiction in terms - so maybe some kind of bucket-fill algorithm would work. A 40-by-40 space would be 1600 squares; any enclosed area larger than that is probably questionably safe however it is set up. I think “is this an area completely surrounded by walls, doors, and windows that can be closed?” is a starting point, at least.