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,590 views 262 replies
Reply #76 Top

Skirmish mod version:  .08
Map:  cataract
Players:  Human(pacov) v 4 AI (2 ub + tb + da)
AI settings:  nightmare difficulty, high hp, normal gold
Game settings: fast

Observations:

The ai bought all of the appropriate creep upgrades very soon after hitting level 8 and got tower regen 1 by warscore 2 (if not earlier). 

3 Ai's bought equipment.  1 Ai did not.  In my game, it was the AI that appeared in the 2nd slot when you press tab (i think that was slot 2 in the lobby but I'm not sure).  After I killed the AI once, it actually did go back and buy items. 

So, in my previous test (1 human vs 2 ai), there was always one AI that NEVER bought a single item.  In this test (1 human vs 4 ai), 1 AI refused to buy anything at the beginning, but did buy items after dying once.  If you can get it configured so that all of the AI's ALWAYS start by purchasing armor, etc, then this particular bug will be squashed. 

Reply #77 Top

Pacov, did your oak not buy anything ever or just at the start?

 in that test, oak NEVER purchased anything at all and he was back at base quite a bit due to getting killed.

Sedna does not have any artifact preferences, so she will take any I have activated (disabled a couple crappy ones) that she can afford. I can give a minor bonus to any one artifact to try and get her to pick one. She is a little short on her buy plan any suggestions for more items?

When in doubt, go with blood of the fallen if its an option. 

Reply #78 Top

Pacov.

I started up a 2v1 game and have you noticed if its always the AI that starts farthest away from the shop that doesn't buy?

I wonder if this is a map thing.  On Cataract the start locations 4 of the 5 are in range of the shop at the start.  With every team size, a player always starts in the spot not near the shop.  I'll see if i can find where this is intitialized and maybe send that AI to the shop or tell it to look for a shop in a wider radius. 

It sits there until the others have done thier shopping then rushes a middle flag, so i thought it had just picked a different goal than the others, but it is probably the start out of range of shop messing it up.

 

Note: this affects the unmodded game as well.  It is just now that we are looking at the AI we notice these things :P

Reply #79 Top

Skirmish mod version:  .08
Map:  cataract
Players:  Human(pacov) v 2 AI (Lobby Slot 1 on darkness - SEDNA, Lobby Slot 2 on darkness - UB)
AI settings:  nightmare difficulty, high hp, normal gold
Game settings: fast

Observations:

This test is to determine if a specific AI refuses to buy items based on lobby slot location.

The ai in lobby slot 1 did not buy any items at the start of the game.  The ai had 4400 gold.  The ai died at level 5 with 6800 gold.  The ai respawned and did not buy anything.  Ai died again... now has 8200 gold.  left again without buying anything.  Died again with 9200 gold.  Left base again without buying anything.  Here's something interesting.... the AI didn't die one time.  It actually was able to retreat to base with low hp.  NOW the AI bought some armor/items for itself. 

Edit - The sedna Ai was the furthest away from the shop on cataract at the start of the game. 

Reply #80 Top

Skirmish mod version:  .08
Map:  cataract
Players:  Human(pacov) v 2 AI (Lobby Slot 2 on darkness - SEDNA, Lobby Slot 3 on darkness - UB)
AI settings:  nightmare difficulty, high hp, normal gold
Game settings: fast

Observations:

This test is to determine if a specific AI refuses to buy items based on lobby slot location.  This test does not include lobby slot 1 on darkness. 

Both Ai's purchased items at the start.  Sedna was further away initially but still purchased items.  I'm leaning in the direction that this has always been an issue and we never noticed it before.  We can always work around this by never putting an AI into slot 1 on darkness when playing against AI, but this sounds like something that belongs on the bug list for demigod.  NOT this mod.  Here's a new test with your skirmish mod disabled to confirm the issue is the unmodified game:

Skirmish mod version:  DISABLED
Map:  cataract
Players:  Human(pacov) v 2 AI (Lobby Slot 1 on darkness - SEDNA, Lobby Slot 2 on darkness - UB)
AI settings:  nightmare difficulty, high hp, normal gold
Game settings: fast

My test on this is to let the game run for about 4 minutes and review the results.  AI located in lobby slot 1 on darkness DOES NOT buy any items or armor at the start of the game on cataract.  This is confirmed as a bug for demigod AI on cataract and is not caused by this mod. 

