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,586 views 262 replies
Reply #26 Top

 

I glossed over a section on achievement item selection. 

 

Might be back to square one on skill selection.  I had thought LUA used 0 based indexes so setting it to 3 would select the 4th build, but i guess its a 1 index as 1-3 were the built in oak builds and 0 and 4 both crashed the AI (just stands there cuase there was an error).

 

I'll try a couple more things, but might have to shelve skills until shadowing is working.

Reply #27 Top

Ai have a set amount of favour points they can use. It was something like achievement favour min = 300 and acheivement favourmax=450. It's only on nightmare they start getting decent favour items.

 

Reply #28 Top

 

I didn't set a priority on artifacts, so they are 50-200 based on thier cost.   I didn't really think there was a bad one, but i can certainly zero out some or reduce thier priority to closer to the normal items and see if the AI doesn't try and save its money for one. 

 

Although that could just be a random goal it selected and stuck to...  if it is consistant we can look into that.

Reply #29 Top

 

Heh found the achievment selection logicif you can call it that.

function named: FindBestAchievementItem

First it reduces the list to what the demigod is allowed to select (min-max range based on difficulty and general/assassin).  Then it applies advanced algorithms to select an achievment item.

        local numItems = table.getn(achievementItems)    Count the items we can select
        if(numItems > 0) then   if we have at least one item proceed
            result = achievementItems[Random(1, numItems)]  Select a RANDOM item...
            table.insert(bestItem, {ItemName = result.ItemTable.ItemId, ItemCost = result.ItemTable.ItemCost, BaseShopType = result.ItemTable.BaseShopType})   Send out best item back to the DG
        end

 

What is a short list of achievements the AI should use.  I think i'll make a random call like 1-5 and the result will lock it to a range of one item.

So if random came up 1 it would have min of 450 and max of 450.   The AI would get swift anklet.

Repeat for each item we want them to use.  There is some overlap at the 1750 mark, so if those are useful might have to add some additional logic.

 

 

When should the AI look to buy artifacts in general or specific ones?   I can tell it to wait for a certain warscore/warrank or tell it to wait till it has a pile of cash? llike 15k otherwise they have a priority of zero and it should focus on other things.

Reply #30 Top

What is a short list of achievements the AI should use. I think i'll make a random call like 1-5 and the result will lock it to a range of one item.

its not truly on the short list, but I'd like to see an alt version where the AI always selects amulet of teleportation for some testing (if you get a chance).

The basic items are blood of the fallen or swift anklet for AI, imo...

Reply #31 Top

Just wanted to reiterate - I did a playthrough on this.  me vs 2 ai.  1 ai bought upgrades for themself and citadel.  The other did nothing.  Something is wrong.

Reply #32 Top

Just upload .04 give it a try and see if they focus on items first. 

 

Looking at some of the code there may be a 'ai leader' that takes on the task of citadel upgrades.  Might be something to watch.

 

.04 Changes:

Building health regen becomes a priority at 300 warscore (part way through warrank 1).  This lets the AI get items to start and on the first trip back one will get this upgrade.

At Cats reinforcement damage becomes priority.

At warrank 10 giants, armor, and damage upgrades become priority (should get them all)

Artifacts will be ignored until the DG has 10k, this should get them focused on being fully equipped before holding cash to get an artifact.

Achievements items locked to teleport amulet for testing.  

 

Last one can be changed by searching for 1125 in Skirmish_AI\hook\lua\sim\AI\AIshopUtilities.lu, just enter the favor cost of the item you want them locked to.

Reply #33 Top

downloading and giving it another test now.  Thanks for all the quick builds!

Reply #34 Top

Test case:

Skirmish mod version:  .04
map:  cataract
players:  Human(pacov) v 2 AI (sedna + reg)
AI settings:  nightmare difficulty, high hp, normal gold

