Jump to content

NPCs (technical)


Magusdl

Recommended Posts

Guest easy AI opponent
.....

Not in the literal sense, obviously.

Its the same also in a non-literal sense...

 

Only time will tell.

Hahahah.... I also wanted to add "only time will tell" but then i didnt.... (fedora)

Edited by easy AI opponent
Link to comment
Share on other sites

Non-programmer here.

[..]

Interacts with others, driven by needs, and virtualizes characters that are off-screen.

Bang on.

Just like there are specific uses and applications for tools and objects in the building trade, you wouldn't use a hammer to screw in a screw (or perhaps a better analogy - you wouldn't use a screwdriver to tighten a bolt, even if a bolt and a screw do both appear quite similar), there are the 'correct' ways to implement character AI in a given scenario or game type.

 

As I'm sure most of you will agree, PZ is pretty much a survival RPG, where we want the NPCs to essentially act in the same, or similar, manner as a human player would. The NPCs would ideally be marginally distinguishable from another human playing the game - following some flexible survival strategy, gathering supplies, establishing a 'secure' zone, and preparing themselves to weakening the surrounding Zombie population.

The AI implementation that best fits this is Goal-Driven Agent Behaviours which is, as the name suggests, behaviours derived from an active set of achievable goals. Not only does it mimic human actions quite well, it conveniently is very open to modding as well - once the goal/management structure is in place, additional goals, activities, and actions can be added to the system so that as game functionality increases, the AI can be expanded rather than re-written to include the new possible activities (farming, building, interacting with other players/NPCs).

 

Goal-driven agent behaviours define activities as a hierarchy of atomic and composite goals. An atomic goal is a single activity, often linked with another part of the game engine, such as navigating from point A to B (pathfinding), or reloading the equipped weapon. A composite goal is one which is more complex than an atomic goal, and is often made up of several atomic goals - something like find cover and hide, or gather food and stash it safely.

The hierarchical part of it is what makes it so similar to human train of thought - most people have a conscious and sub-conscious set of goals at all times, working on them one at a time - "Eat dinner" would be a composite made up of something like "Go to store", "Purchase required ingredients", "return home", "combine and cook ingredients", each of which is likely a composite goal in itself.

The beauty of hierarchical composite goals is that they can be completed to a given level of accuracy - if the player is following an NPC, then that NPC would actually go inside their home and to the oven to cook their food, but if the player is not nearby then those actions can be virtualised - simply over time having the food go from uncooked to cooked, and the NPC's location being update to within their home - saving on processing time as well as complexity.

 

Gosh, that came out a bit longer than I had planned. If any of you would like to get a bit of an understanding on the most likely method (not guaranteed to be how they've done it, but certainly something similar will have been implemented) they've used for the NPC AI, so you can better understand it when they are released, then look into Goal-Driven Agent Behaviours.

Link to comment
Share on other sites

Crusader Kings 2 + Sims 3&Story Progression Mod =

A) ambitious

B) very ambitious

C) too ambitious?

 

Firstly, not to boast on the matter, but we pretty much invented Sims 3 Story Progression Mods. :P evidence is all there with a quick google search. This approach is key to how we're doing the NPCs. We're dealing with Story Segments more than AI. That is what the meta-game is. To call it 'AI' is a bit misleading, because the NPCs don't have AI so much as the game's 'director' has AI and it bestows 'zombie movieish' series of actions that make sense for the characters involved. It's writing an interactive zombie movie effectively using a hopefully one day massive library of branching scenes with 'criteria' for triggering that match situation and character traits, that in themselves require little code to function and can be put in as fast as Will can write them and Ringo can script them.

 

The sophistication and detail will be in the stories that the director can weave, the more branches it has, and the more specific things it can do with different personalities and situations. Characters can get flags which triggerable events can use as conditions, allowing the scripting to allow for any conceivable long term plan or decision or tendency for an NPC. Want them to start hearing Spiffo plushies talk? (as Strider suggested at indie Stone meet :D) Flag them as 'spiffo_hearing_nuts' and make some scenes with spiffo talking taht require that flag, that perhaps trigger paranoia moodle, and bingo.

 

Once the system is fully functional expanding the AI or the perception of AI will be easy for us and modders, and the NPCs will seem more and more vibrant and detailed as this expands.

 

Crusader Kings 2 + Sims 3&Story Progression Mod = ambitious - well yeah it's a lot of work but the very reason we're doing it like these two things is because they produce quite complicated and sophisticated stories from much simpler set of rules than doing AI simulation across the world, and making that simulation able to play as well as a player.

 

CK II may have an event that triggers on average once every month if a vassal's opinion of you is less then -50, and you have the trait 'lunatic' for example. That event has flavour text, and button choices with effects, adding a trait or removing a trait, or somehow changing the state of the game to match the flavour text. Ours will be more complex than that since it will involve dialogue scenes, characters moving about, talking to eachother, and potentially other game actions. But it boils down to the same thing.

 

