Peppe

[MOD Project] DG Skirmish AI .22 -- 2/08/2010

[MOD Project] DG Skirmish AI .22 -- 2/08/2010

This mod will seek to make a challenging AI to play against in single player and multiplayer.

Currently mods can only be applied to 'skirmish' games offline, so offline tournaments are out at the moment.  Multiplayer can only use mods in custom games.

I hope to have many contributors and please post ideas here.   I am no expert on this game and can use every input available.  I also welcome other developers if anyone is interested.

 

Current Features:

  • Each demigod has custom build(s) reflecting a focused skill and item plan
    • Each build supports custom favor item and item priorities to taylor item selection to each build.  
    • Where it made sense the AI skill plans hold skill points for use at a later level. 
  • The AI purchases Citadel Upgrades like a human:
    • Priests, Angels, and Cats purchased in warrank 8 (if it has the money)
    • Giants and armor upgrades purchased at a high priority in warrank 10

Under Development:

  • Refine conditions for when to use an item with an 'on use' property.
  • Improve AI macro through goal priority level manipulation.

 

Downloads:  

Installer - http://peppe-dg-mods.googlecode.com/files/Peppe_DG_skirmish_AI_setup.exe

Zip - http://peppe-dg-mods.googlecode.com/files/Skirmish_AI.zip

Newer versions available in this thread: http://forums.demigodthegame.com/400825

To add an installer to your mod follow instructions here: [MODDING-UTIL] Mod Setup Script


.22 Changes: 2/08/2010

Tweaks to new or changed items in 21.  Should avoid flags protected by towers (more often).

 

.21 Changes: 2/07/2010

Custom actions created to teleport to towers and portals under attack by enemy Demigods.

When looking for flags to capture all Demigods consider all flags.   Actions for flags nearest HQ, near to demigod, and portal flags.

Capture lock changed to only lock portals and valor flags under enemy threat.

 

.20 Changes: 2/03/2010

Rook arrow tower firing rate dropped and damage increased in attempt to improve the AI Rook retreating stutter-step issue.

 

.19 Changes: 1/25/2010

Mainly Stun/Interrupt Changes.

UB + Rook will save thier skill for interrupt or a low health target.

Sedna + Oak, will fire thier interrupt skills as long as they have mana and should stop using it once they reach low mana, but will fire if an interrupt opportunity presents itself.

Erebus,  Will use charm mostly for interrupt, but if he can stun multiple demigods will fire it off.

Demon Assassin,  Didn't test this, but should only shadow swap to interrupt may add additional conditions later.

Teleport and Large potions set back to require a safe distance from enemies to use.

 

.18 Changes: 12/15/2009

Sedna Heals earlier, @75%

QoT Casts shield earlier, @75%

Some flag cap changes.

 

.17 Changes: 12/14/2009

Sedna build changed.

Minor changes to survival goals.

Flag capture range extended.

 

.16 Changes: 12/13/2009 Mark II

Minor changes to Teleport distance check and consumable item priorities.

UB build changed to Ooze + Spit maxed by lvl 10.

Sedna Item priorities changed.

 

 

87,592 views 262 replies
Reply #101 Top

pacov your testing has been very helpful.   Same for myles. 

On a player dropping.  We will need to confirm if it plays on using 'random' weighted skill selection (vs picking a build).  With that I may need to write a section to handle item chioce when skills are randomly weighted.  Right now the global value of all wearable items is 0 and each build adds priority to the items it uses.  Artifacts do have a gloabal value, so the take over AI would eventually replace items with artifacts.

 

Bman you have been added to the code project.

 

I've commented a little in every file i changed and the section that changed with a #  [MOD]  Description. 

I have not done that for the AIglobals (mostly just value changed) and each demigod's AI template (build skill order, point saving, achievement item by build, and items by build).  But will add that to them to make it easier for others to play with adding builds.

+1 Loading…
Reply #102 Top

.11 out. 

Comments added to demigod AI templates.

UB template was not being applied (fails over to original game template).  Fixed by assigning my template correctly (UnitAITemplate changed to UnitAITemplates).

Reply #103 Top

on player dropping - what would be great would be to have the computer compare the player's build to the available builds and find the "closest fit" and essentially come up with a skill plan "on the fly" to line it up as best it can.