This appeared to work more appropriately, but still had some huge game breaking issues.  Both Ai's were purchasing armor this time around.  1 bought 1 upgrade (tower regen).  Neither ai prioritized XP1 a war rank 2.  Sedna even ported back to the base with enough money but did not purchase it. 

Hmm... noticed something.  Reg bought the 400 gold health potion.  Then sold it immediately for the robust rejuvenation elixer.  Lost a little cash in doing so. 

The Ai seems to prioritize purchasing items/potions over citadel upgrades.

Ok... saw reg going crazy again.  He went to shop... kept buying 400 gold health potion.  Then would sell it and buy the robust rejuventation potion... the would sell that and buy 400 gold heatlh potion... then would sell and... he kept doing this until he ran out of money.

10 minutes into the game and the AI has only purchased tower regen 1. 

There's still a pretty big problem with version .04

 

Reply #35 Top

 

Any reason for them to even buy potions?  I left those at the defaults, i'll tweak with the sell back priority and see if that helps that cycling.  

 

Don't think XP upgrade can be purchased by the AI at the moment.

 

Citadel upgrades should go:

Building health 1  during rank 1-2

Gold I during rank 3-4

Priests, Angels, Cats, blacksmith I upgrade in rank 8 (or later).

Giants, Armor, and Attack upgrades in rank 10.

 

All other upgrades are at 0, so will never be purchased.  XP just doesn't work.  Let me know if that is wrong, but I thought you indicated the other upgrades were not useful.

Reply #36 Top

Any reason for them to even buy potions? I left those at the defaults, i'll tweak with the sell back priority and see if that helps that cycling.

buying a pot isn't a horrible thing... but buying a pot, but sell the pot, to buy the same pot, to sell the pot is a bad thing.  That glitch kept the AI from buying anything for the citadel outside of tower regen. 

To cover your post:

AI did buy tower regen at level 1.  Did not buy gold I at rank 3-4.  Never hit level 8.  But the ai would not have had the money due to buy/selling of options for currency. 

Reply #37 Top

 

Thanks for being an active tester .05 up.  With some minor tweaks and block selling consumables.

 

 

Reply #38 Top

testing .05 soon

Reply #39 Top

testing .05 soon

Test case:

Skirmish mod version:  .05
map:  cataract
players:  Human(pacov) v 2 AI (oak + qot)
AI settings:  nightmare difficulty, high hp, normal gold
game settings: fast

ai bought tower regen1.  also bought armor as expected for itself.  Ai did by currency 1 this time (seems like that is fixed this time)

AI issues again.  1 ai kept buying/selling tp scrolls for cap locks... it did this over and over again until it ran out of money. 

 

more details in case it helps... seems like ai behaved appropriately at the beginning of the game.  bought armor and then some consumables.  Its on the next few trips back that the AI starts acting silly with consumables (buy/sell until broke).  I can't confirm yet, but it does seem like one DG is responsible for buying the upgrades (and it seems like the other ai is going haywire with the buy/sell). 

Reply #40 Top

I think there is just too much competition for the consumable slot.  I have reduced thier priorities way down and saw less item flipping.  Also cut our mana potions and rejuvs.  Rejuvs becuase the AI didn't seem to use them well (held them when down on only one category choosing to go back to base to heal).   They seem to play better with heal potions as they consume them quickly and stick around a little.

 

No time to get a build out, but might hold it for a bigger update...

 

Got holiday stuff going on, but did find something else nice.

 

So custom Skill selection are back in. 

 

The method I am going to use until shadow files are available is to use the hook method, but name my hero templates something custom.

 

At each level the AI calls this function:

    PickSkillUpgrade = function(self, unit)
        local unitId = unit:GetUnitId()..'peppe'

...

It goes on to check if it can find the unit, if it has been here before and selected a build already, etc.

 

GetUnitId() resolves to a string for each hero.  hoak for Oak.

As you can see above I added a string onto the end of the unit id, 'peppe', so now the game will look up my custom AI skills template instead of the built in ones. 

