Documenting "Features", AI Habbits, and Oddities in Physics

+
So what would you need for an unique NPC? An ID? 24bits, List of friends 50*24bits+flags 10bits Some state 8 bits, A mood 8 bits, profession 24bits, some basic flags 10bits, a clothing set 24bits? Their place of living 24bits... (TBH i'm being generous, most static attributes could be encoded in ID or optimized in other ways - like you don't need a specific home for everyone, just building or e.g. "vanishing point"). Anyway.. that gets me to something like 1824bits. Ok, cars and drinks and wardrobe. Lets make it 20kb for each NPC, most of it being static. That gives me 5.6Gb. DDR4-3200 has tranfer rate of 25.6Gbps meaning you could run trough that full, unoptimized list 4.5 times per second.
Don't forget an important thing, the time to "code" each one. So I have no doubt that it's possible, but the time (money) to do it...
Even 2 minutes by NPC (which is also generous) : 280K NPCs > 560K minutes > ~9333 hrs > ~388 days of work.
It's a lot :)

Edit :
According to the wiki, Night City welcome about 6,964,425 in 2077.
You can't compare "actual" city with Night City, in theory (on the paper at least), each megabuilding houses approximately 128,000 poeple at maximum (and on a "tiny" ground surface).
 
Last edited:
It's not possible to look at this as every NPC counting as "1 processing function".

When I code an AI routine like this, I first need to account for a single NPC's individual, basic functionality. Let's take a really simple example like, "Walk from point A to point B":

I'll have some sort of navigational grid (I use the term navmesh, since I've primarily worked with Gamebryo / Creation Engine) which is a web of "points" that are valid places for actors to move in 3D space in order to create various paths from A to B. I then need to write an algorithm that dictates how many different times the AI routine will try to calculate different pathways in its attempt to find an open route from the starting point to the destination. The more points there are in a web, the more detailed the movement can be, but the more processing it will take to find a chain of points that goes all the way from A to B.

Now, if a point along the route that is ultimately selected is "blocked" because something in the world-state changed, like another NPC decided to stand on one of the points chosen along the path, I need the algorithm to both recognize that (constant processor cycles dedicated to checking), and I'll then need to recalculate the route, with the blocked point now counting as A, and the final destination point remaining as B.

That process must be continuously running, indefinitely, from the start of the NPC's journey until the end. If, at any point, the algorithm is unable to calculate a valid route to the final destination at point B, the NPC will become "stuck". In lay experience, this is where you'll see an NPC just walk in circles, jitter back and forth, or randomly start walking in a different direction. In actuality, what's happening is the AI routine is actively trying to work around the issue by either repeatedly re-calculating the route, but is continuously unable to reach destination B because the algorithm does not allow enough passes to find a route complex enough to get all the way from A to B...or it simply gets itself unstuck because the algorithm has a failsafe function that allows the NPC to simply pick a new destination B.

Next, that simple process of making a single NPC do nothing but "walk from point A to B" must be individually processed for every, single, individual NPC that I intend to populate the world-space with. Every, single, individual NPC must be given an equal share of processing time in order to figure out what grid point on the navmesh they're going to move to next, make adjustments as needed, and then execute it.

And all that does is let random NPCs simply move from one point to another. We haven't even gotten into the AI routines that would need to be written to have NPCs react to the world around them, move at only certain times of the day, interact with things like vehicles, crosswalks, vending machines or store stalls, display idle animations, fetch and play specific sound files for speech, etc., etc., etc. For each of these different elements, I'll need specific code that governs all of it constantly loaded into RAM and being actively processed for each, individual NPC presently loaded into the gameworld. If I want to create a persistent world with static (instead of randomly generated) NPCs, I also need to have algorithms specifically tracking the behavior of NPCs that are not actively on-screen at the moment.

As the complexity of the system increases, especially the number of individual NPCs involved, the amount of processing required increases in an exponential curve. The more processing I dedicate to creating these types of complex AI routines, the less I have to dedicate to all other processing the game may need to do.

Hence, we have to balance. The end result is that we want to create an illusion of bustling life while still allowing for all of the game's other functions to execute as smoothly as possible, leaving an overhead of system resources in case something unexpected happens and the game suddenly needs to "pull" and do a lot of complex processing all at once. Generally, as is the case with all game design and development, if we need more resources in one area, we need to take it from another area.

Think of a game's minimum specs as a "budget" that determines what all game functions are able to afford. If a process cannot do what it needs to do on that budget, then process needs to be simplified or reworked in clever ways so that the game engine is not "over-spending" in any one area.