Reply #81 Top

 

Well i have a little hack that seems to be working.  There is a file called HeroAIGoal.lua in (lua\sim\AI).  It is very simple file that creates the goals for each instance of the AI brain (each hero gets its own brain).

The default purchase items goal has 0 priority (looks like almost all goals start at zero).  Some goals increment on thier own, and some actions reduce goals.  So the AI may have a goal of capping flags that grows every second of the game.  Soon it reaches the top of the goal list and the AI finds actions that will reduce that value and performs them.  When they complete the goals value is reduced and a new goal moves to the top of the list.

Anyway my hack was to go in the heroAIgoal and wait for the purchase item goal to be passed and add a base priority to it:

        if goalName == 'PurchaseItems' then
            self.BaseInsistence = self.BaseInsistence + 2
        end

I am going to play with the '2' value, but it definatley worked.

The easy way to fix this would be to shadow the ItemGoals.lua file in (lua\sim\AI\Heroes\Goals) and edit the value directly.  My understanding is shadowing is not enabled yet for modding.

 

BMAN or other modders.   Can you look at the AI actions and Goal templates and see if you see an easy way to customize these files with our current hook method?

If you hook one of the template files (sim\AI\Heroes\Goals or sim\AI\Heroes\Actions) all your changes are rejected and an error is logged (duplicate template detected).    This is an area that can have great impact on the macro game of the AI, and would be great to start modding.  I think i tried to go a few folders up and change the files it selects for import (init.lua if i recall), but that errored out on loading demigod.

Reply #83 Top

Well i have a little hack that seems to be working.

Cool.  I'll get another test in when you upload another version.  Thanks for you efforts on this and I'm glad to assist. 

Oh... and the link in your op doesn't work right (To add an installer to your mod follow instructions here: [MODDING-UTIL] Mod Setup Script)

Reply #84 Top

 

Link fixed.  .09 posted:

Default shop priority added to force AI to shop at start. 

Rook has a second build added.  Now has hammer+boulder and tower spam build.

 

I was in the middle of the rook build, but it was functional, so I left it in.  Since i have a goal override in for item purchasing I will probably see what some other goal overrides due to the AI macro game.

Reply #85 Top

Alright, got a good test with a lot of notes using teams that you see a lot. Also reproduced pacov's bug and believe I saw a couple buy/sell cycles.

Skirmish mod version:  .08
Map:  cataract
Players:  2 AI(Sedna + DA) + Human(Oak) v 3 AI (Sedna + UB + LE)
AI settings:  hard, normal settings
Game settings: normal

First off, Sedna on the dark side was in slot 1 and didn't buy anything for the about first 3 minutes, then bought Velmish and Plenor.

Second, I'm positive I saw both Sedna(Dark) and LE go through a buy/sell cycle with minion idols, and pretty sure UB sold a Banded Armor only to buy it right back, but I want to double check that.

Notes on Individual Demigods-

Sedna(light) - Started with minotaurs not monks. Stayed with those until about 8-9 min mark, then sold those off for Scaled Helm and Nimoth armor. Around 13 min got Bishops, and 17 min got the other two best idols. In all, had a pretty solid build.

Sedna(dark) - As I said above, didn't buy anything until about 3 mins when it got Velmish and Plenor. Didn't get any minions until about 15 mins when it got Bishops. A little bit later is sold an HP item to get the Hungarian Crown. I think it would probably be best to remove that item from Sedna's list. The other two helms are enough imo.

UB - Really solid build with BoF as favor. AI started with Unbreakable Boots, which I thought was interesting. Other than the suspected buy/sell cycle of Banded Armor, no other problems.

DA - Though his build was solid throughout with mostly HP items and a Velmish, he struggled through the match. I'd recommend only allowing BoF or BotS since he didn't use the Essence of Magic item very well.

LE - Started with demolishers instead of monks, then sold those off, but I missed when. Had a pretty solid build, but also didn't get Bishops until after it got the best minotaurs and siegers(at ~15 and 17 min) at ~20 min mark.

Reply #86 Top

Skirmish mod version:  .09
Map:  cataract
Players:  Human(pacov) v 2 AI (Lobby Slot 1 on darkness - SEDNA, Lobby Slot 2 on darkness - UB)
AI settings:  nightmare difficulty, high hp, normal gold
Game settings: fast

