ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Thu Nov 15, 2018 6:03 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Enemy AI and Stealth
PostPosted: Thu Apr 02, 2015 4:42 pm 
Offline
Uruivellas

Joined: Wed Apr 30, 2008 5:55 pm
Posts: 708
I think stealth can be better.

Here's how npcs currently work (if I've read the code right):

If they don't have a target (or a 10% chance if they do), they set their target to the closest hostile in their field of view (out to their sight range, usually 10, but blocked by walls), regardless of stealth/invisibility/etc.

When an npc loses sight of their target (from walking behind a wall, stealth, or whatever), they try to guess its position. They have a radius X that goes up by 1 each turn, starting from 1 on the first turn they fail to see you (Or 3 if they've never seen you before). They pick a random position within X spaces of your true position, and average that with whatever their last guess was. That's where they treat you as being.

I didn't go deep into target passing, but it seems pretty good to me when I look at it. :) You can't pass your target if you can't see your target currently.

Here's what I don't like about it:
  • NPCs always know you're there if you enter their field of view, even if you have 9999 stealth. It starts out slightly inaccurate, but they are still alerted to your presence.
  • They can divine your location if you teleport halfway across the map.
  • The averaging doesn't work for large jumps. If I make a jump they'll target the space roughly halfway between for a turn, which doesn't make much sense.


Here's my suggestions for making stealth better:
  • NPCs have a confidence level, which starts at 50. Every turn, this is decreased by the distance from their estimated target to the target's actual position. So in an actual combat it'll slowly decrease, but if you teleport away they'll quickly lose confidence.
  • NPCs with at least double confidence and the same target can pass their target info on. So a group of enemies that can't see the target will still spread out over time, but if one enemy can see and the rest can't, they'll periodically retarget based on what the seeing enemy tells them.
  • NPCs that run out of confidence lose their target.
  • When an NPC first targets something they can't see, they start with a confidence of 10.
  • The retargeting chance is increased when confidence is low. Note that this can retarget the same thing, which will raise the confidence back up to 10 and reset their estimated position. This is essentially the npc noticing a "new" enemy and forgetting about the old one.
  • The estimated position does not take the real position into account. Instead, it deviates by sqrt(51 - confidence) every turn. We'll rely on the retargeting to deal with updating the true position.

_________________
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)


Top
 Profile  
 
 Post subject: Re: Enemy AI and Stealth
PostPosted: Thu Apr 02, 2015 5:06 pm 
Offline
Wyrmic

Joined: Tue Feb 15, 2011 12:01 am
Posts: 282
grayswandir, I really like the emergent properties of this proposal! I'm not clear on a couple of basic matters, though. Maybe you could talk me through this like I'm 7.

What actually happens if the player is stealthed, wanders through a corridor and steps into range 10 of an enemy the player's never seen before?

grayswandir wrote:
  • NPCs have a confidence level, which starts at 50. Every turn, this is decreased by the distance from their estimated target to the target's actual position. So in an actual combat it'll slowly decrease, but if you teleport away they'll quickly lose confidence.

Will it be on to me from Turn 1? I think a true stealth mechanic should offer the possibility of creeping up on foes completely unawares. That's one of the key things that makes stealth gameplay fun.

If the enemy starts moving about, no matter how incompetently, whenever I enter sight range (and while supposedly fully hidden), then that's really going to break the immersion.

grayswandir wrote:
  • The retargeting chance is increased when confidence is low. Note that this can retarget the same thing, which will raise the confidence back up to 10 and reset their estimated position. This is essentially the npc noticing a "new" enemy and forgetting about the old one.

So assuming that sometimes our stealth will mean the enemy is unaware of any threat whatsoever, how is this simulated?

grayswandir wrote:
  • The estimated position does not take the real position into account. Instead, it deviates by sqrt(51 - confidence) every turn. We'll rely on the retargeting to deal with updating the true position.

This is wonderful, as it means rogues can use their movement capabilities to enhance their deception, which opens up a lot of beautiful synergies within the current stealth classes. As you mentioned, the current system crushes all such possibilities. Roll on the total rework, says I!


Top
 Profile  
 
 Post subject: Re: Enemy AI and Stealth
PostPosted: Thu Apr 02, 2015 5:46 pm 
Offline
Uruivellas

Joined: Wed Apr 30, 2008 5:55 pm
Posts: 708
Nagyhal wrote:
Will it be on to me from Turn 1? I think a true stealth mechanic should offer the possibility of creeping up on foes completely unawares. That's one of the key things that makes stealth gameplay fun.

If the enemy starts moving about, no matter how incompetently, whenever I enter sight range (and while supposedly fully hidden), then that's really going to break the immersion.
Yeah, I forgot to mention exactly what happens here. I'm thinking what would be best is if the npc's confidence level is set based on distance to the target and how badly they fail seeing through stealth. Say, 50 - 5 per space - points they failed the stealth check by. (I'd like to make stealth and see stealth follow the saves curve as well, but right now they don't so big numbers like this are possible, I think). And then, of course, if it's below 0 they don't notice at all.

