The Forums Are Now Closed!

The content will remain as a historical reference, thank you.

Enhanced AI Mod v0.26.35 Release 2/16/2011

By on November 27, 2010 11:12:28 PM from Demigod Forums Demigod Forums

Peppe

Join Date 03/2006
+49

Enhanced_AI_v0.26.35:

http://peppe-dg-mods.googlecode.com/files/Enhanced_AI_v0.26.35.zip

http://peppe-dg-mods.googlecode.com/files/Enhanced_AI_v0.26.35.exe

 

 

AI will work hard to get map control.

AI will actively work to keep portal counts even or in its favor. 

AI will save for critical upgrades like currency, so it can purchase it at or near warrank 3.

AI generals will consider what healer idols the rest of the team owns when making purchases.

AI generals will send one of their healing idols to an AI teammate on summoning (when 2 are summoned) and on teleport.

Locked Post 398 Replies +3
Search this post
Subscription Options


Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 8:52:26 PM from Demigod Forums Demigod Forums

 

Any issues with other projectile based demigods?

 

The ranged demigods all share a ranged attack action to handle their auto attack.  I don't recall making major edits to the action, the primary change was to make each action shorter, so the enhanced ai demigods go into and out of all actions more often than the standard AI.    I have never looked at how damage is applied, but I don't think the attack action ending every second instead of every 4 seconds would have an affect on applying damage.

 

There may also have been some tweaks on the distance the demigod will stand to begin shooting.  I believe the default is max range I tinkered back and forth many times with the AI using the default vs being a little closer.  I mention this because maybe at max range the shots should hit, but are thrown out by whatever applies damage?

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 8:55:44 PM from Demigod Forums Demigod Forums

I don't know if you saw my edit, but yes. This happens with the QoT & TB. I think I saw it with Reg, but I'm not sure.

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 9:09:20 PM from Demigod Forums Demigod Forums

Sounds like the attack action is too short. If i recall in older versions the shortest i made these actions was 2 seconds, but they were further lowered to encourage the AI to select more time critical actions like TPing in to defend something.

I'll tinker a little and maybe set the action to be a hair longer than the attack speed if that is stored in seconds somewhere.

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 9:50:14 PM from Demigod Forums Demigod Forums

Thanks for checking this out, fellas.  Much appreciated!

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 10:12:37 PM from Demigod Forums Demigod Forums

Yep, that sounds about right.  I don't know enough about AI targeting to know exactly how to fix that, but I can take a look.

Without the 1.04 UberFix, this would probably result in an AI QoT having a ridiculous rate of fire, since QoT has no attack animation interrupt set up and her attacks all go through successfully even if they're stopped.

 

Edit: Whoops, missed that next page.  Welcome back Peppe.
If this is happening with vanilla DG AI as well as the mod, let me know what you change to resolve it, and I'll add that to the Uberfix as well.

I'll tinker a little and maybe set the action to be a hair longer than the attack speed if that is stored in seconds somewhere.

unit.Sync.AttackTime should be the ROF delay in seconds.  This won't always be accurate for QoT (I'm thinking about redoing my fix for this in the UberFix), so make sure you add at least 0.2s or so.

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 10:29:31 PM from Demigod Forums Demigod Forums

Updated.

 

Enhanced_AI_v0.26.34:

http://peppe-dg-mods.googlecode.com/files/Enhanced_AI_v0.26.34.exe

http://peppe-dg-mods.googlecode.com/files/Enhanced_AI_v0.26.34.zip

 

I thought I still saw issues basing it on attack speed, so kept it simple and just used a fixed time.  All attack actions now have 3 seconds to run.  Default was 4 seconds for most, so it is a little less sticky than base AI, but should spend enough time in the auto attack actions to do damage. I say sticky because the AI will not consider other actions while it has a current action.

AttackActions.lua was the only file changed.  Don't think there is anything for uberfix to change as the default actions generally run 4 seconds.

For both vanilla and enhanced AI an attack likely animates, but fails to hit whenever the attack action ends.  So if for example an AI can attack every 1.5 seconds, but the auto attack actions are set to 4 seconds the AI will abort every third swing when the action ends to select a new action even if it goes into the same action and selects the same target. 