Reply #104 Top

Quoting bman654, reply 103
on player dropping - what would be great would be to have the computer compare the player's build to the available builds and find the "closest fit" and essentially come up with a skill plan "on the fly" to line it up as best it can.

Agreed.  Also impressive if that could be done.  That would be pretty slick if it could adapt to some degree. 

Skirmish mod version:  .11
Map:  cataract
Players:  3 humans v 4 AI (All ub)
AI settings:  nightmare difficulty, high hp, normal gold
Game settings: normal

I wasn't so much bug testing as much as I was play testing.  The game I played was all with top level players (shade + trouser).  The beginning of the game was actually challenging.  The AI had fairly decent builds going for it re: abilities and equipment.  It used large health potions pretty much all the time (which is actually a good tactic considering).  I don't think we even pulled off a single kill until 3 min or so in.  Things were slow going for killing the AI (good) probably through about 5 minutes.  At that point, we started to easily pull ahead as we were able to get better items for ourselves, etc.  By about 6-7 minutes, it was a joke.  We were slaughtering the AI left and right.  They seemed to run out of steam and stopped buying large health potions (prob didn't have the money, but maybe just stopped buying them).  We starting killing them in waves.  We stalled a bit so they would get to level 8.  Sure enough, they bought all the creep waves up through cats.

Here is where some balancing is needed.  I think the AI needs to be able to make a decision on whether or not to save to cats or keep upgrading.  In the case of our game, the AI should have been upgrading itself instead of creeps to scale better with us.  I'm not entirely sure what the trigger should be for whether or not to buy creep waves.  Logically, if you only control 1 portal consistently, you shouldn't put money into creepwaves, etc. 

 

Reply #105 Top

 

What do you think the AI needs to survive better or should that be a priority?  Increasing the survival goal makes it chicken :P   I had noticed it uses health potions well, so In my local build i will bump up big health potions and try to get it to carry those.

 

Early game it has a gold advantage to buy most of the best stuff, so it makes sense it was able to push you around for a short while.  For UB i believe after spending 4k it will have high 3k or mid 4k health.   For the assassins they usually only need a couple thousand more and they will have bought all the non artifact items thier build has planned to buy.

 

I have been playing with the AI goals and I don't know if its just random or the goals, but sometimes I can get 3 of 4 to stick together.  One always seems to go rougue.  Would having more of the team in the same area help?  Goal tested: AttackWithHelp

There is also a CaptureFlag goal would map control help or be worthwhile?

I'm also testing sigils.  The default action is to pop them at 60%.  Going to try 20% and see if it can use them to avoid death better.

 

 

Reply #106 Top

What do you think the AI needs to survive better or should that be a priority? Increasing the survival goal makes it chicken I had noticed it uses health potions well, so In my local build i will bump up big health potions and try to get it to carry those.

I agree re:health potions.  Fairly intelligent usage.  Teleports are hit and miss.  Honestly, if AI exp/gold had been set to low, we might have actually lost the game simply because of the AI having better kits.  That's ok.  But it would be a serious improvement if the AI remained challenging on normal gold/exp, imo anyway. 

Reply #107 Top

The default action is to pop them at 60%. Going to try 20% and see if it can use them to avoid death better.

Sigil use is tricky.  I, for one, try to wait a LONG time before popping a sigil to use it as a last second move to get a kill.  I typically don't use sigils to escape, but sometimes you have to.  I'm wondering if the AI will run after popping a sigil or if it will attack. 

Anyway, human strategy aside, it might be best to have the AI's pop sigils EARLY so that human plays might pull back instead of pursue.  This way, the AI wouldn't run for sure.  Maybe try 40% as the threshold. That sounds reasonable to me, anyway. 

Oh - Ai's attacking together is smart, but then we start getting into real strategy.  For instance, I probably wouldn't want my entire team on one side pushing.  I'd rather have all but 1, then have 1 guy sneaking around getting flags back.  BUT - if an entire team was in one location, then I either need my entire team there or I need my entire team to break off and go for flags and get the hell away from the other team.  PLUS - there needs to be a way, if there is not, to get ai's to all chose the same target.  For instance, if its 4 humans v 4 ai, all ai should be focused on the easiest target to kill in a 4v4 battle.  Programming the logic for that would be another good thing, if its possible. 

And again - thanks for taking the time to work on this.  I think ALOT of people will enjoy this mod when its completed and I'm glad to see it progress.  I'm sure the pace will slow down a bit on your side due to other obligations, but please know your efforts are appreciated.  Thanks!

Reply #108 Top

.12 up with some rough changes.  Normally i would test more on my end before pushing this out, but it might be the last build for a few days.

 

There is some built in targeting functions in AIutilities (that file added to mod).   The default attacks select the weakest non fleeing hero in range (was weapon range by default).  I've increased that range by adding a fixed amount, so heroes in the area should pick the same target.   I don't know how sticky that target selection is though.  AttackActions.lua has been added as well to play with the attack logic if needed.

In AttackActions, I have also increased the range checks for most of the attacks.  On cataract, I think the AI goes and waits by its tower near the edge flags for creeps, but doesn't see them fighting at the flag with the default range.    Hoping to get them to engage more often as they seem to creep poorly.

Capture actions added as well.  I flipped its search order to check nuetral flags then enemy flags.  And decreased its fear of enemy creeps at a flag.

Sigils @ 40%

Goals tweaked.  Target is more flag capping and creeping to get map control and level advantage.  Slow growing priority on killing structures (should push towers more often than the base AI).

 

Reply #109 Top

 

Don't have a lot of time this week, but was just poking around the code.

 

The code to handle a player leaving is here:

\lua\AIBrain.lua  line 141

    AbandonedByPlayer = function(self)
        local stronghold = self:GetStronghold()
        self:Alert(stronghold, 'PlayerLeft')
        print(LOCF('<LOC ai_takeover>AI has taken over for %s', self.Nickname))

        self.UseSkillWeights = true

        self.BrainController = 'AI'
        if self.GoalPlanner then
            self.GoalPlanner:SetActive(true)
        end
        if self:GetTeamArmy() and self:GetTeamArmy().GOAP then
            self:GetTeamArmy().GOAP:AddBrain(self)
        end
        local hero = self:GetHero()
        if hero and not hero:IsDead() then
            self.GoalPlanner:StartHeroPlan(hero)
        end

        self.ClassCallbacks.OnAbandoned:Call(self)
    end,

 

It does what i expected.  When a player leaves the skill weights planner takes over.

Skill weights can be taken out and a build selected here or thrown to a custom function to decide on a build.  The build the player had going would have to match a pre-defined build at that point or the remaining skill plan will fail.   I believe on fail the weighted skill planner will still pick a skill.

From a modding perspective I don't know if it would be more time efficient to dynamically have it create a costom build to follow based on the builds we defined or modify the skillweights to have it continue down a path already started.   The weighted plans for each demigod may not be bad once a player has gotten them started.

 

 

 

Reply #110 Top

I've been playing around with this mod, and I have to say that I see the big improvement of the AI. However, I've noticed certain things that could be improved.

In particular, I see that the AI plays more defensively, which is a good thing. But sometimes it just stays in its place doing nothing, probably waiting to rack experience from nearby creeps when they die, instead of actually killing the creeps.

When fighting an enemy 1v1, my team mate sedna (nightmare AI), stay behind and heals me sometimes instead of fighting.

One more thing that is very annoyin, the AI goes back to the citadel at full health and mana sometimes, just to buy an extra scroll, pot, or item. It happens quite frequently, and makes the AI behind on levels especially early game.

I also noticed that the AI, spend too much gold on items, and doessn't focus on citadel upgrades. sedna buys mage slayer, gloves for AA !!

Overall, a lot of good things here. I especially like the pre-defined builds for AI, with corresponding items :) (although some has to be changed/improved). I also like how the AI is more careful with towers early/mid game, although sometimes on cataract, an AI would run past all the 8 towers in front of my citadel at level 5 xD.