The game automatically hooks my HOak_AIBlueprint.lua in the correct place, and the unitid inside is 'hoakpeppe'.

The templates are only used in one file (friendlyasset.lua).

 

I also looked around friendlyasset and we can do two interesting things with these templates.   We can set skills orders, and we can set custom item weighting.  So instead of every AI sharing one set of item purchase priorities we can set them by demigod (not by build though).   There is no example of this in the existing demigods, but the plumbing all looks to be there.

 

 

Reply #41 Top

 

Anyone seen the AI use OAK's last stand?  Is it decent?  Wondering if it might be a worth the point or 2 over morale sometime after 15 since the AI does tend to die  against players.

 

I have 'abuggeredhedgie' build in and letting a game run with it.  Testing out a method to save skills.   If it works i'll maybe add a another build and then try to get 1-2 good builds in for each demigod based on any guide i can find in the strategy seciton...   that compilation thread is up to date?

 

Main point of this pass is to get the bad skills out of the AI trees.  I believe i have seen Sedna should never use yeti's and they are in 2 of the 3 AI builds.

 

It will probably take a lot of testing to find which skills the AI uses well vs not well.

+1 Loading…
Reply #42 Top

Keep in mind we should be able to teach the AI to use skills a bit better also.  It's an aspect I've wanted to take a look at when I get some time.

Reply #43 Top

Anyone seen the AI use OAK's last stand? Is it decent?

Do not get last stand IMO for AI.  It's debatable, but if you are paying even a little attention, you won't get killed by an AI using last stand ever.  It often doesn't even acquire you as a target after the mode is enabled.

Reply #44 Top

Quoting pacov, reply 43

Anyone seen the AI use OAK's last stand? Is it decent?


Do not get last stand IMO for AI.  It's debatable, but if you are paying even a little attention, you won't get killed by an AI using last stand ever.  It often doesn't even acquire you as a target after the mode is enabled.

Last stand is not even good for humans. Let alone AI.

LOL! i prefer anything else but Last Stand, because if the enemy is just even a little smart, he will avoid it.

Reply #45 Top

 

Hope to see others join in to make a challenging skirmish AI.  Skill use will probably be an advanced topic.   I don't have a master project plan, but right now i am taking out the low hanging fruit ;)  

What upgrades to get and when?  set pretty good and easy to customize from here.   Only issue is XP upgrade not being selectable by the AI.

What items to get and when?  Set to the common items we all use.  Item buy/sell cycling may be an issue (seems to be there in the default AI as well).  Tempted to block all consumable selling by the AI.    Only condition on when to buy somethng is to not consider artifacts until we have 10k, so the AI focuses on normal equipment instead of saving for an artifact.

Custom skill point distributions?  Plumbing all done, just need to input some good builds into the AI template format.

 

After builds i think the next easiest thing to tweak is the AI goals/priorities (flags, creeping, hero killing).   I think i saw these in lua\sim\AI\Heroes\Goals.   I believe the goals will require a similiar hack as the hero ai templates.  You can't hook those files without cuasing a 'duplicate template' warning.  For the hero templates when this happend only the originals were used.   I was thinking tweaking these goals to focus on creeping till 5 or 7, then transition into structure or hero killing?   This will be the hard to tell what is going on as I don't think we can enable debugging to get messages on what goals the AI had available and which one it selected.  There is some randomness built in to have the AI be less predictable.

 

My progress tonight was good.  Saving a skill point looks to be good and i have a couple builds from the forums transferred to the template format.  

 

The change to support saving a skill point was to modify the default action when the AI has a skillpoint.

 

The files that control this are heroGOAP (loops PickSkillUpgrade while we have skill points) and friendlyasset (contains function: PickSkillUpgrade)

My change was to add a 'SAVE' to the build and then handle alternate execution when the skill 'SAVE' is passed.

 