In same way we will have scenes, with NPCs filling the parts, and those scenes will be picked based on the group's situation and the members in that group. Outside the player's stream circle all this happens conceptually, and the effects are virtual until the player approachs, at which point they are applied solidly after the fact. If there was a slaughter in that house, then place bodies around. If there is an NPC group at home in their safehouse, ascertain the fortification level of the house (that may have increased due to certain story events or some general board gamesque set of rules) and barricade it up / build walls / rooms or whatever else to fit. If it happens inside the stream circle then the actual NPC characters will be 'soft' scripted (aka their exact movements are not predefined, but they may 'go closer to the player' or 'go into the adjacent room' or 'go to a window and look out'. 

 

This doesn't apply to stuff like combat or idle AI however.

 

the difficult bit about that is making sure these virtual NPCs transition into real NPCs in positions that match the context of the event, and that they can pathfind around the local area without getting stuck on something, or try and pathfind outside your spawn radius, and if they do and reenter the meta-game, then it stays consistent. Making NPCs move from room to room and behave naturally when you're around etc.

 

Making NPCs fight effectively against zombies, as well as look natural and like a player would when they fight. If NPCs are getting caught on locked doors or getting bitten by a zombie right next to them without reacting due to some conflicting set of priorities then it spoils the NPCs completely and makes them a detriment to the game and shatters any reality.

 

TL;DR: The whole point of the CKII / Story Progression philosophy is to make it massively LESS ambitious than it would be using proper persistent AI, and thus allow us better higher level 'story' results instead of having an AI that just fails because the programming required to make them 'make it up as they went along' would be immense and unmanageable.

 

It's the stuff that's NOT CKII / Story Progression mod that's the tough stuff. ;D

 

Will post more another time to answer OP's questions specifically. :)

Link to comment
Share on other sites

Hypothetical stress test: In network mode if you had multiple stationary players form a scattered dot grid pattern around a large area creating a large "streaming net", that means the game (or just the server?) would have to process all those npcs in real-time right?

 

Also if i wanted to script an arsonist npc that goes around looking for fuel, enters houses, looks for the objectOven, turns it on and goes away, does that mean i would also have to define a "simplified" version of that for metamode? or are you going to magic a way for the game to handle that itself?

Link to comment
Share on other sites

Hypothetical stress test: In network mode if you had multiple stationary players form a scattered dot grid pattern around a large area creating a large "streaming net", that means the game (or just the server?) would have to process all those npcs in real-time right?

 

Also if i wanted to script an arsonist npc that goes around looking for fuel, enters houses, looks for the objectOven, turns it on and goes away, does that mean i would also have to define a "simplified" version of that for metamode? or are you going to magic a way for the game to handle that itself?

 

Yep the server would need to process them all. But then server runs at 12FPS so will struggle less with the increased load.

 

Anything that can happen to a house will have some sort of 'flag'. 'burntdown' will likely be one of them, so it'd just set that flag on the house, which the metagame would factor into their events and would post apply fire / burnt tiles as you approach it. There would need to be some script that went through all containers in the house, check if they are stoves, and if so NPC walks adjacent, stove comes on, then NPC leaves building and heads elsewhere. The scripting would deal with both virtual meta game and real behaviour for it.

Link to comment
Share on other sites

Not sure if I can (ab)use lemmy's "good question answering moodlet" ;-) but I loose nothing by trying, in the worst case will be ignored - what I would like to know more about NPCs is their knowledge/memory.

 

Location:

1) would they follow the same randomness when finding loot?

2) would they get distracted (for some time) with for example hauling that big supply of newly discovered food when looking for carpentry book?

3) would they search for fridge/stove in a forester hut?

4) would they even know about it's existence (or how to reach it) if they've never been there?

 

Player actions:

5) remember about his help/donation/theft

6) connect dots when player was entering/leaving the house and something was missing (also not accuse player of such action when he wasn't even near to notice players misbehaviour)

7) again accusing/hating player for pulling down the horde

8) sharing (not instantaneously) knowledge about player (we could kill quietly someone who noticed us stealing stuff, so that the rest of the group won't know about it and still admire us)

9) trying to loose player, when he's tailing an NPC that tries to hide his safehouse

 

On the not specifically NPC related question:

10) not refreshing the map instantaneously with something that was done by NPC (noticed on some MP stream, that even when player was having his back to the part of the screen, it was still updated with walls being built by someone else) - think it would hide from a player fact that some building has been turned into a safehouse and is currently being barricaded/walled off

 

And so that I'm clear - I'm asking about some real expectation for when we will see NPC's in the bare implementation, not something you hope/strive for. Also I don't expect you to answer each and every point separately - what I did is just noted them separated to pinpoint what I'm interested in, in regard to memory/knowledge.

 

And thank you again for the bigger picture about your view on the whole NPC stuff.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...