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 #26 Top

Minor tweak request:  is there any way you could keep the AI from declaring the build it is going for about 4 to 5  seconds?  With the way things load, this usually translates into having to hit enter to see what the AI chose as its only visible for 1 to 2 seconds.  I guess the perfect implementation of this would be to wait 4 to 5 sec, then post 1 build.  Wait 1 or 2 sec then post build 2 and so on.  Again, not even remotely a big deal, but figured I'd throw that out there.

Reply #27 Top

It's really easy - just add a forkthread and a wait to line 372 of FriendlyAsset:

Code: c++
  1. ForkThread(function() WaitSeconds(5); AIUtils.AIChat(unit, announcement) end)

Reply #28 Top

 

Updated.  There is other stuff in the release.  Pretty sure everything else i had updated on my local copy was complete.

 

The game time actually starts a few seconds before the player's camera spin start, so i did a little higher wait and added some randomness.

Actual code:

Code: xml
  1. local waitTime = math.random(8,16)
  2. ForkThread(function() WaitSeconds(waitTime); AIUtils.AIChat(unit, announcement) end)

 

 

The major other changes are in the AI master goal overrides.  I expanded from ~4 to 8 or so that should get the AI always doing something.

 

Code: c++
  1.             if GetGameTimeSeconds() < 18 then
  2.                 currentMaster = 'MakeItemPurchases'
  3.             elseif GetGameTimeSeconds() < 30 then
  4.                 currentMaster = 'CapturePoint'
  5.             elseif shopDistance < 30 and canBuyItems then
  6.                 currentMaster = 'MakeItemPurchases'                
  7.             elseif artShopDistance < 30 and canBuyArtifacts  and self.Agent:GetHealthPercent() > .5  then
  8.                 currentMaster = 'MakeItemPurchases'    
  9.             elseif self.Agent:GetHealthPercent() > .99 and strongholdThreat and strongholdThreat > 0 then
  10.                 currentMaster = 'Attack'                
  11.             elseif self.Brain.Score.WarRank == 3 and self.Agent.Gold >= 1800 and ValidateUpgrade.CanPickUpgrade(Upgrades.Tree, self, self.Brain.Score.WarRank, 'CGoldIncome01') then
  12.                 currentMaster = 'MakeItemPurchases'
  13.             elseif eflags and aflags and table.getn(eflags) + 1 >= table.getn(aflags) and self.Agent:GetHealthPercent() > .99 then
  14.                 currentMaster = 'CapturePoint'
  15.             elseif self.Agent:GetHealthPercent() > .99 then
  16.                 currentMaster = 'Attack'
  17.             else        
  18.                 useLocalFunction = true            
  19.             end
  20.  

 

Basically in this order:

if it has stuff to buy and it is near a shop it will buy. 

If there are enemies around its citadel it will attack stuff.

If the flags aren't heavily in it's teams favor it will capture flags.

If none of the above and its healthy it will attack

Otherwise use the default function to decide what mastergoal to do.

Reply #29 Top

Made a quick test with the latest released version (d) - well.. almost latest version - you are a bit speedy :)

Anyway, version d - the replays worked as expected.  Can also confirm that uberfix is removing the expected status effects when brainstorm is cast on other players.

Another neat thing to know (MAYBE) is when a player on your team has purchased an artifact (if the ai does that at this point).  Perhaps just a quick message.  Again, just a thought, not super important.

I think the most challenging map I've played on is levi with those mods enabled, as a sidenote. 

And last, I generally like the way the ai handles itself now.  A critique for cataract - its still not placing enough importance on holding its own portals.  Its not bad, mind you, but late in a MP only game, portal control pretty much decides the outcome - and as a result, players will fight to the death to get a lock off and certainly swarm to a portal if its threatened.  In addition, if a late game portal is captured on one side, the team that lost that portal might very well take a shot the other teams portal to balance things out.  A thing to keep in mind is that this primarily a cataract strategy.  Portals are valuable on other maps, but as there are only 2 portals per team and those are close to the base, if you lose 1 and giants are out, it's probably gg.

 

Reply #30 Top

If there are enemies around its citadel it will attack stuff.

I think this might be where is care less about holding its portals. 

Reply #31 Top

 