Example OAK minion build:

    Oak_Minion = {
            'HOAKPenitence01',      # 1
            'HOAKRaiseDeadWard01',  # 2
            'HOAKSoulPower01',      # 3
            'HOAKRaiseDeadWard02',  # 4
            'HOAKSurgeofFaith01',   # 5
            'HOAKPenitence02',      # 6
            'HOAKRaiseDeadWard03',     # 7
            'HOAKPenitence03',      # 8
            'SAVE',  # 9
            'HOAKSurgeofFaith02','HOAKRaiseDeadWard04',  # 10
            'HOAKPenitence04',   # 11
            'HOAKDivineJustice01',      # 12
            'GeneralStatsBuff01',         # 13
            'SAVE',  # 14
            'HOAKSurgeofFaith03','HOakSoulFrenzy',   # 15
            'GeneralStatsBuff02',      # 16
            'GeneralStatsBuff03',               # 17
            'GeneralStatsBuff04',           # 18
            'GeneralStatsBuff05',             # 19
            'GeneralStatsBuff06',       # 20
    },

20 skills, but with saves there are 22 skill levels in the list above.  Each comma above seperates a skill level that the PickSkillUpgrade function uses to figure out what it should do next.

 

In the main GOAP loop i made the following change, comment tagged [MOD]:

local upgrade = self.BrainAsset:PickSkillUpgrade(self.Agent)

...

            # [MOD] If the skill returned is 'SAVE' check if we have added a skill, otherwise abort
            if upgrade == 'SAVE' then
                if self.Agent.Sync.SkillPoints == 2 then
                    self.BrainAsset:savedSkillcomplete(self.Agent)
                else
                    break
                end
                 
                upgrade = self.BrainAsset:PickSkillUpgrade(self.Agent)
               
                if not upgrade then
                    break
                end
            end

 

As soon as we get a second skill point (@10) the skill level is incremented using savedSkillcomplete (custom function).   With that the PickSkillUpgrade function attempts to select the next skill, once that completes it increments the level, and since it has another skill point to spend it loops back to select another skill at the same hero level.

At 9 it is constantly entering this loop and aborting (skill = save).   There is a wait statement at the end of the loop by default, which should keep it from eating too many resources and i did not notice any issues having this loop do nothing every 'tick'.

 

Should i write something that can process saving skill points for more than one level or is one enough?  I can't recall personally saving more than one skill point at one time in any build i tried.

Thank to all that contribute to this thread.  I will try to get a build out tomorrow if i can input some builds for each demigod otherwise it might be a day or two.

Reply #46 Top

 

I was thinking on last stand if we changed the AI use of the skill to only go after sctructures it might be able to act like human's doing suicide runs on citadel.

Reply #47 Top

Quoting Peppe, reply 46
 

I was thinking on last stand if we changed the AI use of the skill to only go after sctructures it might be able to act like human's doing suicide runs on citadel.

That's usually the 1 semi-viable use of last stand (typically just for suicide runs on the citadel).  I'd still lean FAR away from last standing being a part of oaks build.   

Reply #48 Top

 

Have builds in for OAK (full minion), Erebus (minion no charm), Demon ASsassin, and QoT.

 

Implemented saving a second skill point to be able to use this QoT build, http://forums.demigodthegame.com/352272:

 

QoT

            shield_spike = {
            'HQueenBrambleShield01',# 1
            'HQueenGroundSpikes01',    # 2
            'SAVE',                  # 3
            'HQueenBrambleShield02','HQueenGroundSpikes02',    # 4
            'HQueenSpikeWave01',       # 5
            'SAVE',                  # 6
            'HQueenBrambleShield03','HQueenGroundSpikes03',    # 7
            'SAVE',                    # 8
            'SAVE2',                  # 9
            'HQueenBrambleShield04','HQueenGroundSpikes04','HQueenSpikeWave02',    # 10
            'HQueenUproot01',          # 11
            'HQueenUproot02',       # 12
            'HQueenUproot03',         # 13
            'SAVE',                   # 14
            'HQueenGoddessofThorns','HQueenSpikeWave03',  # 15
            'HQueenUproot04',          # 16
            'HQueenViolentSiege',      # 17
            'HQueenCompost01',        # 18
            'HQueenCompost02',        # 19
            'HQueenCompost03',      # 20

Oak

    Oak_Minion = {
            'HOAKPenitence01',      # 1
            'HOAKRaiseDeadWard01',  # 2
            'HOAKSoulPower01',      # 3
            'HOAKRaiseDeadWard02',  # 4
            'HOAKSurgeofFaith01',   # 5
            'HOAKPenitence02',      # 6
            'HOAKRaiseDeadWard03',     # 7
            'HOAKPenitence03',      # 8
            'SAVE',  # 9
            'HOAKSurgeofFaith02','HOAKRaiseDeadWard04',  # 10
            'HOAKPenitence04',       # 11
            'HOAKDivineJustice01',  # 12
            'GeneralStatsBuff01',    # 13
            'SAVE',  # 14
            'HOAKSurgeofFaith03','HOakSoulFrenzy',   # 15
            'GeneralStatsBuff02',     # 16
            'GeneralStatsBuff03',    # 17
            'GeneralStatsBuff04',    # 18
            'GeneralStatsBuff05',    # 19
            'GeneralStatsBuff06',    # 20
    },       

 

Demon Assassin

        SkillBuilds = {
       
           speed_spine = {
            'HDemonSpineAttack01',      # 1
            'HDemonWarpStrike01',       # 2
            'HDemonDemonsSpeed01',        # 3
            'HDemonSpineAttack02',      # 4
            'HDemonWarpArea01',         # 5
            'HDemonDemonsSpeed02',        # 6
            'HDemonSpineAttack03',      # 7
            'HDemonDemonsSpeed03',        # 8
            'SAVE',                     # 9
            'HDemonSpineAttack04','HDemonWarpArea02',       # 10
            'HDemonElusiveness01',        # 11
            'HDemonWarpStrike02',       # 12
            'HDemonWarpStrike03',        # 13
            'HDemonWarpStrike04',          # 14
            'HDemonDeadlyWarp',            # 15
            'HDemonElusiveness02',      # 16
            'HDemonElusiveness03',        # 17
            'HDemonAssassinsSpeed',     # 18
            'HDemonWarpArea01',         # 19
            'HDemonWarpArea02',         # 20
            },
        },

 

Erebus

           bite_swarm_army = {
            'HVampireBite01',           # 1
            'HVampireCoven01',             # 2
            'HVampireConversion01',        # 3
            'HVampireBite02',           # 4
            'HVampireBatSwarm01',       # 5
            'HVampireCoven02',          # 6
            'HVampireBite03',           # 7
            'HVampireCoven03',            # 8
            'SAVE',                      # 9
            'HVampireBite04','HVampireBatSwarm02',    # 10
            'HVampireConversion02',        # 11
            'HVampireConversion03',        # 12
            'HVampirePoisonedBlood01',  # 13
            'HVampirePoisonedBlood02',    # 14
            'HVampireArmyoftheNight',     # 15
            'HVampireVampiricAura01',    # 16
            'GeneralStatsBuff01',         # 17
            'GeneralStatsBuff02',       # 18
            'GeneralStatsBuff03',          # 19
            'GeneralStatsBuff04',       # 20

 

AI will be more fun to play against when it has multiple builds to choose from, so if there is another good build post it or link to it and i'll create the build template for it.   I'll try to dig up a solid build for the remaining 6 demigods, but input is welcome.

Reply #49 Top

The QoT build kind of sucks imo.

the other ones are good though.

Reply #50 Top

Just wanted to point out incase it got missed - you have 'HDemonWarpArea01' twice as skill #5 and #19 in DA's skill list.