And the starting estimated position will go through a round or two of movement based on that confidence on first sighting.


Also, I forgot to mention, but an npc taking damage from something when it doesn't have a target will make the npc target the damage source. This is a bit more complicated, as it means that enemies can track you while you've poisoned them. For now I think it'd be best if we just give 50 confidence if they notice you because of damage, and then see how that ends up working.

_________________
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)


Top
 Profile  
 
 Post subject: Re: Enemy AI and Stealth
PostPosted: Thu Apr 02, 2015 6:19 pm 
Offline
Wyrmic

Joined: Tue Feb 15, 2011 12:01 am
Posts: 282
grayswandir wrote:
Yeah, I forgot to mention exactly what happens here. I'm thinking what would be best is if the npc's confidence level is set based on distance to the target and how badly they fail seeing through stealth. Say, 50 - 5 per space - points they failed the stealth check by. (I'd like to make stealth and see stealth follow the saves curve as well, but right now they don't so big numbers like this are possible, I think). And then, of course, if it's below 0 they don't notice at all.

And the starting estimated position will go through a round or two of movement based on that confidence on first sighting.

As long as it doesn't work like the current system where, no matter what you do, enemies start out at maximum awareness of your position and progress toward a lower awareness.

Besides all that, it's the kind of system where it's really easy to fine-tune behaviour after a basic implementation. So I'd guess that any vaguely-defined stealth "feel" could be approximated from this approach

Quote:
  • Also, I forgot to mention, but an npc taking damage from something when it doesn't have a target will make the npc target the damage source. This is a bit more complicated, as it means that enemies can track you while you've poisoned them. For now I think it'd be best if we just give 50 confidence if they notice you because of damage, and then see how that ends up working.

This might be another good argument for implementing our damage source flag idea (i.e., damage is flagged if it's a direct hit, retributory damage, damage from a DoT, etc.)


Top
 Profile  
 
 Post subject: Re: Enemy AI and Stealth
PostPosted: Sat Apr 04, 2015 7:07 pm 
Offline
Uruivellas

Joined: Wed Apr 30, 2008 5:55 pm
Posts: 708
Alright, very rough version done: http://te4.org/games/addons/tome/grayswandir-stealth-rework

You can mess with most of the numbers in the gameplay options.

_________________
Addons: Arcane Blade Tweaks, Fallen Race, Monk Class, Weapons Pack
Currently working on Elementals. It's a big project, so any help would be appreciated. :)


Top
 Profile  
 
 Post subject: Re: Enemy AI and Stealth
PostPosted: Sun Apr 05, 2015 8:45 pm 
Offline
Wyrmic

Joined: Tue Feb 15, 2011 12:01 am
Posts: 282
Lua error detected.

I can get the gist of this - something's setting the confidence value to nil when an Actor tries to get its last seen target - but there's a lot of breadcrumbs to chase and I don't have the time at this moment.

It seems to be happening when I attack an enemy that hasn't got a target.

I hope you'll forgive the emphasis on this question but the bug has made me very suspicious... Is it the case that in testing 10~ levels of rogue you failed to attack a target that completely hadn't seen you?

Nonetheless from watching the assumed locations of these enemies it's clear this is already an improvement over the base stealth implementation! I look forward to more!

Code:
Lua Error: ...ir-stealth-rework/superload/engine/interface/ActorAI.lua:95: attempt to compare nil with number
   At [C]:-1 __le
   At ...ir-stealth-rework/superload/engine/interface/ActorAI.lua:95 aiSeeTargetPos
   At /engine/ai//talented.lua:27 runAI
   At /engine/ai//talented.lua:62 doAI
   At /mod/class/NPC.lua:72 act
   At /engine/GameEnergyBased.lua:129 tickLevel
   At /engine/GameEnergyBased.lua:64 tick
   At /engine/GameTurnBased.lua:51 tick
   At /mod/class/Game.lua:1255
 ----------------  Stack Dump ----------------
--------------- Stack Dump Finished ---------------


Top
 Profile  
 
 Post subject: Re: Enemy AI and Stealth
PostPosted: Mon May 11, 2015 12:58 am 
Offline
Archmage

Joined: Sun Jul 13, 2014 4:09 pm
Posts: 367
*sees this*

Not playing a stealth character this second but... Rah, Rah *cheers you on*

Enemies having too much psychic knowledge of player position when stealthed really is unfortunate, even with the high stealth multiplier helping to kill them in late game.

_________________
ToME Tips - auto-generated spoilers for ToME. - someone else made. I find super awesome, so spreading as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group