The AI spends too much gold on consumables. I think early game, the AI should buy the regular starting items, and save money until war score 3. Then buy tower health + currency. Then it should start again buyin items for itself (the standard 1500/1750 gold items), and save money for warscore 8, with regular purchases of scrolls, locks and pots (not too much though).

Reply #111 Top

The AI spends too much gold on consumables. I think early game, the AI should buy the regular starting items, and save money until war score 3. Then buy tower health + currency. Then it should start again buyin items for itself (the standard 1500/1750 gold items), and save money for warscore 8, with regular purchases of scrolls, locks and pots (not too much though).

I agree and disagree.  I think the starting amount of consumables chosen.  The AI purchases tower regen 1 at level 1, which I think is a good call, personally.  And gold at level 3.  Could you list what types of games you are playing and on what map when you playtest?  For instance, most of my tests are 1 human v ai or 3 humans v 4 ai. 

Reply #112 Top

"

Here is where some balancing is needed.  I think the AI needs to be able to make a decision on whether or not to save to cats or keep upgrading.  In the case of our game, the AI should have been upgrading itself instead of creeps to scale better with us.  I'm not entirely sure what the trigger should be for whether or not to buy creep waves.  Logically, if you only control 1 portal consistently, you shouldn't put money into creepwaves, etc. "