I guess ideally each attack action would only end after completing an attack. 

 

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 10:34:49 PM from Demigod Forums Demigod Forums

Thanks for checking in and taking the time to make an update, Peppe!  Much appreciated.  I'll get this added to my combined installer asap.  THANK YOU!

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 10:46:06 PM from Demigod Forums Demigod Forums

I guess ideally each attack action would only end after completing an attack.

Add an OnWeaponFire callback to the demigod at the beginning of the action that sets some var (either in the AI class or on the demigod) that the attack action waits for.  Then remove the callback (or make the callback self-removing?  I think that's possible) before switching actions.

Reason for Karma (Optional)
Successfully updated karma reason!
February 15, 2011 10:54:09 PM from Demigod Forums Demigod Forums

On second look, both of the hero attack actions seem to be weighted based on how many attacks the demigod can perform in the alotted time, so shortening the time and/or making an action duration single-shot would both have negative affects on weight calculation for that action.  So it could be done, but CalculateWeights for those actions would also have to be updated to consider a different set of factors.

If you want to try a per-shot attack action, I can show you how to use the callback to do it.

Edit: I just noticed that their timers are using 0.2 second waits.  That, uh, doesn't always work.  Sometimes WaitSeconds(0.2) will only wait one tick instead of two, which means a 4 second timer may actually be a 2 second timer.  If you're curious as to whether or not this is happening, add a print message to the ActionFunction loop that reports GetGameTick() and/or the durationTimer variable.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 12:00:48 AM from Demigod Forums Demigod Forums

Welp.  Confirmed.

Those waits are waiting 0.1 seconds, not 0.2.  That's why you're having trouble with this.  Every action timer that waits 0.2s will only be waiting half that long.  This also means that every action loop is going 10 times a second instead of only 5, which is probably unnecessary and is incurring a performance hit in a multi-AI game.

If you change all of the waits to 0.3s, that -should- fix it, but I'd test to make sure.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 12:17:05 AM from Demigod Forums Demigod Forums

Added this version to the combined installer.  Happy to add an updated version if you release and happy to test (just let me know if you need some testing).  Thanks.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 5:44:12 PM from Demigod Forums Demigod Forums

Test using version 0.26.34

cataract (nightmare ais - all tb)

Result:  well... I saw the occasional miss here and there, but its similar to what is in the vanilla game (so thats at a tolerable level)... the downside, though... and its a bit of one is that the fix seems to slow down the auto attacks quite a bit.  It looks like they literally attack, then wait .25-.75 seconds or so, then attack again instead of a steady flow of attacks.  It definitely occurred consistently on ice tb. 

Here's a replay - watching for about 1 minute on the left side should make things clear (I just aa'd a tb as an ice tb so you can easily see the rate of fire differences).  http://www.box.net/shared/sdjlga7i0o

edit - I made the changes miri described in a quick test build and noticed quite a bit of improvement.  Still the occassional misses, but that seemed to get the attack speed back up to normal or very close to normal.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 8:18:52 PM from Demigod Forums Demigod Forums

I ran a similar test last night and didn't notice a slow down. I guess I should check it out again.

 

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 9:30:50 PM from Demigod Forums Demigod Forums

Again, I'm far from an expert on the AI, and even after looking at the AI action code I still don't understand exactly how repeated attack actions would mesh together, but I don't see anywhere where another order is issued to the AI between actions, so as long as the AI has an attack/assassinate goal, it should seamlessly process consecutive attack actions.

Therefore, I can only conclude that having the action's timer come due in the middle of an attack animation or just before an actual fire event begins is the only thing that would cause interrupted or slower attacks now.  This could be completely off base, and maybe it's switching actions to and from the attack actions and I'm just not aware of it, but if it's sticking with the attack actions, and things are going slowly/being interrupted, I'd guess that this is a function of asymmetric action timer / ROF timer.

 

There are a few ways to fix this.  I'm not sure that a one-shot action timer is a good solution, because this would radically increase the amount of processing overhead once the AI reached a high rate of fire.

