Peppe

AI Skirmish Mod .25n Release 11/27/2010 (Major Revision)

AI Skirmish Mod .25n Release 11/27/2010 (Major Revision)

 

Release 25 :  

Mod Version - Skirmish/Online Play: 

http://www.filefront.com/17572530/Skirmish_AI_v25n.zip

http://www.filefront.com/17572533/Skirmish_AI_v25n.exe

 

-This version only works in skirmish mode and has no lobby modifications.

 

Tournament Edition - Offline/Singleplayer:  http://www.filefront.com/17552549/Skirmish_v25_TEd.zip

-This version works in all game modes (tournament/skirmish) and adds some functionality to the auto-fill lobby button.

 

Gameplay should be the same in each version.

 


 

Major Changes:

Version D or later will support replay playback.  Thanks miriyaka

Stuck AI issue fixed by slowing down shopping to one action per second.  AI is a little slower to shop, but plays every game reliably.

AI goals are overridden based on conditions:

  • First 20 seconds of the game -> Shop.
  • Next 10 seconds -> capture flag (gets them all moving to nearest avialable flag).
  • If the enemy has the same or more flags and we are at full health -> capture flags
  • If we are war rank 3 and have enough money for currency -> Shop

The result of the above is a good clean opening.  And the AI spending most of the game capturing flags -> fighting at the flag -> retreating -> healing -> shopping -> leaving shop area -> capturing flags.   If it doesn't take a lot of damage it may only retreat a little and then rejoin the fight.  If it takes a lot of damage it usually retreats to the health crystal.

AI will spend much less time doing nothing or aimlessly wondering around.

 

Minor Changes:

Item weights for common items (health stacking items).  AI's will use similar items, with a few builds picking up class/build specific items.

Most builds have 1-3 achievement items, so the AI will be a little different game to game even if it only has one build for that Demigod type.

 

29,339 views 110 replies
Reply #76 Top

Thanks.  A second set of eyes on the code is great.

I don't recall copying the citadel functions, so if its duplicated its probably just a carry through.  I'll take a look.

I'll see if i can cleanup the capture function to get the flag unit rather than search for the closest flag.

Retreat is mostly controlled by unit sensor.   There is a health sensor in there with a sliding 'oh shit' scale.  When that gets high then it goes and finds the best action to increase health and survival.  You have to look at action weights or goal sets to see what actions are likely to be called.   I think in that sensor file there is also an on take damage function.  You might be able to use that in other places to get a damage rate.

We have gone back and forth on letting the AI teleport in combat vs not.  It is in the teleport to health statue action. By default there is a distance check for enemies that blocks the action.   If i recall it kicks it to a find safe position.  Once it gets to a safe spot it uses the TP, but it may never make it to the safe spot.  Potions had the same enemy check but i took it off as most situation can get off a potion.

I don't remember if i updated them all, but Demigods that have an interrupt skill have some logic in there to interrupt their target when it detects an action started.  For sure UB's grasp is setup for that.

 

Found the other spot the AI interacts with its minions.  On teleport when it completes all minions are told to guard their master.  Going to see if I can count the healers and send some some back out on teleport.   Would also like to get it to cast higher level healers when it has them right now it keeps its existing healers until one dies and it will re-cast the higher healer.  Think I may do a release of what I have...

Reply #78 Top

Looked through unit sensors and mostly understand how it works, but I'm not really sure what SensorStatus compares against when deciding new goals?  I tried to follow the chain that this value takes, and sort of lost it around recalculating goal insistence or some such.

Also, the value that the OnTakeDamage callback is adding to / subtracting from is probably being totally overridden by the HealthSensor levels, which just hard-set it and don't check the existing value.  In fact, unless a demigod's health isn't being altered at all by attacks, I don't see a situation in which that damage callback would make any difference at all?

 

What I'm getting at is that there has to be a better way to use that damage callback, say, to actually estimate incoming damage rates vs remaining health, but I don't know enough about the sensor/goal system right now to make that happen.  I think the health sensor is doing this same job somewhat ok, but it can't make projections w/r/t when it should retreat, it just reacts.

Reply #79 Top

 

Didn't get too familiar with those, but don't recall changing them functionality wise so they are similar to the default ones.  The goal repick does not trigger every time the AI updates its status, so its possible the sensors and on damage function run between goal selections to get it into actions that keep it alive until it can decide to flee completely.

 