Attack and citadel defense conditions were added with version e.  Version before that if the AI had map control it would do whatever it thought is best (generally select not good things, follow squads or stand around).

 

The capture flags check is higher in the list than the final if healthy attack check.   Capture flags is the primary action until the AI has +3 flag advantage over the enemy.  Instead of letting the AI choose its next best action I set it to attack.  I can make capture the default action until the enemy is out of flags :P.   The health checks are in there so as soon as it takes damage it will re-evaluate and probably attack the thing that damaged it or flee appropriately.   Without that check the AI would stand directly on the flag pole until dead or captured.

 

Cataract has 13 flags.  Each team starts with 5.  The formula above results in the AI seeking to capture flags until it has 8 of them.

If the enemy has 6 flags the formula adds 1, making their count 7 which equals the count we have, so it keeps capturing.   I thought it needed some condition to stop going for flags once it had good map control.  If it should just keep pressing every available flag that can be arranged

 

Is it ever the wrong thing to do to head to a enemy flag to capture?  

 

 

Reply #32 Top

If there is a way I would prioritize friendly portal flags as 3, and enemy portal flags and the HP flag as 2. 

Therefore, if it lost a friendly portal flag, it would really prioritizing flags (hopefully one of which would be the portal). However, if presented between capping XP flag and HP flag it would always go HP flag. 

This would make the "flag count" to be 13 + 2*2 + 3*1 == 20. 

Another trick would be to "teach" the AI how to capture the two gold flags without being attacked by the tower, and how to capture both the gold flag and portals as the same time. 

Reply #33 Top

 

Changes in E

More conditional overrides for master goals to keep the AI on task.

Some builds updated or added.

Oak shield use changed.  Old function was to use it whenever any enemy unit was near.  New function oak must be below 50% health and an enemy hero has to be near.

 

Version F posted. 

AI's announce artifact purchases.

Capture points is the mastergoal as long as the enemy has flags and the demigod is healthy and not near a shop that it needs to purchase items from.

 

 

Reply #34 Top

Is there currently logic in the AI to distinguish between different flags at all?  By type, or also by location / default ownership?  I'm pretty sure the flag markers in MasterChain that each team starts with have ownership variables, so if it doesn't do this already, it should be simple enough to retrieve.

Also, does Validate.CanPickUpgrade check whether or not the upgrade is already purchased?  I don't have the lua in front of me right now.  I assume it does, but I figured I'd ask.

Reply #35 Top

 

Closes up for a couple hours. 

 

If i recall Validate.CanPickUpgrade checks everything, so if its already purchased it will return false to let the AI move onto a later goal.  I checked before i used it, but don't recall the details now.

 

The AI has all sorts of weights for different flags.  I believe these would be compared to kill, move, or other action weights to help the AI land on Capturing that flag as its master goal and then execute the actions to reduce that goal from being the highest.  We are overiding the AI's master goal to be capture points.   So how it selects flags should be entirely in the capture actions lua file.  There are 3 actions for it to select from. I think 9 month ago i added one or two of them to get it to capture more.

The actions generally just find all flags, sort by distance from the unit or stronghold, and then go get the closest one.

We probably just need a capture nearest action for use through most of the game and then toward the end ramp up the weight of the capture portal action.   I think it will tend to select the action with the highest weight to fulfill its master goal.

Reply #36 Top

Yes, a general-use capture-nearest would be good, and a much higher-priority recapture-own-portal, with a caveat for going for an enemy portal instead if one is significantly closer and not too heavily-defended (a simple radius 25 count of hostile towers centered on the flag).

I'll take a look at those actions when I get the chance.

Reply #37 Top

so - version 3f - played a 4v4 on levi (me+3ai v 4ai).

This time, the AI refused to buy any items... it did by fs1 at one point, but no other upgrades and never bought any items for itself... hmm...

edit - strike that - ai still bought priest/angel/cats at 8, just no items for themselves

Reply #38 Top

however, if i play on cataract, it plays just fine... hmm

Reply #39 Top

Is it ever the wrong thing to do to head to a enemy flag to capture?

Yes - the general goal is to hold all flags if possible, but to be willing to trade off as needed.  For instance, on cataract, I'd generally rather have 2 demigods stay on hold the HP flag early game while another dg trades off between the mana and xp flag.  What I think you have going in this version is that if team A controls 2 of the mid flags, then ALL will run to the missing flag... this leaves the other 2 flags undefended and is a bit of overkill... plus, it leads so some silly nonsense.