However, it should still be possible to have a semi-enforced timer length, while making the exact action timer a multiple of the demigod's ROF.  The simplest way would be:

Code: c++
  1. local duration = 0.1 + unit.Sync.AttackTime * math.floor(ActionDuration / unit.Sync.AttackTime)
With a default ActionDuration of 3s, this would produce values at ROF delays like so:
1.5: 3.1
1.3: 2.7
1.1: 2.3
1.0: 3.1
0.7: 2.9
0.5: 3.1

Make sense?  It wouldn't require any significant changes to the architecture of the action functions, or any serious re-evaluation of weight calculation, but it would keep the timer from straddling an attack event in most cases.

 

Another, possibly simpler and more effective way to do this that just occurred to me is to have every attack action set a var on the unit or its brain that holds a handle to or entity id of the last target that it was assigned, and clear this out using a ~.3s wait thread at the end of the action.  If an attack action finds this value (which would only happen when going straight from attack action to attack action) and it is equal to the assigned target, it kills the thread and skips the IssueClearCommands/IssueAttack part of the action function, so attacks simply proceed seamlessly until a non-attack action or an action against a different target is issued.

 

Edit: Oh, crud.  The ActionWrapper thread in HeroAIActions.lua DOES do an IssueClearCommands.  Great.  So the timer-manipulation fix is the only viable one, because there's no way to stop it from clearing orders and halting an in-progress attack without overriding ActionWrapper and adding some kind of action-specific exception where commands are not cleared if it's an attack action (whereby each attack action would need to be altered to do their own conditional clear commands based on whether or not they have a target carried over from a previous action).

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 9:44:33 PM from Demigod Forums Demigod Forums

All you should need to implement the variable timer is to replace this line in each attack action:

Code: c++
  1.         while not unit:IsDead() and durationTimer < actionBp.ActionDuration do
..with these two:
Code: c++
  1.         local duration = 0.1 + unit.Sync.AttackTime * math.floor(actionBp.ActionDuration / unit.SyncAttackTime)
  2.         while not unit:IsDead() and durationTimer < duration do
Along with the WaitSeconds(0.3), of course.  Assuming 0.3 is enough to produce an 0.2 wait.

 

Alternate duration calculation that rounds up instead of down:
1.5: 3.1
1.3: 2.7
1.1: 3.4
1.0: 3.1
0.7: 2.9
0.5: 3.1

Code: c++
  1.         local duration = 0.1 + unit.Sync.AttackTime * math.floor(0.5 + (actionBp.ActionDuration / unit.SyncAttackTime))
Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 9:52:59 PM from Demigod Forums Demigod Forums

Think i am seeing some better behavior if you kill the time on the calculate weights function.

AttackActions.lua Line 624:

        return { KillHero = returnValue + agent.WorldStateData.HeroKillBonus }, actionBp.ActionDuration

To:

        return { KillHero = returnValue + agent.WorldStateData.HeroKillBonus }

 

This change seems to let the ActionFunction run to conclusion.  I always looked at the time component on the calculate weights functions as a timeout.  So the ActionFunction could loop or get stuck doing something, but the timeout would still be checked and kill the action preventing a totally stuck AI.

 

I'll run some more tests, but see what you think.

 

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 10:06:48 PM from Demigod Forums Demigod Forums

That's only used for one thing as far as I can tell.

It sets a value called self.ActionTime, that is then not used by anything in the lua.  So that's right out.

That leaves the goal priority increase that it multiplies: look at lines 226 and 246 of HeroAIWorldState.lua.

 

If I'm understanding correctly, that time value just acts as an exponent to the insistence of that particular action's goal (Assassinate for these actions, I guess?).  So leaving it omitted (auto-set to zero) either removes or simply doesn't increase insistence for that goal.

This is kind of gibberish to me, because I don't know what these goal values look like or how exactly they're used.  If I had to guess, I would say this would let the AI switch action types away from attack more easily?

 

What do you mean when you say you're seeing better behavior as a result of this?

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 10:17:03 PM from Demigod Forums Demigod Forums