This test is to determine if Peppe's fix is working so that the AI always shops even in lobby slot 1 on darkside on cataract.  I waited 4 minutes and then viewed the replay.

Both Ai's chose to purchase at the start of the game.  Looks like you might have that bit resolved.  Well done, Peppe!

Reply #87 Top

Thanks myles.

I'll remove Hungarian.

 

What is a good priority on idols? 

I have minitour 4 at 15.  Rest 0 (never buy)

Archer 4 at 15.  Rest 0 (never buy)

Priest 1 10, priest 4. 20 rest 0 (never buy).

Idols are weighted against items as well.  For most builds scale helm and banded armor are in the 10-20 range. Also most consumables are ~10.   Maybe priest 1 bump to 15?  If it has the cash it will probably take monks over lvl 4 of the others.   Most generals will probably start with them + ~1500 item if they can afford both.

 

UB build is probably one of the best for the AI.  Its like 2 skills and has helath regen to keep ooze on as long as it wants.  Barely any mana to manage.

Regulus auto attack build is similiar, but not as deadly.

I'll switch DA to blade of the serpant as i can't edit the essence of magic logic at the moment (templated so not hookable).  The default logic on serpant is pretty good.  It will trigger whenever the unit is below 60% mana if i recall and there is an enemy around.

 

Reply #88 Top

I might lower consumbable to the ~5 area. One thing I noticed but forgot to mention was that the AI seems to go through TP's and Sigils like candy. I suppose it's good to increase there survivability, but they seem to spend a ton of money on them.

For Priests, perhaps change priest 1 to 15, priest 4 to 25, and have priest 2 and 3 inbetween so the AI sees them as high of a priority as mid-level items.

 

Reply #89 Top

I might lower consumbable to the ~5 area. One thing I noticed but forgot to mention was that the AI seems to go through TP's and Sigils like candy. I suppose it's good to increase there survivability, but they seem to spend a ton of money on them.

Agreed.  The AI doesn't exactly handle them all that well, but in my play throughs, the AI having a sigil definitely saved it more than once.  And them having some extra gold due to nightmare settings certainly help mitigate their waste initially.  TP's are almost always wasted by the AI, but at least on cataract, they do tend to port out after a near suicide run on their opponents portals. 

Peppe - seeing as beast is already pretty decent and probably only needs some small tweaks, I'm going to provide some feedback dealing with him.  It'd be nice to get one AI as near to perfect as we can. 

Can you help me understand a little more about the Lua file?  How many builds do you already have encoded from UB?  I see quite a few builds in there... does the AI just randomly select a build or is there some sort of order?

Reply #90 Top

 

Use pacov.

 

I recommend downloading notepad ++ it will color code the file for you making it easier to read.

-- means ignore this line (commented out).

The 3 builds for UB that came with the game I commented out.  So the only active one is my build named 'ooze_speed_stats'

 

SkillBuilds = { builds } is a table cotnaining all the builds this hero can use.  The game randomly selects a build at the start of the game to play with.

A build in there starts buildname = { build content } creating a table of the builds atributes.

I have customized the processing of the build content, but basically the first part is all the skills it can learn.

Then there is a list of achievments (randomly selected if multiple).

Then the list of item weights for this build, priorities addative to base value.

Reply #91 Top

First, thanks for working on a mod like this. Just read through the posts and the one thing after reading some game summaries that because different rank priests heals can stack while all bishops are on a "bishop heal" cd to my knowledge would you be able to prioritize if one general buys bishops, 2nd general buys high priests to maximize team healing. Keep up the good work

 

 

Reply #92 Top

Item counting appears tied to a given unit.  There might be a way to look at each unit on a team and count thier idols and adjust the priority of the priest idol based on the result, but it would be a good amount of custom code.  I'll probably save that for sometime later unless its critical.

Reply #93 Top

I'll probably save that for sometime later unless its critical.

Probably not critical, but would be a nice add on at some point.  Only really matters when the AI's are bunched together.

Reply #94 Top

@Peppe: The trick is to remember you can put whatever LUA code you want in your hook files.  Don't try to use the same template syntax in your hook file.  Instead just either override individual values or replace entire code.

Example of how to override the PurchaseItems goal using a hook file for ItemGoals.lua:

Code: javascript
  1. HeroAIGoalTemplates.Purchases.BaseInsistence = 2

