When does the game trigger an AI package?

Post » Sat Feb 19, 2011 3:26 am

I'm curious to know at what point the game decides to activate an NPC's AI. I'll need to set the scene before hoping anyone can answer knowledgeably though. So, here's a detailed example scenario. This is not a trick question, please assume that when I say a door links cell A to cell B, there is therefore a door in cell B linking back to that door in cell A. This saves me having to actually mention each door-link twice in the following example:

An NPC has their Editor Location in an Upstairs interior cell.
This Upstairs interior cell has a door linking to a Downstairs interior cell. No other doors exist to link out of this interior.
The Downstairs interior cell has a door linking to the Imperial City, Talos Plaza worldspace.

The NPC has a primary (overriding) AI package instructing it to wander for several hours each day in the Market District worldspace, starting at 10am. It also has a secondary AI package instructing it to wander at Editor Location at all times (i.e. when no overriding AI package is running - when the primary package time expires, the NPC will therefore return to the Upstairs interior cell).
The NPC does NOT have "No low level processing" ticked - thus the game should process the NPC's AI without requiring the player to be in the same cell as the NPC.

Now, with this scenario, the NPC should either be in the Upstairs interior cell, or wandering in the IC Market District worldspace, or travelling between the Upstairs interior cell and IC Market worldspace, which would involve travelling through the Downstairs interior cell, through the Talos Plaza worldspace, and through either the Elven Gardens District worldspace or the Imperial Palace District worldspace.

So, when does the game begin to process this NPC's AI?

Let's say the player is presently in the Market District (having Fast Travelled there from anywhere outside the Imperial City), and it's 11am.
The NPC should now either be in the Market District, or travelling to the Market District.
But for this to be true, the game has to have loaded that NPC and its AI packages, which would require the game to scan all AI packages and pick out any which reference the Market District or an object placed in the Market District.

Let's say the player is presently in the Imperial Palace District (having Fast Travelled there from anywhere outside the Imperial City), and it's 11am.
Typically, I find NPCs prefer to travel between Districts via the Palace District, so let's assume for this scenario that the NPC always travels through the Palace District.
Again, the NPC should now either be in the Market District, or travelling to the Market District.
But this would require the game to scan all AI packages and pick out any which reference other worldspaces (and interiors of course) directly LINKED to the Palace District. This would mean a LOT of AI packages being activated and processed which potentially aren't needed to be running, especially in a city worldspace like the Palace District, which is directly linked to six other IC worldspaces - also especially in a city worldspace which contains a lot of buildings and thus links to many interiors.

How much of a strain does a mod adding many new NPCs in new interiors to various Districts in the Imperial City put on a gamer's computer? Will every new NPC have their AI processed pretty much the whole time the player is in the IC, just in case the player happens to travel into a worldspace or interior which one of the NPC's AI packages targets? Or, will the game only process the AI for NPCs whose AI targets the worldspace the player is in right now, and not any whose AI targets worldspaces directly linked to the one the player is in? In which case, where do interiors play into this? Does the game load AI for all NPCs placed in the interiors directly linked to the worldspace the player is in right now if their AI targets the worldspace the player is in, but not if their AI targets worldspaces directly linked to the worldspace the player is in? What about interiors linked to interiors linked to the worldspace the player is in, does the game effectively "tunnel" through interior-links in search of NPC/AI packages to trigger, or only go one interior cell deep? Does the game not load NPCs/AI packages for those in interior cells directly linked to the worldspace the player is in at all, unless the linking door is in exactly the same cell as the player? Or within a one-cell radius of the player (i.e. 3x3, 9 cells centred around the player)?

Let's say I think too much (having Bus Travelled to work, from anywhere nowhere near where I work), and it's 11am.
Have I missed my stop? ...several times over? But that's going off-topic, so better not discussed.

So, anyone have any thoughts on this? I do hope I haven't rambled on too much to hold anyone's attention this far! Maybe there's a really well known answer already, and I didn't even need to go beyond the topic title to get my answer...
User avatar
Gavin Roberts
 
Posts: 3335
Joined: Fri Jun 08, 2007 8:14 pm

Post » Fri Feb 18, 2011 8:55 pm

An AI package is triggered when the game updates the actor's AI and the conditions for the package are true.
Your question seems to be about performance more than timing. Each actor has an AI Process which is assigned a priority based on proximity to the player, from low, middle-low, middle-high, and high. Only processes with high priority (e.g. in the same cell as the player) are processed every frame. Low processes get updated as infrequently as every (in-game) half-hour IIRC, and the level of detail in their processing is considerably reduced.
The game is built that way to address the potential problems you brought up in your OP. If you're worried about performance, avoid having a large number of NPCs in a single cell, as they'll all be in a high process state.
User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am

Post » Sat Feb 19, 2011 5:20 am

This suggests that the game monitors all NPCs at all times, rather than monitoring the AI packages themselves. All NPCs (excluding those marked with "No low level processing") beyond a certain distance to the player then are ticking away in memory at a minimum of low priority at all times, even if the player is in Anvil and an NPC is placed in Leyawiin with AI that only relates to the Leyawiin worldspace and Leyawiin interiors.