In my game on levi, the 3 ai's on my team would run run all together from flag to flag. 

edit - decided to go back to version .25e and observed the same no shopping behavior on levi. 

edit edit - last version that was good on most maps was .25d - just a did a play through using that on levi.

I'm going to start documenting my tests in greater detail going forward and try to standardize some parameters.

In the past, I had been using nightmare AI's.  There seems to be a decent drop off in purchasing when using normal ai (that's what I've been working with all night).  Obviously, the normal ai will have less gold so it can't buy as many upgrades, but this led to me having a ub on my team when we were at wr 7 with only dark crimson vial and banded armor as he spent all of his available money on upgrades. 

 

Reply #40 Top

No one sticks around the HP flag becuase they are probably all unhurt, so all get the capture points as thier master goal.  They all then run the same capture action function that selects the nearest flag as the capture target.  I might be able to add some randomness to this so even if they are all in the same spot they can make different choices.

 

The shopping issues is probably a distance thing.  

I'll have to test the overrides on the other maps.  The shop distance check is only 30, so shopping will generally only occur when the AI passes by a shop (most maps this is on their retreat to the health stone).  There are so many distance types in the game, but i think that '30' in this function covers from the shop to the citadel on cataract.  The AI shops consistently on cataract because it retreats to the health stone next to the shop. 

 

Probably need to get distance out of the check and just shop when it has stuff to buy.   But don't want it to shop every time it can afford a health potion... 

Maybe I'll modify the shopping override to be cash based?  If it has over 3000 and has items in its shooping list, then go shop?   I'll tinker with this a bit.   Maybe sum up the cost of all the items it thinks it can purchase and make some cash amount worth the trip?

 

I think for the flag capture actions I am going to count up each flag type or at least count portals on each team.  If the portal counts arn't in the demigod's favor it will select the nearest portal as the capture target.    Not sure if it should be nearest to the demigod or nearest to the demigod's stronghold.   Maybe i'll have it check which stronghold the demigod is closest to and select the closest portal based on which side of the map its on.

If portals are even or its not war rank 7+ it can any near flags.   Not sure what to do on the AI bunching up on the same flags.  Maybe a new capture action can be done that instead of capturing a point just defends it...   I've got a move action in to teleport to portal flags (the action sends the 'portal threatened' message when its triggered), maybe I should expand that to protect HP flags?  Any other valuable flags?  If it is expanded to any center flags it will be threatened often. 

Reply #41 Top

 

On upgrades.  Every upgrade currently is at a higher priority than every item the demigod's purchases.   Most equipment is in at a 20-50 priority.   Most upgrades are 100+.

We can try setting upgrades at ~25.  Then the AI should get its health stacking items before upgrades. 

Reply #42 Top

Quoting Peppe, reply 41
 

On upgrades.  Every upgrade currently is at a higher priority than every item the demigod's purchases.   Most equipment is in at a 20-50 priority.   Most upgrades are 100+.

We can try setting upgrades at ~25.  Then the AI should get its health stacking items before upgrades. 

well... that I'm not too sure about.  I think I'd probably like the ai to purchase the upgrades.  The general premise in the vanilla ai is that they are useless.  The more they take care of for me, the better my chances of winning.  Your mod makes a substantial difference in the ai's skill level - but unless they can come pretty close to emulating another decent human player, then they are a liability.  HOWEVER - that is offset quite a bit by having them purchase upgrades so the human players can focus on kills, etc. 

It might be worth a shot at changing things up a little, though.  I'm game for testing at any rate and we can see how things go.

Reply #43 Top

Definitely do not make the AI want to shop whenever it has money, even over a certain threshold.  As it is, in .23, nightmare AIs would shop shop shop all game.  the_hunger's modifications improved this a bit, but it still happens a lot.  Every time they complete an action or get a kill, they try to head back to base to shop.  It was totally excessive, and meant that they'd spend maybe ~30% of the game actually doing anything useful.