The flee Master goal also has a top level override blocking many flee actions unless the demigod is below 70% health.

 

While i have you. If i don't know the fields in a table can I run a loop to output the field and values?

Reply #80 Top

Quick test on v25n.

Standard test settings as per previous posts.

UB (human) / Sedna / QoT v UB (AI) / Sedna / QoT

The findings:

I wanted to run the test with two generals and one assassin on each team to see how it works. QoTs on both teams quite altruistically gave one monk to UB and one monk to Sedna, thus running with no monks at all, while Sednas were sporting an impressive retinue of 3 monks. After the monks died and were resummoned, the AI was happy just to leave monks attached to their original summoners.

Reply #81 Top

FYI - I'm updating some of this post to clarify some things...

AI skirmish (mod version) .25m/uberfix 1.03RC4

Settings:  Cataract/High Towers - all other settings on default
AI settings:  normal

rook (human)/ub/da/ v rook/ub/da

Observed results:

not of fan of the way my ai did its initial shopping... my ub got a pot and a tp (but no items).  by da did the same thing.  After a trip back to base, ub bought some items, but da did not

da then, with no items (outside of potion and tp scroll) bought xp1.

What I think would be best, though it could be arguable - change what the AI buys at the game's start.  Generally, this means an assassin will have banded armor and scalemail or scaled helm.  BUT - at the very least, I'd want every assassin to have 1 item that is not a consumable.  Then, once someone has 600 gold, have them buy fs1. I'd just make a blanket statement and say SAVE for cur1 if that's an option (eg no more purchases after intial buy + fs1 until ws3).  Then buy xp1.  Then buy whatever additional armor they need.  I DO NOT want the ai shopping after the initial shop and fs1 buy if it is sent back to the crystal UNTIL warscore 3.  After ws 3, let it buy whatever it has prioritized. 

once we hit ws 3, i started watching the ai's behavior.  ub, who had 900 gold, at first didn't buy anything at the shop and then started to head out... but then turned around and bought a tp scroll at the shop and another pot (eg didn't save for cur1).

now, at ws4, we still don't have cur1.  The da still has 0 items on my team 1 tp scroll.  At 9:55 sec, da buys his first piece of armor (banded).

12 min in - still no cur1.

I also noticed that it SEEMS like the dgs are more interested in flags than in getting kills.  In one instance, the ub on my team and I were chasing a dg over a flag.  The ub on my team stopped cold on the flag instead of pursuing a little more.  Probably need to bump the KILL DG priority a little if possible.

bought cur1 myself at 15min.

noticed in other instances the ai actually did pursue a little past a flag it did not control (i had extremely low health in this scenario - in the other scenario i described, we could have gotten a kill, but only if me and the ai stayed on the other ai.

at ws8, i saw the ai locking the health flag, which was actually good imo. 

noticed that the enemy ai, though only ws6 had priests.  I assume this was done to counter our priests (we are ws8).

enemy at ws7 popped out angels (we don't even have them yet)

we hit ws 10 and the ai buys cur2 instead of angels/cats/giants.

ai did not port in to save its portal again.

ai wasted 2 locks on 1 flag (both cast at the same time).

ai did not attempt to retake its portal for > 3 minutes.

Reply #82 Top

Quoting Peppe, reply 79
Didn't get too familiar with those, but don't recall changing them functionality wise so they are similar to the default ones.  The goal repick does not trigger every time the AI updates its status, so its possible the sensors and on damage function run between goal selections to get it into actions that keep it alive until it can decide to flee completely.

Yeah, the damage callback is relatively unchanged from the original - if anything, it'll activate more often, but I still don't think it will be doing anything unless the main health sensor update happens a lot less than I'm assuming it does.

Quoting Peppe, reply 79
While i have you. If i don't know the fields in a table can I run a loop to output the field and values?

Well, yes, that's the only way to access table keys that aren't specifically named/numbered, but what's the context?

Reply #83 Top

Also, I get the feeling that you guys are testing this with different AI difficulties.  The Nightmare AI has never been as dumb as what Pacov's describing, because it always has some gold to work with.  I agree that the AI shouldn't prioritize consumables, but expecting multiple normal AIs to all save their gold for Currency I is going to somewhat gimp their item setup for 5-8 minutes depending on the map, even with perfect out-of-the-gate item purchases.  On Leviathan, if they die, they might not even have enough gold even if they spend nothing after initial purchases.

If you're dead-set on having AI purchase absolutely nothing before Currency I (this is a bad idea for Hard/Nightmare, as they'll have plenty of gold even if they buy some much-needed items), then decide on a specific AI player at the start of the game who will be doing the gold-saving, and implement this into the item priority check.

The question is, how to determine which AI saves?  I've got an idea, but it would require hooking AIBrain and finding a point post-creation but pre-game start where the team brain can iterate all allied brains and find an AI player to designate for saving (preferring demigods like Reg and QoT to assassins).  If there's a way to iterate all allied AIs in the strategic goal system, that would be better, but I don't know enough about how that's structured.

Reply #84 Top

 

The shopping walking away and shopping again is caused by letting the AI decide what to do in the shop area.   Its either that or force them to shop and risk them sometimes not making it out of the shopping area.

 

 

I have not seen a consumable heavy purchase in a long time.  The priorities are such that every Nightmare AI should buy Nimoth first.  A healer idol or unbreakable boots and then some lesser armor items.  Bah just saw you were testing on normal.  I may need to redo priorities for a 1000 cash start.  I may have had tp above banded armor/helm.  Which would probably have it waste its cash on tp scolls and then pick up a potion cause it had nothing else it could afford.

 

Sound like a different game in your version.  Don't know if nightmare to normal would do all that.

 

There is some built in logic based on the targets health to continue an attack even if it is high risk.  That is probably the pursuit into enemy towers you saw.

If the DG takes damage it should drop its capture action and figure out what to do based on what is in front of it.  I will see if upping kill heroes helps and something to kill the weight of the capture action if enemies are nearby.  It may also just be too chicken to stick in a fight.  If you think it is that i can lower the bar for when it does a full retreat.

 

.23 or .24 added citadel response upgrades based on if the enemy gets certain troop upgrades, so its not giants vs soldiers.  They looked decent to me so havn't touched them.

Reply #85 Top

Quoting miriyaka, reply 82

Quoting Peppe, reply 79Didn't get too familiar with those, but don't recall changing them functionality wise so they are similar to the default ones.  The goal repick does not trigger every time the AI updates its status, so its possible the sensors and on damage function run between goal selections to get it into actions that keep it alive until it can decide to flee completely.
Yeah, the damage callback is relatively unchanged from the original - if anything, it'll activate more often, but I still don't think it will be doing anything unless the main health sensor update happens a lot less than I'm assuming it does.


Quoting Peppe, reply 79While i have you. If i don't know the fields in a table can I run a loop to output the field and values?
Well, yes, that's the only way to access table keys that aren't specifically named/numbered, but what's the context?

 

I cam up with this and just sent the string to the log file.

                for kk, vv in v do
                    myString = myString .. 'column: ' .. kk .. ' value: ' .. tostring(vv) .. ' || '
                end

It worked pretty well and I found a unit ID i was looking in a column i would have never guessed.   Context, there is a 'function WarpMinions(unit)' in ability.lua that runs when the demigod teleports.  I needed to know what columns were available on the minion units to identify them and maybe send the healers back off to a teammate.

Reply #86 Top

Re: Citadel upgrades, Currency II is probably cheaper than Catapults.  Unless you set all priorities to zero (which it's basically doing except for FSI, creeps and CurI/II and ExpI/II), the AI will buy what it can afford.

Oh, I see the problem.  Someone threw out my changes to currency that took into account time, gold settings, etc.  With those settings, Cur II and Exp II were basically always 0 unless the AI was Hard/Nightmare, gold was high, or it was really early in the game (e.g. High War Score or something, where Cur II is available really early on and thus more worthwhile).

Edit: Replace the current block(s) of utility functions in AIGlobals with this: http://pastebin.com/yqFBKrNA

And then replace CitadelUpgradeWeights.CGoldIncome1-3 with this: http://pastebin.com/R8S6Dt1x

Uncomment the log message if you want to see what it's returning, when.

 

Note that there are also a bunch of other utility functions there.  I've had good results with allowing the AI to buy Graveyard I and II under extenuating enough circumstances, and I can post the priorityfunctions for those if you're interested.

Reply #87 Top

I thought i fixed it before, but there was a spot where they AI could spend the 1800 it had saved on items once it got out of warrank 2.  Extended the reserve to continue until currency is purchased.

 

I'll take a look at the old currency and exp priority functoins.  Exp was at 0 because the AI couldn't purchase it (bug fixed now).

Reply #88 Top

Also, I get the feeling that you guys are testing this with different AI difficulties. 

We were testing with Normal AI, not Nightmare. However, the difficulty settings are consistent throughout both Pacov's and my tests (I based my settings on the tests we did together and his testing log).

Reply #89 Top

We were testing with Normal AI, not Nightmare. However, the difficulty settings are consistent throughout both Pacov's and my tests (I based my settings on the tests we did together and his testing log).

Exactly - we are using a consistent method for testing.  For me, its same settings.  If AI behaves itself on cata, I move onto levi.  We WONT change AI settings until we get to something stable.  Then we will test on nightmare, etc.  From what I've seen, if it does ok on normal, it will do exceedingly well on nightmare (outside of not buying items to its maximum potential until after ws3.

Reply #90 Top

I did like 3 games today with it (Solo, nightmare ai). They have improved, but it always seems like my ai are always doing dumber stuff then my enemy. The opposing ai will rush one lane together pushing me out, destroying a tower and taking a flag before my teammates seem to notice when im fighting a ai about to die who is sitting between me, and the tower andteammate Ai, The Ai will sometimes just stand there and attack creeps.

Reply #91 Top

Peppe - updated the post above with links to currency limiting code, in case you miss it: http://forums.demigodthegame.com/400825/get;2832079

Also, here's Experience and Graveyard: http://pastebin.com/4PX3SKyt

Unlike Cur/Exp, Graveyard has an increasing priority with a minimum threshold.  It might take some tweaking, as right now any team with more than ~15 combined deaths at level 10-ish will buy I.  Maybe that's ok, but probably not the best way for a normal AI to spend gold, so it either needs a difficulty mult or a gold reserve mult.

Reply #92 Top

The Nightmare AI has never been as dumb as what Pacov's describing

Nightmare has more gold than normal and can compensate.  My premise is that normal SHOULD BE ADEQUATE, and then nightmare should be challenging (and I'm quite willing to nerf nightmare until ws3 - then let them run wild - if the logic is good, the nightmare team should have more gold than the other and be able to buy better equipment and upgrades).  I've suggested logic that the normal AI focuses on critical upgrades in a timely manner, then buys cool stuff for itself.  As the nightmare AI has quite a bit more money at its disposal, its less of a problem and works with the existing rules better... but that's only because it has so much money.  Normal AI require the rules to be optimized to function appropriately.  At any rate, try a test with normal AI and let me know if I'm exaggerating.  That said, again, I want normal AI to cover the basic functions. 

If I really had to make a list of what I really want a terrible AI to do, it would be EXACTLY this and nothing else:

  1. buy fs1
  2. buy currency at ws3
  3. spend all money at ws 8 on purchasing creeps

Everything - and I mean EVERYTHING else is gravy.  As it stands, item 1 is covered.  Item 2 is not.  Item 3 means that the ai will get priests then and little else. 

If I was optimizing for this base build, then I'd make sure objective 1 and 2 were always met.  Objective 3 requires additional logic (what is ok to buy if the ai is saving for those creep upgades). 

Reply #93 Top

Quoting OMG_blackmage, reply 90
I did like 3 games today with it (Solo, nightmare ai). They have improved, but it always seems like my ai are always doing dumber stuff then my enemy. The opposing ai will rush one lane together pushing me out, destroying a tower and taking a flag before my teammates seem to notice when im fighting a ai about to die who is sitting between me, and the tower andteammate Ai, The Ai will sometimes just stand there and attack creeps.

Thanks for providing feedback synn - please continue to do so as new versions are released.  Its best if you use the format IN1 and I are using to report results, though. 

Reply #94 Top

 

I'll start testing on normal first.  Probably got the priorities out of wack with that.  Just moving TP below banded helm and armor gets them buying the right stuff at the start.

Reply #95 Top

I'll start testing on normal first.  Probably got the priorities out of wack with that.  Just moving TP below banded helm and armor gets them buying the right stuff at the start.

Please do - normal is the holy grail here, imo.  Everything else should fall into line (or be extra tweaks added later) if that works well. 

Reply #96 Top

 

Adding these conditions to the AI's item budget. 

Code: asp.net
  1.         if aiBrain.Score.WarRank >= 2 and ValidateUpgrade.CanPickUpgrade(Upgrades.Tree, unit, aiBrain.Score.WarRank, 'CGoldIncome01') != 'HasUpgrade' then
  2.             gold = math.max(gold -1800, 0)
  3.         end
  4.         
  5.         if     (AIGlobals.GetEnemyTeamBrain(unit).Score.WarRank >= 8 or aiBrain.Score.WarRank >= 7) and ValidateUpgrade.CanPickUpgrade(Upgrades.Tree, unit, aiBrain.Score.WarRank, 'CTroopNumber04') != 'HasUpgrade' then
  6.             gold = math.max(gold -4800, 0)
  7.         end
  8.         
  9.         if     aiBrain.Score.WarRank >= 9 and ValidateUpgrade.CanPickUpgrade(Upgrades.Tree, unit, aiBrain.Score.WarRank, 'CTroopNumber06') != 'HasUpgrade' then
  10.             gold = math.max(gold -6000, 0)
  11.         end

Basically should be -1800 (cost of currency) once the AI reaches war score 2 and persists until the AI has currency.

It will start saving again when the enemy reaches 8 or it reaches 7.  It will save 4800 (cost of cats) until cats are purchased.

Final saving routine sets aside 6000 for giants at war rank 9 or above.

 

Now they AI at anytime can use all money on citadel upgrades, so if it ends up wasting money on lower upgrades a similar budget override may need to be applied to the citadel purchase side.   This should only affect the troop upgrades as the AI should only buy experience and FS1 before currency.

 

I'll test this a little bit and probably release it all as .26.

Reply #97 Top

That looks like it should work, although the shotgun approach might periodically gimp a team of several AIs, especially against a human player who is spending all his money on equipment.

 

Re-worked the Graveyard priorities so even I should never be purchased by Normal AIs unless death penalty is on high, or the team is spending most of their time dead.  Nightmares will purchase I in any normal game, and II-III if they're getting spanked.  This should keep them in the fight a bit more.

http://pastebin.com/86vW3zKA

 

I see the_hunger did use most of my troop/building upgrade functions.  Those were the ones that I was least sure about, actually.  I guess I haven't noticed the AI buying them very often, even on Nightmare, but still, that might warrant a second look.

Reply #98 Top

That looks like it should work, although the shotgun approach might periodically gimp a team of several AIs, especially against a human player who is spending all his money on equipment.

I would like to hear your criticism of the logic fleshed out a bit.

My take is gimping is cool if its done after the initial buy and prior to ws3.  Is that what you mean?  In a good game in MP, no one is dying before ws3, and currency is bought EXTREMELY close to ws3 coming up.  Curious if that is what you mean or if you are talking about somethign else.

Reply #99 Top

All AIs on a team will be saving, meaning they'll all still have starter equipment when only one player on a human team would have been saving.  WS3 usually takes what, 5 minutes?  The AI is gonna die plenty in 5 minutes.  I can count on one hand the number of times that I've played an AI game where none of them died before WS3, hell WS2.  They take bigger risks, they react more slowly and less specifically, etc etc.  And that isn't even taking into account the 10800 gold they'll need to hang on to for giants + catapults.

I'm just talking about limiting the gold saving to one AI per team, preferably a Regulus or some other demigod who isn't as gimped by waiting longer to buy better equipment.  This might have the opposite effect on Cats+Giants though, if one player is expected to save for both.  Something like assigning these three to different demigods might have the best effect.

 

This is less from the perspective of a 1-AI-on-a-human-team and more from the perspective of an all-AI team.  If there's only one AI on the team, then the current method will work as well as it can, given the limitations of Normal AI gold income.

Reply #100 Top

If it becomes an issue we can probably modify the gold saving section i have now to check in on each ally brain's gold.  The ally brain with the highest gold can have its item budget reduced to purchase upgrades.   May be less reliable as the AI can still purchase other upgrades while its item budget is reduced.