If I were to write my own generic 'goals' for when I buy creeps it would be this:

0 == do not buy , 300 == buy if I have the cash on hand , 600 == save my gold, go back to base when I have it, 1000 == sell my stuff to buy immediately

--

Priests:

I am at WS 6: +100

My opponents have Priests and it is at least WS 5: +150

I am at WS 8: +750

I have been holding lanes and pushing lanes very well. (easiest way to quantify this is a WS check. if Friendly.WS - Enemy.WS > 820 (full level), that means I'm a whole level above them, which means I'm dominating): +100

My opponent is are:

 - Assassin Erebus :  +25

 - Minion Erebus    :  -50

 - Sedna               : +50

 - Angelic Fury Reg : +25

 - Tower Rook that has been holding lanes very well the whole game : -75

 - Torch                 : -75

 - Ooze Beast         : -25

Me or my teammates are:

 - Minion Erebus    : +10

 - Sedna (Healing Wind) : +10

 - Tower Rook       : +10

 - Fire TB              : +10

 

Angels:

I am at WS8 : +600

My opponents have Catapults: +400

 

Catapults:

I am at WS8: +600

My opponents have Catapults: +400

 

Giants:

I am at WS8: +600

My opponents have Giants: +400

 

Global:

I do not currently control both my portals: -100

    () If one of my portals is currently locked and there is an Erebus/Oak on their team: -150

I have control over one of their portals: +50 (you get more XP if you have larger waves)

    () If I have control of one of their portals, and it is locked, and there is an Erebus/Oak on my team: +100

Each time I cap an enemy portal my 'priority' would increase by 10. Each time an enemy captures my portal, my priority would decrease by 5.

I have more towers than my opponents: +50 / tower

I have less towers than my opponents: -50 / tower

I have a significant Warscore disadvantage: +100 per level

Basically, if I get portals really early in the game, I might get Angels at Warscore 7 just so that I get more gold and XP from the enemy portal. Similiarily, if I can't control my own portals, there is very little point in sinking 10,000 gold into buying better units.

If I have less towers, it is more important that I hold lanes rather than buy units ASAP because it will be harder and harder to protect my portals as I lose more and more towers. In order to hold lanes, I need to buy items. If I'm pushing well, even while under-itemized, then I can risk putting a lot of money into the citadel and trust myself not to feed.

At higher level of play, if war-scores are asymetrical, then both the winning-team and the losing-team will tend to rush for units. 5 minutes of having catapults with a lower WS can mean pushing your opponents to defending their towers and re-gaining control of the map until they bring out their own. 5 minutes of having catapults with a higher WS could be an unstoppable push that your opponents can't recover from. Conversely, if both teams have very close WS then they are probably roughly equal in kills and gold. Therefore, flags are much more hotly contested and holding a lane is more vital than pushing because it is much, much harder to push in these games. So, equipping yourself with items becomes more important.

--

That's a much more thorough, while still qualititative way of expressing when I personally purchase units. I know that when to buy priests is a hotly contested topic and there are many, many variables that have to be considered (your and your opponents teams, level advantages, tower advantages, the map, how many people are playing, how many lanes there are, etc etc) and the 'safest' choice is always to wait until WS8. Still...

 

Also, I'd be more than willing to write up several different AI-builds (I know you currently have one-per-demigod or something). I'm most comfortable with Sedna but I've played dozens and dozens of games against top-ranked players so I know what good builds look like ;) A cheat-sheet for the ability-enumerations would be most helpful but I'd be willing to submit several to help give a more diverse single-player expierence.