As mentioned above, I also found this results in them buying way too many citadel upgrades compared to items, although that's definitely fixable with proper citadel upgrade priorityfunctions (which I tried to do, but probably didn't get the gold thresholds right).  The piece of information I was missing when I tried to fix this is what you just said - 20-50 priority for items.  That means there's little reason for anything other than fs1, currency, and priests<->giants to be >20 priority, and priests should probably only be 25-30 now that they auto-match creep upgrades with the enemy team (with super-high priority, if I recall) even once giants are available.

On that topic, what happens right now when an AI successfully captures a flag?  Previously, even in early .24, they'd basically always head back to shop, whether or not they have a scroll.  If they don't have a scroll, this wastes a crapload of time.  When they always had scrolls in .23, this wasted a ton of money, and still a lot of time.

 

My initial thought on the latter issue is that we need to make some kind of flag guard/hold action, if one doesn't already exist.  Have it be the defacto action whenever the AI's team is holding a majority of flags, has its own flags intact, and nothing higher priority is presenting itself (defend tower / defend citadel / defend pre-owned flags, etc) and have the action focus primarily on the non pre-owned flags (on almost all maps, this will be the 3-4 in the center).  Make this action interruptible by anything higher priority, and have it keep tabs on the AI's gold to the extent that it does eventually go back and shop once it can buy several items / upgrades.

Reply #44 Top

Also, upon re-reading the past few posts, I agree with pacov about having the AI, especially nightmare, take care of the core upgrades like fs1 and currency.  Even having one nightmare AI on your team means that you should never have to worry about these, and definitely shouldn't have to worry about buying the entire creep tree yourself.  Normal AIs are never going to be able to afford the entire creep tree AND a bunch of items, so expecting them to compete anywhere near on the level of a human while buying upgrades is silly.  If you want an AI that takes care of upgrades and is also challenging to fight, don't play with/against Normal.