"What do you mean when you say you're seeing better behavior as a result of this?"

 

I took off those time values on each attack action and the auto attack action only got interrupted to use a skill. 

I saw some issue swith TB swapping fire/ice mode, but the attacks all looked good.

 

If its not a timeout then I don't know why the behavior changed.   Setting it to something under a second gets mostly interrupted attacks... leaving it off gets nearly all completed attacks.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 10:34:02 PM from Demigod Forums Demigod Forums

Whoops, I missed a use of that ActionTime value - HeroGOAP.lua, lines 1212 and 1247.  Not that I really understand how it's being used, but you're right in assuming that it does time something.

 

Edit: Actually, I don't think it's a timer, even there.  It doesn't involve any waits.  This appears to be a planning function only, and not something that loops constantly.

If that change works, and doesn't have any unintended consequences, then I guess that's good enough.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 10:59:00 PM from Demigod Forums Demigod Forums

 

I am not seeing anything terrible, so i'll release to Pacov for testing

 

http://peppe-dg-mods.googlecode.com/files/Enhanced_AI_v0.26.35.zip

http://peppe-dg-mods.googlecode.com/files/Enhanced_AI_v0.26.35.exe

 

Attack actions tweaked.   Timeouts? removed.  Adjusted wait times in loops.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 11:03:09 PM from Demigod Forums Demigod Forums

Man, my head hurts just from an hour of looking through HeroGOAP/StrategicGOAP/HeroAIWorldStates.  And I still don't know what anything does.  I don't know who did the AI for Demigod, but I can definitely see why they had trouble refining its behavior.  Yikes.

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 11:13:19 PM from Demigod Forums Demigod Forums

I am not seeing anything terrible, so i'll release to Pacov for testing

heh... we all do our part   Will test tomorrow. 

Added to the combined installer.

Outside of tb's aa, is there anything else you think I should take a look at that might be impacted by the changes?

Reason for Karma (Optional)
Successfully updated karma reason!
February 16, 2011 11:33:52 PM from Demigod Forums Demigod Forums

Quoting miriyaka,
Man, my head hurts just from an hour of looking through HeroGOAP/StrategicGOAP/HeroAIWorldStates.  And I still don't know what anything does.  I don't know who did the AI for Demigod, but I can definitely see why they had trouble refining its behavior.  Yikes.

Yeah, i tried to decipher the section you pointed to in hero goap.   In my head I think that section checks the elapsed time of the current action and if the elapsed time is higher than the weight time it does that depth-1 killing the current action.  The depth either goes into the next action or goes to a no action state to select a new action.  Or it could be doing something entirely different

 

Quoting OMG_pacov,

I am not seeing anything terrible, so i'll release to Pacov for testing
heh... we all do our part   Will test tomorrow. 

Added to the combined installer.

Outside of tb's aa, is there anything else you think I should take a look at that might be impacted by the changes?

TB's is easiest to spot, but it looks like the auto attack issue was affecting every demigod. 

I made the change in all the auto attacks (which covers all the target types) and ran a couple games locally and didn't spot any issues.  They will interrupt an attack to use a skill, but i think that is ok.

Reason for Karma (Optional)
Successfully updated karma reason!
February 17, 2011 12:06:10 PM from Demigod Forums Demigod Forums

Quoting Peppe,

I guess ideally each attack action would only end after completing an attack. 

 

Heh. every demigod has a different attack length for their animation, and it changes as the game progresses. (items / attack speed increase) and can be affected by things like ooze.

I don't think this is something that you could "guestimate" with a timer.

eg: If TB is being ooze IV'd while shooting at a weak target at max range, the timer's time is sufficient?

Reason for Karma (Optional)
Successfully updated karma reason!
February 17, 2011 6:00:55 PM from Demigod Forums Demigod Forums

0.26.35 tested:

cataract (high towers)

Ai normal hp/gold.  All ai's nightmare and tb

human = tb

issue appears resolved.

Reason for Karma (Optional)
Successfully updated karma reason!
Stardock Forums v1.0.0.0    #108432  walnut2   Server Load Time: 00:00:00.0000485   Page Render Time: