Jump to content

Is it even possible to code zomboid NPCs?


Headshotkill

Recommended Posts

First of, this isn't a complaint about NPCs taking a long time, I've made peace with that many years back.

I'm just curious given the recent radio silence about NPCs what the morale of Lemmy and his team is about tackling this coding monstrosity, does he have high hope it's possible to do in a way that doesn't break?

From what I remember the NPCs are going to function with the use of a decision-tree and use this to react to different stimuli.

 

Thing is, how does the system handle a player who's actively fooling around doing nonsensical things like building a wall around an NPC that's sleeping, all these variables in different situations creates an exponentially increasing amount of different stimuli that the NPCs somehow need to react to. A single weird scenario that's not considered in the code may derail the AI as it has no answer as to how it should react. Is it possible this list gets too big for a human to code? Would a deep-learning AI which improves over generations be better suited?

 

 

Link to comment
Share on other sites

On 7/11/2023 at 8:40 PM, Headshotkill said:

First of, this isn't a complaint about NPCs taking a long time, I've made peace with that many years back.

I'm just curious given the recent radio silence about NPCs what the morale of Lemmy and his team is about tackling this coding monstrosity, does he have high hope it's possible to do in a way that doesn't break?

 

There is a mod called Superb Survivors

https://steamcommunity.com/workshop/filedetails/?id=1905148104

 

Don't expert some super intellgent NPC's in main game

Just expect basic actions to happen and some scripted ones

Link to comment
Share on other sites

Very good question, I am personally rather pessimistic when it comes to NPCs. It is an absolutely massive undertaking.

 

Also afaik deep learning is not a magical system you can just plug in to do the work for you. One first needs to code the entire deep learning algorithm.

 

And then there's still the problem of what input do you feed the algorithm, and how do you tell the algorithm what output it's looking for.

 

In short I'm pretty sure it's just impossible to do here.

Link to comment
Share on other sites

1 hour ago, Modin said:

Very good question, I am personally rather pessimistic when it comes to NPCs. It is an absolutely massive undertaking.

 

Also afaik deep learning is not a magical system you can just plug in to do the work for you. One first needs to code the entire deep learning algorithm.

 

And then there's still the problem of what input do you feed the algorithm, and how do you tell the algorithm what output it's looking for.

 

In short I'm pretty sure it's just impossible to do here.

Yeah, deep learning and all that stuff isn't a magic one-fits-all solution. I grabbed TWD series from Steam this summer sale and I'm a couple episodes in. Man if similar stories would develop organically in project zomboid that would be amazing, it would probably elevate this game into the top 10 games ever made. 

Let's not forget Lemmy has, if I read the blog posts right, been working on these NPCs for about 10 years now. I've been practising guitar for 2 years and if you really want something done, and put the work in, you can get some amazing results. 

I'm just worried he's being outpaced by the rest of the dev team, they're making all these new systems and as much as I like new features being added, I also know this means NPCs will have to become even more complicated to interact with these systems.

 

It's good to see they know how to drive cars, shown in a video a while back, but I've yet to see them create walls and fortify bases in a realistic manner beyond simply boarding up the windows. A new NPC blogpost would be very welcome by now.

 

Link to comment
Share on other sites

10 years is quite a long time indeed.

 

But... if we want NPCs that feel good and work well with the rest of the game, their AI is gonna need to be pretty intricate.

 

And it's an entire new set of mechanics, too. It's a huge undertaking, it would change the game completely.

 

Like, how would trading be done? How would NPCs attack the player with melee weapons? Are they subject to the same range limitations? Can they miss a hit if the player gets away? Would they ever sprint or would they just jog? Do they have stats of their own? What would they do with their lives? Would they have to eat? Do they have traits too, calories, weight? Would they replace their clothes? Does this all impact the world, as in resources become scarcer because NPCs are using them too? If they have to eat, do they die if they can't find anything?

 

If NPCs are following you... what if you're faster than them? What if you get into a car and just drive off? What happens to their AI? Most games just TP the player's companions to them, but they can't do that here. NPCs driving by the way seems like a bad idea, how would they handle zombies? Try to avoid them or just damage the car needlessly? What if the car stalls? By the way, if they drive anything, will the car just spawn with them or will they use existing cars only? Same for their resources.

 

If you find a friendly camp, can you just rob them blind in plain sight? If not, can you still rob them when they aren't looking? What if you bash in one of their doors with an axe? What if you bring an ambulance with its siren on and drive it to the middle of their camp? What if you steal a vehicle? What if you drop items in the middle of the camp, will the AI acknowledge that the player has done that? What if you drop food with bleach in it and they all fucking die, will the survivors acknowledge that you killed them all?

 

How will melee weapons work on NPCs? Will spears thrust, for example? Knives do their little jaw stab animation? Does that still oneshot? How much more resistant than zombies will they be?

 