Reply #113 Top

Here is where some balancing is needed. I think the AI needs to be able to make a decision on whether or not to save to cats or keep upgrading. In the case of our game, the AI should have been upgrading itself instead of creeps to scale better with us.

had the same experience.  Like your idea for logic as well.  Check out his lua code.  Its well commented now, so pretty easy to follow if you want to create some builds. 

Reply #114 Top

The biggest issue that I have noticed with the modded AI is that AI demigods do not cap flags enough and thus often fall behind in warscore.  I think that the mod makes them a bit more aggressive in doing this, but they really do need to be more conscious of the need to hold flags and build warscore.  I play against the nightmare AI, so I am not as concerned about how the AI spends gold.  It has plenty of resources from the beginning and can afford to buy good gear, consumables, and upgrade the citadel all at the same time.  By level 7-8, they are already hanging out at the artifact shop!  However, I have seen the AI go a bit too long without trying to get flags or allowing me to hold one of its portals a bit too long.

Still, great job, Peppe.  The single-player game is vastly improved due to your efforts!

Reply #115 Top

 

@abuggeredhedgie

Some of that logic could be added to the priorityfunctions in AIglobals.lua.  Its jsut a matter of finding the variables syntax to reference the enemy warscore/warrank and doing a simple if statement like:

if enemy warscore > ally warscore then

return X priority

else

something else etc... 

 

Not sure where citadel upgrade status is stored for the enemy.

 

Don't believe there are priority levels that will make it sell everything, but it may sell its lowest item if it will be able to afford the current top priority.

 

Builds are very easy to add.   When testing a build i would comment out any other active builds so that yours is the only one active.  

I have commented out the original builds, so they are not active, but they are a good reference to get the skill names, or you can dig through the skill weights section further down the the demigodname_aitemplate files as every skill should be declared in there. 

Items are all in AIglobals, so copy the items your build will use and set a priority for it to buy it.  Most of the good artifacts have a default priority of 100 that becomes active when the AI has gold  8k or 10k.  If it will be better for the builds maybe i should change it globally to 0 like the other items.   Right now you can add (or subtract) a little priority for each artifact at the build level to get it to lean toward the artifacts it needs. 

 

@the_hunger

I wonder if setting the flag cap goal to grow at a crazy high number per second and setting the capture actions to reduce it a large amount will give it both a top priority goal and a top action to reduce a goal by the largest amount?

Or i wonder if you(as an enemy) hang out at their portal if it is getting filtered out of its list of flags to capture.  Maybe change the end of the capture action function to require > 1 or > 2 enemy heroes at the flag to be too chicken to capture it back?  Or drop the chicken statement entirely and let it go after any flag and retreat based on its survival/health goal.

Playing with this may also lead to trying to capture flags it shouldn't (in front of enemy citadel on cataract).  Might increase the tower check radius to make sure it does not find any or maybe add a larger radius check for the citadel itself?  Leave that as the last flag to capture.

If that helps maybe I should rewrite the function to act more like the kill targeting function.  It starts out highly filtered and slowly reduces the filter until it gets at least one target.  For the kill functions it is something like first pass it looks for demigods, second squads, third structures, and last anything it can hit (all checked in a range around the demigod).   If we can set a start point as our home citadel and tell it to find the closest uncapped flag and let the filter work its way outward to find flags to capture.

 

Reply #116 Top

Quoting Peppe, reply 115
 I wonder if setting the flag cap goal to grow at a crazy high number per second and setting the capture actions to reduce it a large amount will give it both a top priority goal and a top action to reduce a goal by the largest amount?

Or i wonder if you(as an enemy) hang out at their portal if it is getting filtered out of its list of flags to capture.  Maybe change the end of the capture action function to require > 1 or > 2 enemy heroes at the flag to be too chicken to capture it back?  Or drop the chicken statement entirely and let it go after any flag and retreat based on its survival/health goal.

Playing with this may also lead to trying to capture flags it shouldn't (in front of enemy citadel on cataract).  Might increase the tower check radius to make sure it does not find any or maybe add a larger radius check for the citadel itself?  Leave that as the last flag to capture.

If that helps maybe I should rewrite the function to act more like the kill targeting function.  It starts out highly filtered and slowly reduces the filter until it gets at least one target.  For the kill functions it is something like first pass it looks for demigods, second squads, third structures, and last anything it can hit (all checked in a range around the demigod).   If we can set a start point as our home citadel and tell it to find the closest uncapped flag and let the filter work its way outward to find flags to capture.

I think that it is an issue that can probably be easily addressed.  The AI (at least on hard/nightmare) is not bad at capturing flag, it just needs to be a bit more persistent.  Your first suggestion--raising the flag-capture priority--is probably the way to start testing for a solution. I think that it needs to be a constant priority and not an escalating one.  That is, if you are losing the warscore fight early on, you will probably be losing it later as well.  Thus, the AI needs to be building warscore (i.e., capturing flags) consistently throughout the battle.

I would actually like to try out different values for the flag-capture goal.  Could you tell me what file/code to find that information in?

Reply #117 Top

The capture goal is in \Skirmish_AI\hook\lua\sim\AI\Heroes\Goals\AdvanceGoals.lua.

 

HeroAIGoalTemplates.CaptureFlag = {
    Name = 'CaptureFlag',
    BaseInsistence = 0,
    IncreasePerSecond = .5,
}

 

For testing you can set the base high, but there is a bug in the item shopping on somemaps where the AI won't shop if it is out of range of the shop at the start (fixed by setting shopping base higher than all other goals).   I believe the base gets modified when it completes an action in that category (Skirmish_AI\hook\lua\sim\AI\Heroes\Actions\captureactions.lua).

Reply #118 Top

Tried this one today. Good work and all but it won't be really usefull untill the AI stop acting like and idiot :) I'm guessing that is rather hard though but gj so far.

Reply #119 Top

While I was playing around in this game I noticed all AI controlled demigods half way through the game stop doing anything.

http://www.gamereplays.org/demigod/replays.php?game=51&tab=upcoming&show=details&id=102922

Reply #120 Top

While I was playing around in this game I noticed all AI controlled demigods half way through the game stop doing anything.

http://www.gamereplays.org/demigod/replays.php?game=51&tab=upcoming&show=details&id=102922

 

Tried to watch with various version of my mod, but got gamestate error.   Did your gamelog show any errors? 

 

Usaully if there is an error like that it happens at the start and I find the source.   I havn't seen any like that mid game.

 

 

Also, .13 up. 

Just some minor tweaks to existing files and additional goal files that can help with the overall AI behaviour.

Reply #121 Top

No it happened mid game, UB on my team was owning everything and than stopped doing anything and stayed at base, Than OC and than everyone on the enemy team. I had about 5 other mods running also, but they couldnt have caused it since this isn't the first time I played the mods together.

Reply #122 Top

Hope to get some more testing in tomorrow.  Thanks for a fresh release, Peppe. 

Reply #123 Top

I must say i'm impressed.

Played a couple of games yesterday with my partner vs 4 nightmare ais on prison and for the first time we lost. (same setup in version 11 and was a complete victory for us).

Just to make sure we tried vs vanilla ai and crushed them utterlesly so i must commend you for your work: finally an AI that is half decent to prepare you to online games ^^

From what i've seen the ais cover each other, tend to stick together and definetly level up and gear up fine.
They still do lot of stupid things but in the end in a 2vs4 we really enjoyed the game!

 

Reply #124 Top

Definitely enjoying this mod.  The AI UB build on hard/nightmare is actually tough at this point.  The AI's are teleporting more often, and often at meaningful times - in my last game, a UB telied in for a nice 3 on 2 gank against one of my AI teammates.  The item builds seem to be helping a lot.  I do get the sense that the AI's are returning to base a bit more, but that's probably OK.  I have yet to see my teammates buy priests/angels or cats.  However, in my last game, one of my teammates did buy giants.


My biggest issue with the AI's is that they still march straight into enemy tower defenses and periodically commit suicide.  The better item builds are helping them survive this now, but this behavior needs to be changed somehow.  Don't know if that's possible.

Reply #125 Top

I liked how in my last AI game, the UB on my team stayed a bit behind me. We wouldn't move until i did and was waiting for the tenticle r.....gank that was awaiting sedna trying to cap our flag.