The question is then, should we adjust certain citadel upgrade priorities for lower-skill AIs?  This is trivial to implement, and I already have the code to get AI difficulty sitting around somewhere (if I cant find it, it should also be in the .23 skirmish AI thread), so it's just a question of deciding which upgrades to not have lower-level AI focus on unless it's trying to auto-match (i.e. the enemy has giants and the AI's team is screwed unless it gets them too, items be damned).

Edit: What difficulty level are the AIs brought in when a player is dropped?  If not already the case, it should be possible to auto-adjust this to the enemy team's combined kills/war score compared to the dropped player's team, i.e. pull in a Nightmare AI if the enemy team is winning, or a Normal/High if things are closer or the dropped player's team is winning.

Reply #45 Top

 

G: http://www.filefront.com/17559261/Skirmish_AI_v25g.zip

One flag capping action.  Has some randomness to it.  And should go after portals first anytime their balance gets out of wack.

I flipped shopping back to a distance check.  It will start a shopping quest whenever it gets near the health stone and has items to buy.

 

AI should spend 90% of the game capping flags, or fighting over them.   The only time it will shop should be when it is hurt and goes back to the health statue.

I did not re-balance upgrades.

Reply #46 Top

Good stuff.  Thanks for getting another release out.  Not sure if I'll have a chance to test this out tonight, but I'll take a look at it tomorrow.  Thanks!

Reply #47 Top

Excellent.  I'll try to give this a shot when I can; looking forward to seeing an AI actually go to another flag after capturing one for the first time in, well, ever.  o_O

Reply #48 Top

Had to rush that G release out this morning before leaving for the thanksgiving festivities.  I did not get to test the portal re-capturing section or let you know what changed.  I normally run a few full games for release, but did not for g, so hopefully no major issues.

To detail the changes in G:

First I found very odd behavior trying to mod the capture action that comes with the game.  Almost like the modded version wasn't overwritting the existing function.   So i neutered it to never be chosen as an action, and re-made the capture anything action.  It was called by the demigods as expected. 

For the action I tried to simplify it down, so it has a fixed weight and the instant status check to confirm it can run this action only requires an enemy or neutral flag be available.   Once we are performing the action, it selects a flag:

Code: asp.net
  1.        
  2.          if table.getn(aPortals) &lt; table.getn(ePortals) then
  3.             captureFlags = Utils.TableCat(nPortals, ePortals)
  4.             captureFlags = SortEntitiesByDistanceXZ(unitPosition, captureFlags)
  5.             if VDist3XZSq(unitPosition, captureFlags[1]) &gt; VDist3XZSq(unitPosition, aiBrain:GetStronghold():GetPosition()) then
  6.                 captureFlags = SortEntitiesByDistanceXZ(aiBrain:GetStronghold():GetPosition(), captureFlags)
  7.             end
  8.             nearFlag = captureFlags[1]
  9.         elseif table.getn(eflags) &gt; 0 or table.getn(nflags) &gt; 0 then
  10.             captureFlags = Utils.TableCat(nflags, eflags)
  11.             captureFlags = SortEntitiesByDistanceXZ(unitPosition, captureFlags)
  12.             if table.getn(captureFlags) &gt; 1 then
  13.                 nearFlag = captureFlags[math.random(1,2)]
  14.             else
  15.                 nearFlag = captureFlags[1]            
  16.             end
  17.         end

First we check if we own fewer portals than the enemy.  If so, we check if we are closer to an enemy portal flag than our stronghold.   My thought here was if the AI is on the other side of the map near an enemy portal flag and the enemy captures one of our flags on the other side of the map we might as well go for the flag near the unit.   If we are closer to the stronghold, then we will find the portal flag closest to the stronghold and go re-capture it.   This runs before selecting any other flag, so if the portal flags ever get out of balance it should be the first thing addressed by a healthy AI.

If the portal balance is in our favor or equal and there are enemy or neutral flags on the map it sorts for the flags closest to the unit.  If there is more than one it randomly selects from the two closest flags.   We can tinker with this, but in testing it split the AI's in a nice way, so they would go to different flags.

 

Some test items:

Are there any maps where the physical portal is far away from the flag?  It was easier to get a list of physical portals than to loop over the flags and find the portal flags, so that part will actually send them to the portal rather than the flag near it, but finding the flag nearest a given portal shouldn't be too much effort if it is an issue on certain maps.

For this version i have the action set to 40 seconds.  If the AI does not make it to the original flag selected in that time the function will run again and it may select a different flag based on the units current position.   We may need a distance check on the closest flag and make sure we don't re-pick to the second closest flag when we are close to another flag.  

Need to run some games to test artifact shopping.  I think it will run to the health stone, shop locally, then if the team owns the artifact shop it will continue and shop for artifacts.   Shopping could also come up as the master goal through the default goal picker anytime the demigod is less than full health (override action at full health), so artifacts may get purchases this way naturally.  The weight for this is controlled by a sensor that checks item priority (very high for artifacts, 100+) and distance to shop.

 

miriyaka,

On flag defense.  I wrote the custom action 'Teleport to Portal' in useitemsactions.   It could be expanded to other flag types or maybe a new one that is walk based, so we save teleport flag defense for portals and maybe have a walking defense of other flags (probably should do a list of flags worth defending vs ones you can just let get captured and re-capture when you get near it).

On difficulty i believe that is stored directly with the brain as well. 

I've only checked on levithan, but it successfully found a spot near the portal to capture the flag.
Reply #49 Top

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

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

rook (human), ub, sedna v rook (human), ub, sedna

Observed results:

early game - ai would push past the flags on left and right side foolishly - looked like trying to capture a flag, but had no mind for the damage they were taking.

AI did not buy cur1 when was possible at one point - sedna could have for my team at one point - 2300 gold, but choose not to at ws4

AI's on the other team would stay at the crystal for way too long.  I think 40 seconds or so once.

Again, AI seemed to prioritize flags outside of the middle three and would overextend regularly. 

In the middle closest to either base (eg past the middle flag in the other teams towers) - the sedna would fight it out.  They'd push into the towers and start taking damage, then back off... the behavior was foolish.  I'm thinking the sendas were trying to push the valor flag, then took too much damage and pissed off.

I think cur1 and fs1 should be super prioritized over anything else.  I'd even be ok if the ai didn't even shop for itself until cur1 was purchased (outside of the intial shop at start).  I wouldn't want that logic for anything else, though.  Just for those 2

 

Reply #50 Top

Found some issues on the maps with a large distance between the portals and the portal flag, so have a fix ready for that. 


I will add a damage check to the instant status of the capture action.  The old function also used to scan for enemies and abort when it found enemies.  I can add that back in and see if the behavior is better.

 

I test 'h' and try to get another version out before the end of the night.