Example of how to override an entire complex goal (instead of just changing a value or 2 like in the above example). This is a hook for MasterGoals.lua:

Code: javascript
  1. # Override the Attack goal with a complete new definition.  Note we do this by ASSIGNMENT of a new table to the Attack template.
  2. HeroAIGoalTemplates.Attack = {
  3.     Name = 'Attack',
  4.     MasterGoal = true,
  5.     GoalStatusFunction = function(goal, unit)
  6.         local numEnemies = unit:GetAIBrain():GetNumUnitsAroundPoint( categories.MOBILE - categories.AIR, unit.Position, 25, 'Enemy' )
  7.         if numEnemies == 0 then
  8.             return false
  9.         end
  10.        
  11.         local enemyThreat = unit:GetAIBrain():GetThreatAtPosition( unit.Position, 1, 'Land', 'Enemy' )
  12.         if enemyThreat <= 0 then
  13.             return false
  14.         end
  15.        
  16.         return true
  17.     end,
  18.     MasterGoalWeights = {
  19.         KillUnits = 2.0,
  20.     }
  21. }

Of course I've not actually tried this, but I am fairly certain it works.

Also, do you know how to use Subversion?  If you setup your google project with subversion and keep your code in the repository, it will make it easier for someone else to jump in...subversion will handle all the merging of changed files etc.

Reply #95 Top

Also...you should be able to use this same hook technique for the hero builds.  I recall you said you had to hack the code which picks a build to make it skip past the standard builds and only use your new builds.  Another way is with this hook technique to just add code in your hook file to just remove the standard builds from the table using table.remove().  For example, if the file adds 3 default builds to the "SednaBuilds" table and you dont want the game to use them, then you can in your hook file probably just do "table.remove(SednaBuilds, 1)" 3 times to remove the 1st entry from the SednaBuilds table 3x which effectively removes the 1st 3 builds from the table.  Then add your own builds.  Or if you know you want to remove all of the default builds, then "SednaBuilds = { }" will remove all the builds by resetting the array to empty, then you add your own builds.  Hopefully this makes sense.

Reply #96 Top

 

Thanks BMAN this is my first time using LUA, so this is great stuff.  I think you have just opened the door to easy modding of the AI actions, goals, and all that.   I did not even think they were variables i could overwrite in my own hooked files.

 

Do I need to clear the templates before i replace them?

This appears to be working, so i don't think so:

For my characters i changed my file from:

UnitAITemplate {
    UnitId = 'hdemonpeppe',

To:

UnitAITemplates['hdemon'] = {
    UnitId = 'hdemon',

....

In my hooked file if I had hdemon as the ID it would give the duplicate error, but now that is overwritting the table it appears to work. 

Looks like I can drop my name hack and use variables and overwritting from now on. 

 

I have also not used google code before, but I found where to turn sub version on in my project.   What is the best way to organize this and start uploading source code in addation to zip and installer versions?

Would you like to be an admin on the project?  I'm going back to work monday, so my updates will slow down and now that there is a lot more stuff to edit more contributors would be great.

Reply #97 Top

I'm really glad to see you modding folks working together and supporting each other.  Thanks guys!

Reply #98 Top

.10 is up

Code cleaned up thaks to bman.

Blade of Serpant achievement item conditions for activation modified

Goals modified somewhat to see what impact it has on the game.  Hope for more flag capping and moving as a team.

Alternate builds put in for most demigods.  Sedna, DA, OC, and Erebus have a single build.

Reply #99 Top

.10 is up

Thanks for all the hard work. 

If you didn't pick up on it, I'm fairly methodical in my testing and I try to cover as many angles as possible.  If you have something in particular you'd like tested, please indicate so in this thread.  Otherwise, I will test whatever makes the most sense to me and provide feedback along with test cases (and replays if needed) 

For instance, now I'm somewhat interested in what happens when the skirmish mod is enabled in 2v2 human games and 1 human drops.  I wonder what your mod will do then.  It's my hope, anyway, that this would be a great mod, not just for human vs AI games, but also for multiplayer in the event that a human drops from a team.  Not sure how all that will work out, but we'll see. 

Reply #100 Top

My id is [email protected].  Add me as a Comitter.  We'll see if that is enough permissions to set up the subversion.  Sometime tonight I'll set it up based on the latest version you have released then probably post a small tutorial on using subversion.