_______________

TL; DR / conclusion only:
Is it possible to create much more complex crowd-AI? Certainly! But that will necessarily create an exponential increase in demand from system resources -- and not by a little -- by tremendous amounts as we add additional NPCs. If it's too much, then only ultra-high-end hardware will be able to handle it. That greatly limits the market. It also limits the overall functionality gameplay-wise, as resources dedicated to AI routines cannot be used for other game functions. It's all a big balancing act.
 
But that will necessarily create an exponential increase in demand from system resources -- and not by a little -- by tremendous amounts as we add additional NPCs.
It might sound silly as an example, but if we take minecraft, all the Mobs (villagers, enemies and animals) have their own little routines (I'm not talking AIs, just "very" basic routines). They are "limited" in number by default for that reason.

For example, a simple sheep. You can spawn them (reproduce) as many as you want. (one tick equal about 0.05 seconds).
For each sheep, the game choose randomly (each 20-1000 game-ticks) a bloc around the sheep (about 20 bloc around) as destination. After choosing a bloc, it need some conditions that the game have to verify : this bloc must have light higher than 7, grass on top, 2 air blocs above, no wolf nearby and an accessible pathway. If the conditions are not met, the game reset the operation and choose another bloc after 20-1000 game-ticks. Then repeat the process until the bloc is valid and if it's the case, the sheep travel to it. The game have to repeat this process all day long, as long as the sheep is loaded by a player (player less than "128 bloc sphere" around the sheep).
On top, each sheep have a 1/1000 chance to "eat" the grass where they stand (if they stand on grass) per game-tick.

With one, two, ten, twenty sheeps, no problem. But if you make a sheep farm (like few hundreds 10-20 sheep for each whool color), you will see that even with a (very) high-end PC, the area will be pretty laggy (and with thousand, almost unplayable on almost all PCs ...)

It's for that reason that many players build their farms (where there is a bunch of Mobs) in the Nether, in the End or at least enough far from their base for avoid to load them except when they want...

And it's only "sheeps" who simply have to choose a simple pathway and with basic Minecraft graphics :)
 
Last edited:
It might sound silly as an example, but if we take minecraft, all the Mobs (villagers, enemies and animals) have their own little routines (I'm not talking AIs, just "very" basic routines). They are "limited" in number by default for that reason.

For example, a simple sheep. You can spawn them (reproduce) as many as you want. (one tick equal about 0.05 seconds).
For each sheep, the game choose randomly (each 20-1000 game-ticks) a bloc around the sheep (about 20 bloc around) as destination. After choosing a bloc, it need some conditions that the game have to verify : this bloc must have light higher than 7, grass on top, 2 air blocs above, no wolf nearby and an accessible pathway. If the conditions are not met, the game reset the operation and choose another bloc after 20-1000 game-ticks. Then repeat the process until the bloc is valid and if it's the case, the sheep travel to it. The game have to repeat this process all day long, as long as the sheep is loaded by a player (player less than "128 bloc sphere" around the sheep).
On top, each sheep have a 1/1000 chance to "eat" the grass where they stand (if they stand on grass) per game-tick.

With one, two, ten, twenty sheeps, no problem. But if you make a sheep farm (like few hundreds 10-20 sheep for each whool color), you will see that even with a (very) high-end PC, the area will be pretty laggy (and with thousand, almost unplayable on almost all PCs ...)

It's for that reason that many players build their farms (where there is a bunch of Mobs) in the Nether, in the End or at least enough far from their base for avoid to load them except when they want...

And it's only "sheeps" who simply have to choose a simple pathway and with basic Minecraft graphics :)
That's the idea, exactly.

Thus, in order to populate a world with "huge crowds", devs create tricks that free up resources and allow for the processing to be done more quickly. For example, let's say I want to populate a crowd of about 100 NPCs that walk along a street, get to a crosswalk, wait for the signal to turn, then cross and continue on their way. Well, I can work that out by assigning a navmesh path that looks like a "figure 8". Saaay, a path 12 points wide that wraps like a ribbon around 2 buildings and comes together in the middle where the crosswalk is.

Rather than trying to code individual NPCs to travel all over the city, hoping that some of them eventually wind up at that crosswalk, I simply write a single algorithm to populate that ribbon of navmesh with 100 NPCs whenever the player loads into that area. It contains all of the AI packages that those 100 NPCs will need, allowing them to wait until the signal has turned before crossing the street, and/or and walk around other NPCs that might move across the ribbon at any point. They'll then follow the ribbon around the building, looping back to the crosswalk in the other direction. And that loop will play out endlessly as long as the player remains in the area, creating the illusion of constant pedestrian traffic at that crosswalk.

Viola -- I can now schedule the engine to update those 100 NPCs for only the AI routines that apply. So, rather than needing to code all NPCs in the game to understand how to use that crosswalk, I only need to worry about those 100 NPCs on that particular navmesh path. And only those 100 will ever arrive at that crosswalk. Speedy and efficient.

But...if I decide to follow one of those NPCs around, I'll see that all they do is loop around those two buildings to cross the street at that same point all day long. I'll break the illusion. It's just like walking backstage in a theatre to see how the set works.
 
Last edited:
I wonder if instead of trying to give day/night ciclesto each npc, yes impossible, is a better system couldn't be in place for NC specifically. So attribute a class to sets of npcs (day worker, night worker, ... with corresponding tasks according to time of day. This would include merchants that would leave the stall at a certain time and go to one.
As Cyberpunk pops-in npcs close to player this would mean that after generating the npcs for that area the game would recognize their class and time of day and they would be given their purposes and we could watch them play out. The complexity of the systems could be greater or lesser (only time of day or weather, reaction to other npcs trying to do same activity on same spot,...)
 
I wonder if instead of trying to give day/night ciclesto each npc, yes impossible, is a better system couldn't be in place for NC specifically. So attribute a class to sets of npcs (day worker, night worker, ... with corresponding tasks according to time of day. This would include merchants that would leave the stall at a certain time and go to one.
As Cyberpunk pops-in npcs close to player this would mean that after generating the npcs for that area the game would recognize their class and time of day and they would be given their purposes and we could watch them play out. The complexity of the systems could be greater or lesser (only time of day or weather, reaction to other npcs trying to do same activity on same spot,...)
Diminishing returns, most likely. What you're describing would definitely be more efficient than individually coding a daily schedule for each NPC, but what would the final result be? If I do that, will I notice any tangible difference in the crowds? Only if I follow and NPC around, probably. But, if that's the case, that's still an awful lot of additional processing power and system resources being reserved for the functions...solely on the off chance that a player decides to follow a random NPC around for no good reason. I'd rather have the additional 5 FPS, myself.
 
Diminishing returns, most likely. What you're describing would definitely be more efficient than individually coding a daily schedule for each NPC, but what would the final result be? If I do that, will I notice any tangible difference in the crowds? Only if I follow and NPC around, probably. But, if that's the case, that's still an awful lot of additional processing power and system resources being reserved for the functions...solely on the off chance that a player decides to follow a random NPC around for no good reason. I'd rather have the additional 5 FPS, myself.
I don't think following an npc would end up in anything. What I think would acvomplish is we start noticing that at the same time of day some sellers close the shop and start walking. There are times at night when only some sellers are working, rush hours is more people walking, middle afternoon more people hiting the vending machines, doing chi kung,... this system would benefit from more environmental interactivity though.
So it would apply these class based actions within that bubble close to the player
 
Diminishing returns, most likely. What you're describing would definitely be more efficient than individually coding a daily schedule for each NPC, but what would the final result be? If I do that, will I notice any tangible difference in the crowds? Only if I follow and NPC around, probably. But, if that's the case, that's still an awful lot of additional processing power and system resources being reserved for the functions...solely on the off chance that a player decides to follow a random NPC around for no good reason. I'd rather have the additional 5 FPS, myself.

One would expect a "masterpiece" video game would have put time into simple daily schedules (and the complex dynamic of changes based on world events, player decisions, and affinity) and modern technology to handle running 5 instances of Dwarf Fortress in the background.
TL; DR / conclusion only:
Is it possible to create much more complex crowd-AI? Certainly! But that will necessarily create an exponential increase in demand from system resources -- and not by a little -- by tremendous amounts as we add additional NPCs. If it's too much, then only ultra-high-end hardware will be able to handle it. That greatly limits the market. It also limits the overall functionality gameplay-wise, as resources dedicated to AI routines cannot be used for other game functions. It's all a big balancing act.

This is where a company hires someone like me to solve these "issues"....

doesn't the sims have all the basics down already?

I was playing this game Pixel Starships...






I really think the main issue here is some groups in the workforce are underpaid and refuse to put forth such industry bending ingenuity into practice and receiving little to no credit.
 
One would expect a "masterpiece" video game would have put time into simple daily schedules (and the complex dynamic of changes based on world events, player decisions, and affinity) and modern technology to handle running 5 instances of Dwarf Fortress in the background.
They do contain schedules, as addressed earlier, just not individual schedules for every single NPC spawned. Rather, the sections of the city see different sorts of traffic at different times. Crowds outside of nightclubs only form in the evening. Fewer people milling about in certain spots during certain times of day, etc.


This is where a company hires someone like me to solve these "issues"....
If you think you can improve on it, mod something as a proof of concept, record the processor cycles required, RAM usage, overall performance hit, etc. and send it in. Many studios are willing to work with people if they have a talent for certain aspects of design or programming. CDPR just went into business with modder that did some amazing texture work.
 
What about short low level cycles? IMHO lack of those is more visible than full 24h cycle. If you frequent an area or linger a little it's very obvious that everyone is stuck in the same micro-loop. Messing with their phone, walking back and forth, operating vending machine. For a minute, two, ten, 30.

AFAIK the game doesn't have dynamic spawn and despawn mechanisms. This makes it hard to hide this. As soon as your surroundings are populated, everyone's stuck doing whatever they're assigned, without the escape of any doors, NCART stations, taking a bus or car.
mrmeeseeks.jpeg


P.S. SigilFrey, can you point me to a tutorial relating modding NPCs? I guess it requires some questphase editing. So far i've had no luck with any scripting resources, only model swaps and existing system parameter tweaks.
 
They do contain schedules, as addressed earlier, just not individual schedules for every single NPC spawned. Rather, the sections of the city see different sorts of traffic at different times. Crowds outside of nightclubs only form in the evening. Fewer people milling about in certain spots during certain times of day, etc.



If you think you can improve on it, mod something as a proof of concept, record the processor cycles required, RAM usage, overall performance hit, etc. and send it in. Many studios are willing to work with people if they have a talent for certain aspects of design or programming. CDPR just went into business with modder that did some amazing texture work.

Remember... Today's success of Cyberpunk 2077 is a reflection of the great strides of "inside the box" approaches to engineering and direction.

Remember... it is best to code for every leaf on the tree for the experience to be real.

Remember... consultants need not know.
 
Remember... Today's success of Cyberpunk 2077 is a reflection of the great strides of "inside the box" approaches to engineering and direction.

Remember... it is best to code for every leaf on the tree for the experience to be real.

Remember... consultants need not know.
I am now eagerly looking forward to the release of your next game!
 
all NPCs must adhere to the same way basic pathing. In a manner of speaking, we all walk with 2 legs and try not to stumble, there is no NPC that's suddenly going to fly (no extra processing required to take that into account). I know I'm being silly but since these NPCs act in the same way, they have to, I believe if CDPR had devised a better pathing algorithm, it wouldn't necessarily take an exponential rocket curve in terms of processing.

But, this is only about how they walk from point A to B. Depending on how the other multitude of game world actions are created, interfacing NPC behaviour with let's say a gunshot, should take into account
* where are they on their route
* the range (of the entity firing the shot)
* the proximity to other NPCs
And you don't want NPCs in the same range to display the same behaviour because that's takes you into uncanny valley effect, so you need
* multiple possible reactions of the same exact action
* different alternatives to a base path

IF the basic pathing algorithm isn't well optimized (which it is NOT in NC), interfacing becomes a problem.
Which is why I hope that, because the next patch takes such a long time to release, it improves upon this. I really don't like seeing uncanny short pathing for NPCs, I don't like it when they walk over benches or other objects like they're not there. Let's breathe some life into this world CDPR!
 
You can fly with the bike. Near Judy's house there is a point where you can drop from the highway to the suburbs tens of meters and continue riding the bike as if nothing had happened. You either love it or hate it.
 
You can fly with the bike. Near Judy's house there is a point where you can drop from the highway to the suburbs tens of meters and continue riding the bike as if nothing had happened. You either love it or hate it.
Why does that not suprise me you can do this :LOL:
 
Tricky physics...
photomode_10062022_042546.png
photomode_10062022_071743.png
photomode_10062022_071935.png


Some objects may seem more climbable than they appear.

Also trying to recreate a moment a newly requested Delamain is hurled down from the sky. Unsure if it is the intersection of multiple possible summoning locations, the amount of objects, or the original location vs new location. My guess is near equidistant creation locations of various heights. Perhaps this was just a one time occurrence.
 
Top Bottom