Is this correct, to the best of your knowledge? Or is there some point at which even low priority gets dismissed as too far from the player for the game to maintain their AI? What about NPCs in interiors which are not linked in any way to any part of the world accessible by the player (ignoring the possibility of script-based travel)?

For example, a mod such as Better Cities, where all the new NPCs and all new interiors are stored in a single ESM, and various different ESPs link these interiors to the world, meaning that depending upon the combination of ESPs chosen by the player, some interiors may be inaccessible. Would the NPCs in these inaccessible interiors still be processed at low priority by the game? Should these NPCs have no AI at all in the ESM, and only have AI added by the ESP(s) which touch the interiors in which they are placed, thus ensuring that the game does not waste processing and memory on NPCs which the player should never meet?
User avatar
TWITTER.COM
 
Posts: 3355
Joined: Tue Nov 27, 2007 3:15 pm

Post » Sat Feb 19, 2011 9:26 am

As far as I know NPCs with no low level processing never have their AI processed unless they are in the loaded area. I think I remember that when I started modding I tried to get a package working that made an NPC leave the house. I didn't enable low level processing and the NPC never left the house unless I entered the house, no matter how long I waited or how close to the house I was. Would probably also be overkill to process AI for all the bandits, conjurers and whatever else there is, even if it is only once in a while. But I might be wrong, it's been a long time since I tested this and I can't remember how carefully I tested it.
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Fri Feb 18, 2011 10:15 pm

All NPCs (excluding those marked with "No low level processing") beyond a certain distance to the player then are ticking away in memory at a minimum of low priority at all times, even if the player is in Anvil and an NPC is placed in Leyawiin with AI that only relates to the Leyawiin worldspace and Leyawiin interiors.


Yep, that's pretty much it. If you don't select "no low level processing" then their AI is processed at all times, even when you're not there and their AI has nothing to do with where you are currently. Makes no difference if the NPC is in an inaccessible cell or not. They will be processed, even if it's only enough for the game to realize they have no path out.

Should these NPCs have no AI at all in the ESM, and only have AI added by the ESP(s) which touch the interiors in which they are placed, thus ensuring that the game does not waste processing and memory on NPCs which the player should never meet?


If your concern is for AI performance on unlinked modules, I'd say yes. Mark them as "no low level processing" AND remove their AI packs in the ESM. Then toggle that flag on them in the ESP and add whatever packs they need there. You're probably safe to leave the vanilla NPCs alone and would only need to do this on the ones you're adding.
User avatar
David John Hunter
 
Posts: 3376
Joined: Sun May 13, 2007 8:24 am

Post » Sat Feb 19, 2011 2:33 am

Yep, that's pretty much it. If you don't select "no low level processing" then their AI is processed at all times, even when you're not there and their AI has nothing to do with where you are currently. Makes no difference if the NPC is in an inaccessible cell or not. They will be processed, even if it's only enough for the game to realize they have no path out.



If your concern is for AI performance on unlinked modules, I'd say yes. Mark them as "no low level processing" AND remove their AI packs in the ESM. Then toggle that flag on them in the ESP and add whatever packs they need there. You're probably safe to leave the vanilla NPCs alone and would only need to do this on the ones you're adding.


Regards vanilla NPCs... that's a given :) wouldn't fiddle with them, that's for other mods to do.

Does anyone disagree with Arthmoor? You've all made sense and none of you have contradicted each other yet. Arthmoor's final suggestion is precisely what I've been considering doing in Better Cities recently.

EDIT
And how much of a difference would it really make? Is it worth the effort in the first place? Maybe it would be a whole lot of effort, with minimal benefit, especially since most BC-users tend to use the complete package anyway... hmm.
User avatar
Nichola Haynes
 
Posts: 3457
Joined: Tue Aug 01, 2006 4:54 pm

Post » Sat Feb 19, 2011 11:21 am

One thing about the AI setup I haven't found a good answer to is "rush hour syndrome".

Because the scheduled AI packages change on the hour, when a re-evaluation happens, you always get a bunch of NPC's start to move to a new location at the same time. If they're routed through a restricted area you get traffic jams at the doors etc. with everyone lined up to go through. Staggered hours just means a lot of small instances of this, rather than one big one, so it can end up being more noticeable that way, because you're more likely to see it happen.

There doesn't seem to be a good way to provide alternate routes to spread the commuters out, either. The path finding algorithm works the same way every time, so they all pick the same one once their paths cross, and the path grids make them line up behind each other, so they move in trains, which looks unrealistic. Short commutes help, so the paths don't get so much chance to join up.
User avatar
Horse gal smithe
 
Posts: 3302
Joined: Wed Jul 05, 2006 9:23 pm

Post » Sat Feb 19, 2011 5:25 am

I'm curious to know at what point the game decides to activate an NPC's AI. I'll need to set the scene before hoping anyone can answer knowledgeably though. So, here's a detailed example scenario. This is not a trick question, please assume that when I say a door links cell A to cell B, there is therefore a door in cell B linking back to that door in cell A. This saves me having to actually mention each door-link twice in the following example:

An NPC has their Editor Location in an Upstairs interior cell.
This Upstairs interior cell has a door linking to a Downstairs interior cell. No other doors exist to link out of this interior.
The Downstairs interior cell has a door linking to the Imperial City, Talos Plaza worldspace.

The NPC has a primary (overriding) AI package instructing it to wander for several hours each day in the Market District worldspace, starting at 10am. It also has a secondary AI package instructing it to wander at Editor Location at all times (i.e. when no overriding AI package is running - when the primary package time expires, the NPC will therefore return to the Upstairs interior cell).
The NPC does NOT have "No low level processing" ticked - thus the game should process the NPC's AI without requiring the player to be in the same cell as the NPC.

Now, with this scenario, the NPC should either be in the Upstairs interior cell, or wandering in the IC Market District worldspace, or travelling between the Upstairs interior cell and IC Market worldspace, which would involve travelling through the Downstairs interior cell, through the Talos Plaza worldspace, and through either the Elven Gardens District worldspace or the Imperial Palace District worldspace.

So, when does the game begin to process this NPC's AI?

Let's say the player is presently in the Market District (having Fast Travelled there from anywhere outside the Imperial City), and it's 11am.
The NPC should now either be in the Market District, or travelling to the Market District.
But for this to be true, the game has to have loaded that NPC and its AI packages, which would require the game to scan all AI packages and pick out any which reference the Market District or an object placed in the Market District.

Let's say the player is presently in the Imperial Palace District (having Fast Travelled there from anywhere outside the Imperial City), and it's 11am.
Typically, I find NPCs prefer to travel between Districts via the Palace District, so let's assume for this scenario that the NPC always travels through the Palace District.
Again, the NPC should now either be in the Market District, or travelling to the Market District.
But this would require the game to scan all AI packages and pick out any which reference other worldspaces (and interiors of course) directly LINKED to the Palace District. This would mean a LOT of AI packages being activated and processed which potentially aren't needed to be running, especially in a city worldspace like the Palace District, which is directly linked to six other IC worldspaces - also especially in a city worldspace which contains a lot of buildings and thus links to many interiors.

How much of a strain does a mod adding many new NPCs in new interiors to various Districts in the Imperial City put on a gamer's computer? Will every new NPC have their AI processed pretty much the whole time the player is in the IC, just in case the player happens to travel into a worldspace or interior which one of the NPC's AI packages targets? Or, will the game only process the AI for NPCs whose AI targets the worldspace the player is in right now, and not any whose AI targets worldspaces directly linked to the one the player is in? In which case, where do interiors play into this? Does the game load AI for all NPCs placed in the interiors directly linked to the worldspace the player is in right now if their AI targets the worldspace the player is in, but not if their AI targets worldspaces directly linked to the worldspace the player is in? What about interiors linked to interiors linked to the worldspace the player is in, does the game effectively "tunnel" through interior-links in search of NPC/AI packages to trigger, or only go one interior cell deep? Does the game not load NPCs/AI packages for those in interior cells directly linked to the worldspace the player is in at all, unless the linking door is in exactly the same cell as the player? Or within a one-cell radius of the player (i.e. 3x3, 9 cells centred around the player)?

Let's say I think too much (having Bus Travelled to work, from anywhere nowhere near where I work), and it's 11am.
Have I missed my stop? ...several times over? But that's going off-topic, so better not discussed.

So, anyone have any thoughts on this? I do hope I haven't rambled on too much to hold anyone's attention this far! Maybe there's a really well known answer already, and I didn't even need to go beyond the topic title to get my answer...

The answer is... 42.
User avatar
koumba
 
Posts: 3394
Joined: Thu Mar 22, 2007 8:39 pm

Post » Sat Feb 19, 2011 7:08 am

As far as I know NPCs with no low level processing never have their AI processed unless they are in the loaded area. I think I remember that when I started modding I tried to get a package working that made an NPC leave the house. I didn't enable low level processing and the NPC never left the house unless I entered the house, no matter how long I waited or how close to the house I was. Would probably also be overkill to process AI for all the bandits, conjurers and whatever else there is, even if it is only once in a while. But I might be wrong, it's been a long time since I tested this and I can't remember how carefully I tested it.


Well, there is modder resource called NPC ACE - NPC Advanced Control Engine which I think process AI even if NPC's are not in the loaded area. (I mean those AI and NPC which are integrated to NPC ACE engine). If only someone with enough skill could try to make mod with it ;).
http://www.tesnexus.com/downloads/file.php?id=20878
User avatar
Kaley X
 
Posts: 3372
Joined: Wed Jul 05, 2006 5:46 pm

Post » Fri Feb 18, 2011 9:14 pm

Well, there is modder resource called NPC ACE - NPC Advanced Control Engine which I think process AI even if NPC's are not in the loaded area. (I mean those AI and NPC which are integrated to NPC ACE engine). If only someone with enough skill could try to make mod with it ;).
http://www.tesnexus.com/downloads/file.php?id=20878


I'd be more interested in something which did the exact opposite - stripped from in-game memory all NPCs whose AI doesn't need to be processed at all (due to being a long way away).
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm


Return to IV - Oblivion