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

Quoting Ptarth, reply 250
The AI code for Demigods is arguably the most interesting, I'm surprised that no one has gotten into it after Peppe.

The AI for SCFA was terrifyingly complex and not very smart/adaptive, so I never had an interest in it.  Subsequently, AI is the part of Demigod's code that I know the least about (since most of my knowledge is carried over from FA) although it seems to be quite a bit different than FA's, and a lot more goal/objective oriented rather than heavily sequenced and timed.


Quoting Ptarth, reply 250
Also, pinging a location gives a temporary 15 to 25 boost to the weight for that action. When Peppe upped the weights to flag capturing so much, he also made it so that pinging something that is not a flag won't change the weights sufficiently to change behaviors. Adding a +25 to a goal of 8 isn't going to override the goal of capturing an enemy portal with a goal of 60.

Lastly, yeah, the teleporting is a little too much. It does need to be reduced. I believe Peppe was working on it before he left.

That makes sense with the pinging - I increased the ping weight to something like 50, and it still wasn't making a noticeable difference.  I guess I'll increase it more.

Also, with the teleporting, there should be one or two functions at most that determine when a teleport should be performed instead of walking - this should be all that requires modification to fix the teleport issues.  I'll look for this when I get the time / desire, but I know I've already seen a reference to it when playing around with AI purchasing habits, I just don't remember which file/functionname.

Reply #252 Top

So, miriyaka, how do you feel about the very very very very interesting problem of getting the AI testing code working again? With a very small amount of work on my part I can get access to global goals and pathing information. However demigod specific goals aren't working correctly.

I mean, wouldn't it be awesome to have AI wars where you design your AI (without any cheats) and watch it fight another AI. Good times...Perhaps even good enough to spawn Demigod's own version of DOTA.

Reply #253 Top

I don't know what you mean by 'working again'.  Is there vestigial code in the mod somewhere for reporting demigod-specific goals or something?

Reply #254 Top

Yes. There is. I think.

Its easier to show you than to explain I think. Run Demigods using the following command line. (change it to reflect your path if it is different)

"C:\Program Files\Stardock Games\Demigod\bin\Demigod.exe" /skipintro /aiwindow

Grab my WIP version of the AI Mod.

Run a skirmish game with the console enabled and the logging window visible. On the left side of the screen is the AI Goal Window. On the left side of that window are a series of little buttons. They allow you to switch which is the target Demigod, however it doesn't work anymore and just starts scrolling error messages.

Also, yeah, the code overwrites everything and is sloppy. But... I have pie. So it is okay.

Reply #255 Top

I'll give it a try when I get the time.  Out of curiosity, what's the error message, or is there more than one?

Reply #256 Top

The first one I get is:

warning: 00:01:35: Error running '/lua/ui/game/gamemain.lua:OnBeat': attempt to use as string a nil value
         stack traceback:
             [C]: in function `SetText'
             ...ck games\demigod\dgdata.zip\lua\ui\game\aiwindow.lua(439): in function `Func'
             ...ock games\demigod\dgdata.zip\lua\system\callback.lua(47): in function `Call'
             ...ck games\demigod\dgdata.zip\lua\ui\game\gamemain.lua(215): in function <...ck games\demigod\dgdata.zip\lua\ui\game\gamemain.lua:214>

I keep getting distracted and don't get around to looking for it when I do have time. I think there are also some problems with putting text into the AI window.

Reply #257 Top

I don't see anything wrong with that particular call.  The argument provided (MasterGoal) seems to have been confirmed non-nil earlier on in the function.  Maybe adding a few log messages to the effect of repr(aiData[hero.currentGoap].MasterGoal) both at the initial check where hero.currentGoap is set and right before line 439 where it's used might shed some light on what's happening.

Also checked HeroGOAP.lua, and I don't see a way that Sync.AIData.Hero[self.Name].MasterGoal (the same as above, only on the sim side of the sync) could not be set, or could be set to something that SetText would freak out at.

Reply #258 Top

I tried with and without the mod and it is definetly an improvement.

Improvements I noticed:

_ AI is never idle, unlike vanilla AI.

_ AI doesn't charge with low HP.

 

I don't know if you can do anything about it, anyway here's what could be improved:

_ the AI tries to teleport when it's very close to its destination (both when attacking and retreating).

_ it always purchases TP scrolls. Well, I don't, so maybe I'm the one in the wrong.

_ Sometimes it spends a lot of time at the shop (around 10 sec, often at the beginning of the game).

_ when a gate is taken it doesn't put much effort into taking them back, compared to vanilla.

 

Thanks a lot for your hard work. Tell us in which area you need feedback (even though I would not be able to tell if it picks good skills since I'm a bad player).

Reply #259 Top

it always purchases TP scrolls. Well, I don't, so maybe I'm the one in the wrong.

Most MP players use TP scrolls.  In SP, its not as important.  The problem is not so much that the AI buys the scrolls, but in how they use them.  I modified this mod awhile back so the ai won't purchase the tp scrolls, which solved some of that problem. 

Reply #260 Top

On second thought, the AI doesn't purchase so many TP late in the game. It is only striking at the beginning.

 

Maybe it can't afford anything else so it keeps purchasing (and using) them at the beginning, until the cash flow enables them to purchase dearer items. At the end, I often see them retreating on foot instead of TP. Shouldn't it be the other way? More TP at the end?

But the real question is: can they code that kind of behaviour at all? I don't think so.

 

Maybe we could ask the AI to purchase TP everytime it's shopping and prevent it from using them at will. Like for short distances. Besides we could randomize its usage, so that it won't systematically use a TP if it has one. Is that doable?

Reply #261 Top

Item purchase prioritization is actually one of the easiest AI-related things to do.  Each item can have a PriorityFunction associated with it that is called whenever the AI goes to purchase anything, and this function can access any piece of information related to that Demigod (as well as sim-global variables and functions), letting you scale priority based on say, level, game time elapsed, other equipment present, etc.

Look at the mod's AIGlobals.lua, line 253.  There's all sorts of conditions that you could put within that function to change when and how many teleport scrolls the AI buys, and if you don't have a lot of experience modding the game, you can still see some examples in the other items in that table.

It looks like Peppe just set it to 20 regardless of the conditions, which is not a great thing.  It should probably be prioritized a lot lower (1-5 maybe) once the AI has one of them, unless it's late in the game and/or the AI has a lot of gold.

If you do start changing priority returns, keep in mind that the AI is currently set up to always buy the highest non-zero-priority item it can afford, so even with a priority of 1, it may still buy TP scrolls if it's out of money for anything else.  Therefore, there may be some circumstances where you'd want to return 0.

 

There's still the issue of when they use the scrolls, which is more often than not to teleport to a tower under attack 5 feet away, or immediately after leaving base and capturing one flag, but solving those is a bit more complicated and I haven't had the time or desire to hack away at that yet.

Reply #262 Top

Just hold tight, everyone.  Some further improvements are on the way!

I've been tweaking Peppe's mod for a few weeks and plan to release a substantial update either later today or tomorrow.  It should really improve things like the AI's flag-capping routine and teleport logic (no more teleporting "5 feet away").  Additionally, I've customized the AI so that it prioritizes flag capping based on the flag layout of a particular map.  So on Cataract, it will be preoccupied with the middle three flags (ManaMax, HealthMax, and Exp.), while still checking on portals, gold flags, reinforcement flags, and cooldown flags.  On Prison, the cooldown, exp., and artifact flags are prioritized, but the AI will protect portals.  Capping priorities on other maps are customized in a similar way as well so that the AI actually goes after the flags that it should.  Also, the AI will not let its portals stay in enemy hands for long periods of time, as it presently does.

The biggest issues with the last version (.22) of the AI Skirmish Mod were that it did not battle for warscore well (that is, go after flags aggressively) and it teleported in some goofy ways.  I've fixed both of these issues.  The AI still teleports--I think that everyone would agree that it really needs to be able to teleport in order to be at least minimally competitive. However, its teleport trigger is limited by a minimum-distance check.  That is, unless the destination is at least a certain distance away, it will not teleport but instead walk. 

This updated AI (v.23) should provide a reasonable challenge, especially on Hard and Nightmare difficulty (I didn't test the lower difficulties, which should also benefit from these changes).  Of course, a lot depends on the demigod matchup, the skill of the player, the map, etc.  However, after a lot of test play, I have to say that I'm pretty satisfied with the revisions.  The AI, of course, will occasionally do some inexplicable things.  But this is less common and the new flag-capping aggressiveness and teleport scripting make up for a lot of the shortcomings.  I consider myself a decent (former) pugger with a 45-50% rating and a few hundred games under my belt.  So I do have a good sense of what people would expect in a good game.  Thus, I am rather happy to report that on nightmare difficulty, my team has been beaten at least once on most maps--and more than once on a few!

I'll start a new thread probably later today after some final playtesting.  I'll also try to get up a zipped copy of the updated mod (called "Skirmish Mod v.23") for everyone to play around with.

Disclaimer: I should say here that all praise should go to Peppe for this mod.  Just looking at his work, I am amazed by his grasp of the coding and the things that he's accomplished. Thus, I make no claims to this mod.  He's done 90% of the work; I just added 10% tweaks to refine it a bit.  I hope that he's cool with these tweaks (and maybe flattered by our continuing interest in his work), though he seems to have left the community some months ago.  In any event, I do take just a little credit for inspiring him to start the mod in the first place (see http://forums.demigodthegame.com/369842).  Again, many thanks to Peppe for giving this game some extended life.

EDIT: The new .23 version of the Skirmish mod is now available at http://www.filefront.com/17207898/Skirmish_AI_v23.zip/.  I have started a new thread for discussion at http://forums.demigodthegame.com/390855.