If you have companions following you, how are they going to feel real unless their AI can properly deal with zombies? Are they going to die from 2 slow shamblers walking up to them because their AI is too shitty? Or are they going to be magically invincible? Same for non-follower NPCs tbh, how will they deal with zombies? Will they have infinite ammo like in many video games? What if I zigzag into a horde, is that just an instant death sentence to dumb NPCs or will they be smart enough to navigate through? Or again will they just be cheating by being invincible or whatever else.

 

How will they react to fire given that fire in Zomboid is this insane force of nature that just relentlessly destroys everything in existence? What if you started the fire?

 

What about their personalities, how will that be decided/generated, or will they all basically be copies of each other? Will it be dynamic or set? What will make them interesting or make me want to interact with them? If I find a settlement, will the NPCs inhabiting it feel real, will they be wary of strangers or just let me do whatever, will they have a leader, roles, stories, will they have different feelings towards other survivors, the player, or towards the settlement itself, will they decide to leave, will new NPCs join, what happens when they die, how will other NPCs react, etc...

 

I could go on forever. I've barely scratched the surface of the complexities of an NPC system. It is an absolutely insane task to add NPCs to such a complex game that hasn't really planned around them in the first place. I've maybe brought up less than 5% of all the decisions and issues around NPCs.

 

This Lemmy guy better be fucking brilliant, because this seems like a monumental task.

Link to comment
Share on other sites

5 hours ago, Modin said:

10 years is quite a long time indeed.

 

But... if we want NPCs that feel good and work well with the rest of the game, their AI is gonna need to be pretty intricate.

 

And it's an entire new set of mechanics, too. It's a huge undertaking, it would change the game completely.

Yes, if we get NPCs they'll either blow our minds with how good they are and set a precedent for future game AI, or we'll be dissapointed with their robotic lackluster performance. There's no inbetween. I'm gonna play devil's advocat and try to come up with solutions to potential problems you mentioned. I'm suprised Lemmy hasn't asked the community to provide examples of what weird stuff they'd do in order to break the AI.

5 hours ago, Modin said:

Like, how would trading be done? How would NPCs attack the player with melee weapons? Are they subject to the same range limitations? Can they miss a hit if the player gets away? Would they ever sprint or would they just jog? Do they have stats of their own? What would they do with their lives? Would they have to eat? Do they have traits too, calories, weight? Would they replace their clothes? Does this all impact the world, as in resources become scarcer because NPCs are using them too? If they have to eat, do they die if they can't find anything?

Trade could either be done using a barter system where each good has an intrinsic value that's modified by the trader's needs/personality or group he belongs to. After some time, either months or years ingame some NPC groups could agree on a shared medium of exchange for trading, be it money or old bottle caps.

We already have PVP combat, it's janky but it works. A long long time ago there was a blogpost called 'NPC dance of death' which showed NPCs succesfully navigating a map with hundreds of zombies forming hordes to reach waypoints. I think NPCs in the final version are supposed to be fully simulated with a food need, drink need, clothes need so they'll have to find all of those. Resources becoming more and more scarce is the most needed addition to this game, currently I use a mod to automatically reduce unlooted container loot with time.

5 hours ago, Modin said:

If NPCs are following you... what if you're faster than them? What if you get into a car and just drive off? What happens to their AI? Most games just TP the player's companions to them, but they can't do that here. NPCs driving by the way seems like a bad idea, how would they handle zombies? Try to avoid them or just damage the car needlessly? What if the car stalls? By the way, if they drive anything, will the car just spawn with them or will they use existing cars only? Same for their resources.

A lot of weird interactions will need to be grouped together in order to keep things manageable. Actions which have a negative consequence for the affected individual(s) will be considered a crime, actions which have a positive consequence will be considered a gift if it is an item, or a favor if it's an action. Any form of crime will have an associated list of possible punishments like physical harm, banishment or execution, while gifts and favors have an associated list of possible rewards. leaving an NPC behind or driving away could be classified as abandonment/desertion depending on the circumstances. If the car belonged to the NPC (group) this would also be classified as stealing the car and all items inside that car. So next time you meet up with that group they'll treat you as a deserter+thief so they'll likely kill you, unless you have a good explanation. (charisma skill?)

I'm pretty sure NPCs will have to find a working vehicle just like the player, this is something that can be coded as checklist: Vehicle working condition? check. Key's nearby or inside the car? check. Gas in the tank? check. --> working vehicle

Considering they've shown NPCs capable of avoiding zombies on foot in a video in the past, I'm sure they'll be able to avoid them while driving as well.

5 hours ago, Modin said:

If you find a friendly camp, can you just rob them blind in plain sight? If not, can you still rob them when they aren't looking? What if you bash in one of their doors with an axe? What if you bring an ambulance with its siren on and drive it to the middle of their camp? What if you steal a vehicle? What if you drop items in the middle of the camp, will the AI acknowledge that the player has done that? What if you drop food with bleach in it and they all fucking die, will the survivors acknowledge that you killed them all?

So taking stuff without permission be it an item or a car would all fall under the crime 'stealing'. Bashing in a door could be classified as 'vandalism' if the door isn't destroyed, only damaged. If the door is destroyed the crime is more severe and could be classified as 'Sabotage' if you're part of the group, or just an outright hostile attack if you're not part of the group. Entering a base without permission would be seen a 'trespassing', some areas of a base may even be inaccesible to some of it's own members and be considered 'trespassing' if you do. (entering the leaders' bedroom without permission) If you drop an item inside the base this would automatically be added to the overall inventory of the base and an NPC will come pick it up to store it in a suitable spot, this would be considered a 'gift' and possibly rewarded. If it's poisoned food this would be considered an outright hostile attack if you're not part of the group or 'attempted murder' / 'murder' if you're part of the group. Additionally if you commit multiple crimes or a very severe crime you could be classified a 'traitor'.

Car honking is something that's difficult to classify, there should be a difference between accidentally honking for a split second or blasting an ambulance siren for minutes. We'd probably need a less severe 'incompetence' crime for an accidental honk, 'Sabotage' for a longer car honk or honking in a crowded area and in the most severe case you'd be classified a 'traitor'. If you're not part of the group car honking near their base would be considered an outright attack. Being classified a 'traitor' basically means you're permanently removed from a group and they'll attack you on sight.

5 hours ago, Modin said:

How will melee weapons work on NPCs? Will spears thrust, for example? Knives do their little jaw stab animation? Does that still oneshot? How much more resistant than zombies will they be?

Unless the melee system is completely overhauled it will be wonky, like the PVP we currently have.

5 hours ago, Modin said:

If you have companions following you, how are they going to feel real unless their AI can properly deal with zombies? Are they going to die from 2 slow shamblers walking up to them because their AI is too shitty? Or are they going to be magically invincible? Same for non-follower NPCs tbh, how will they deal with zombies? Will they have infinite ammo like in many video games? What if I zigzag into a horde, is that just an instant death sentence to dumb NPCs or will they be smart enough to navigate through? Or again will they just be cheating by being invincible or whatever else.

Again this is something I personally am not too worried about, I think they've already proven in the past they've got basic self preservation into the code, be it navigating around hordes or fighting smaller groups of zombies.

NPCs in the final version are supposed to be competely simulated, no infinite ammo, no increased strength.

5 hours ago, Modin said:

How will they react to fire given that fire in Zomboid is this insane force of nature that just relentlessly destroys everything in existence? What if you started the fire?

For this we'll have to wait for the new fire system to be implemented next update I believe. To be honest, fire is one of the most powerfull forces of nature there is so I'm fine with it being extremely destructive. Imagine a forest fire during summer spreading without intervention of firefighters, it could and should easily burn down a large section of an ingame town like Muldraugh. If you start the fire it would be classified as 'Sabotage' but of cours it's waaay more severe than just destroying a door, if it kills someone it would also be 'murder' which could add up to you being classified a 'traitor'. If you're not part of a group and start a fire near their base it's considered an outright attack.

5 hours ago, Modin said:

What about their personalities, how will that be decided/generated, or will they all basically be copies of each other? Will it be dynamic or set? What will make them interesting or make me want to interact with them? If I find a settlement, will the NPCs inhabiting it feel real, will they be wary of strangers or just let me do whatever, will they have a leader, roles, stories, will they have different feelings towards other survivors, the player, or towards the settlement itself, will they decide to leave, will new NPCs join, what happens when they die, how will other NPCs react, etc...

This is something that's been revealed recently in 2 NPC blog posts, each NPC will be virtually simulated from the very start of the apocalyps, before the player even starts the game. Each NPC has a home, a job location and family/friends. When sh*t hits the fan they'll virtually (metaverse) try to get back home and reunite with their family, some members may get sick so they'll try to reach the nearest hospital, they remember these events and can tell the player these stories. You should look up those blogposts, very interesting.

I think for groups there should be several different types of leadership. A full democracy would have all members vote on decisions like what punishment someone deserves for a crime. (banishment or execution for murdering a member of the group?) This is how most, if not all groups would function early on. As the game goes on after weeks/months, some groups would grow in size and evolve to either a council based system where a couple individuals of a large group vote on decisions, or an authoritarian system were one individual has all the power and decides everything. 

I think I've recently read in a blogpost all members would have a job within an established NPC group, like farmers, scavengers, cooks, ...

5 hours ago, Modin said:

I could go on forever. I've barely scratched the surface of the complexities of an NPC system. It is an absolutely insane task to add NPCs to such a complex game that hasn't really planned around them in the first place. I've maybe brought up less than 5% of all the decisions and issues around NPCs.

 

This Lemmy guy better be fucking brilliant, because this seems like a monumental task.

You're right, there's still a ton more stuff to consider.

It's a massive undertaking but then again, if he pulls it off he's basically set for life.

Link to comment
Share on other sites

Im pretty sure thats on of the things that are already solved. I would assume dealing with the player being a idiot and flagging him as a hostile or view the player as a crazy person is already considered if you considered the few things they stated like

 

-The whole article on how behaviour trees work

-Lone Survivor blog talking about how the AI will still try to achieve its goals if there are obstacles in the way

-Lemmy in the comments on the zuckerverse talking about how the AI deals with obstacles and how the behaviour trees work over frames

-Another comment about late game groups coming to kick the players and other npcs butt, how could they even work on screen unless the ai code is basically done?

-The 2022 blog stating at the time that "the vast majority of the hard work has been done, is functional and is extremely cool"

 

- "NPCs won't always listen to the leader, however its not clear whether the scenes that deal with this will be in the first version. Certainly an NPC following an 'order' to patrol the house may decide to stop patrolling the house because they are tired or lazy." I know there is another comment about how their higher level decision making is decided that breaks it down into smaller goals the AI then does to finish it. So if there are obstacles or if they are ordered to patrol, but they are thirsty they can quickly go to a house nearby to get water, drink and continue on patrolling.

 

- The bottom 2 links seem to assume that the decision trees are going/already be expansive and deep enough to handle most of the situations.

 

https://www.gamedeveloper.com/programming/behavior-trees-for-ai-how-they-work

https://projectzomboid.com/blog/news/2022/04/lone-survivor/

https://projectzomboid.com/blog/news/2022/01/2022-and-beyond/

https://www.reddit.com/r/projectzomboid/comments/sveybv/comment/hxfvmdz/?context=3

Link to comment
Share on other sites

  • 2 weeks later...

My current ideal NPCs are like those in Survivalist:  Invisible Strain.    A small game with good concepts that play out on a small map.       They have a respect - fear - pity and something else matrix for each other and the player.   They remember specific events that others did to harm or help them and you can read all of this data with a "brain scanner" tool that's a bit like cheating.     Then they do tasks at the bases like farm,  collect wood,  etc.     Like RTS pawns.     They travel the map,  can fight reasonably well,   elect new leaders,   etc.         What they can't do is build on their own  (pre gen NPC bases).

 

If strange things happen,  like deaths,   while you're around they start to suspect you had something to do with it.      Because you probably did lead zombies to them.  lol.    And Ive seen them argue with and blame each other so the mechanic must apply to each other.      IVe also seen fights within groups.     Both to the death and cases where they stop after hurting each other.

 

 

Link to comment
Share on other sites

  • 3 weeks later...

I always thought it would be easier (emphasis on easIER not easy) to make all NPCs in the 1st build just enemies.

When you encounter them, they are hostile. They are attacking you, attacking zombies, looting stores (or your base)

and simply run off and/or die. They don't have a base they go back to, you can't talk to them, you can't trade them, 

etc. They are just basically armed zombies with some advanced features. That would breathe a bit more life into the

game as if to find hostile survivors that don't trust anyone.

 

Then stage-2 NPCs would come in a later build, where they can be talked to, assisted, help guard your base, trade,

farm, build, etc.

 

That is always how I thought making NPCs would be easier on the dev team. But I don't code so.  =)

Link to comment
Share on other sites

  • 2 weeks later...
On 7/12/2023 at 6:10 AM, Headshotkill said:

First of, this isn't a complaint about NPCs taking a long time, I've made peace with that many years back.

I'm just curious given the recent radio silence about NPCs what the morale of Lemmy and his team is about tackling this coding monstrosity, does he have high hope it's possible to do in a way that doesn't break?

From what I remember the NPCs are going to function with the use of a decision-tree and use this to react to different stimuli.

 

Thing is, how does the system handle a player who's actively fooling around doing nonsensical things like building a wall around an NPC that's sleeping, all these variables in different situations creates an exponentially increasing amount of different stimuli that the NPCs somehow need to react to. A single weird scenario that's not considered in the code may derail the AI as it has no answer as to how it should react. Is it possible this list gets too big for a human to code? Would a deep-learning AI which improves over generations be better suited? omegle ometv

 

 

While you're there, they begin to suspect you have something to do with it. Because you probably drove zombies towards them. lol And I saw them arguing and blaming each other, so the mechanic should apply to each other. I've also seen struggles within the agencies. Both to the point of death, and in cases where they prevent themselves after injury.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...