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

 

priests and angels are purchased late with cats.  Without cats they end up just giving your opponent more money without really causing trouble.   Cats and Giants do the real damage.

 

If they never buy the upgrades in everygame let me know the map and game setup and i'll try to recreate the issue.  I've mainly tested on the smaller 2v2 and 3v3 maps.   If it was just that one game then they probably blew thier money on items and didn't get around to the upgrades.  If there were 5 of them though I would expect they purchased most of the upgrades when cash allowed.

Reply #227 Top

Quoting Danmax, reply 225
What I meant was that they won't buy priests or angels even though we were at War-rank 8.

 

Unless I'm totally overestimating the usefullness of additional creeps, shouldn't the AI buy the extra help as soon as they are able?

What difficulty are you playing on?  I play on nightmare, so the AI gets a significant cash bonus and always starts buying the creeps at warscore 8. Indeed, it is so reliable that I just save my own gold for items.  However, on normal or easy difficulty, I would imagine that AI players might not have the gold to upgrade creeps in a timely way. 

Reply #228 Top

Peppe,

Given that you have the the most experience with modding the AI, can you tell me how the AI treats potions that are dropped from demigods when they die? I've been fixing Erebus's Poisoned Blood ability, and I think I did it. However, after a few tests the AI doesn't seem to want to pick up the potions any longer. I was wondering if you knew anything about it?

Thanks,
Ptarth

Reply #229 Top

 

I recall seeing a section of the code that deals with searching for potions.

 

I didn't mod that file.  It is in lua\sim\AI\Heroes\Actions\miscactions.lua

Line 80 ish and on is about potions.

# ============================================================
# POTION ACTIONS
# ============================================================

 

I think i read your post in the other thread.  You made a new potion or something for erebus's poisoned death potion?

I would think that action used to get pick up erebus's poisoned  death potion would be this:

HeroAIActionTemplate {
    Name = 'Pickup Nearby Damage Potion',

...

 PotionType = 'DamageRating',

...

  local potion, healVal = AIUtils.GetHighestValuePotion( unit:GetPosition(), PotionSearchRange * 1.5, 'DamageRating' )

...

}

Key thing here is the potion type.   If your new potion has a different potiontype it won't have an AI action that matches it and the AI will never search for your potion to pickup.

Edit a second look:

Poisoned blood may use the Health potiontype.  Looks like the action check for a specific value in the item blueprint to determine what type of potion it is and if a value is found it assumes it is that type of potion and allows the action to run.  Digging around in the function miscActions calls should get you down the right path for why your potions arn't being found.

Reply #230 Top

I didn't actually make a new potion (well, not exactly). What I did was to change the potion buff so that when the buff is applied it checks and applies a secondary buff that is based on team membership. It is somewhat indirect (a buff calls a buff), but I wasn't sure what functions Powerups (which is what the potions are) have.

I'll look into it now and see if I can fix it. Thanks for the suggestions.

Edit:

I traced the potion picking up code back to GetHighestValuePotion (AIUtilities.lua). In the function is accesses the value of the buff within the the potion declaration. Since I nested the buffs, the buff that affects health isn't within the potion. So I either need to provide a fake buff, move the real buff into the potion blueprint, or change the pickup code.

Edit 2:

I got it to work by adding in a fake table, that is: Health {Add = 0}. More details are available in the UberFix thread if interested.

Reply #231 Top

A while back I was asking about Logging AI actions, but forgot about it after you replied. I was curious about how the AI was making decisions and such, so I was attempting to enable all of the debugging and logging options. I'm not sure if you have looked at it, but some of the logic pathing is visible. I'm attempting to enable the rest of it, but if you already have and could hook me up with it, that would be great.

So far what I've gotten is some of the Logging and Chat messages from when it initiates actions (or considers them at some level, I'm not quite clear on that yet). I've also got the pathing previously mentioned. Since no one has brought it up before, here is an image of what I'm talking about. Sorry about the image size.

 

The background of the map I turned off to free up system resources, just ignore that. Notice the brown circles and lines, that's the AI pathing that I was talking about. You can actually see it change in real time, especially when the AI is not moving. Also, in the debugging window you can see all of the Teleport to Shop Messages that are being generated by your Shopping function.

 

EDIT: I found some more interesting things.

First, there are some command line parameters that still function. Try running demigods with:

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

I'm not sure what, if anything, /debugai does. However, /aiwindow shows the current team goals!

It is somewhat broken, when I was running it it kept telling me that there was a string error.

warning: 00:01:24: 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

Tracing back to aiwindow.lua, line 439 shows that it is supposed to print out the Current Master Goal of the AI. I'm not sure if it isn't being set or if something isn't setup correctly.

Things that I've found is that the top little blue circle switches to Team 2. However, switching back seems to be broken. Likewise the blue circles in the middle on the left correspond to the Demigods playing. Your UI interface doesn't update correctly with this enabled. Dying will permanently leave you in the sepia death shading.

Regarding AI behaviors, the thing I most noticed is that the AI's have an unwholesome interest in Flag 1 and Flag 2.


Reply #232 Top

Thats very interesting Ptarth.

Now if you could somehow find out why the AI makes these pathing decisions (going to cap a flag past the towers for example), that would be great :thumbsup:

Reply #233 Top

Hi there! First I would like to say a huge "thank you" for all your effort. You, and all the guys participating in this thread, have done a great job to make the game as it should have been in the first place. I just run a game with your mode and these are my findings. I hope they are helpful.

First off, I can't see the replay because it will pop a window saying "Invalid gamestate critical error" and it will exit. Also, during my test, the game was minimized to the task bar twice for no apparent reason.

 

Map: Cataract

Players: Human (Reg), AI (Oak) vs AI (Oak), AI (UB), AI (LE)

AI Settings:Hard, High HP, Low Gold/Xp

 

Observations are limited to the Oak AI on my team because I can't watch the replay.

  1. After shopping at game start, Oak goes for the side lane opposite the one with the gold flag and stops at all our already captured flags to max them out. Then, he proceeds to the neutral mana flag but stops next to the tower without trying to capture the flag while there is no-one else there.
  2. At one point in the game we only had the mana flag captured while the other two middle flags were hostile. Oak TPs from base to the HP flag tower only to run the other way to defend the mana flag that was just starting to go down.
  3. Oak returned to shop constantly (probably to buy all those TP scrolls:grin: ) even with full HP and mana.
  4. At the beginning of the game, around lvl5, there where two oh, so familiar, suicide runs to our portals from the enemy AI. On both those occasions the enemy brushed by our portal flags before TPing out. Both times I got a message from Oak and he TPed straight to the flag. Later in the game when we actually lost our portal flags, nothing.
  5. I actually saw the enemy Oak capture our portal flag and immediately TP to it!

 

Everything else went perfectly as far as I could see. The AI bought good items, the builds really work and it bought citadel upgrades at all the right times. My team and our citadel was buried under a sea of Giant's clubs and other creeps. It was FANTASTIC k1 !

Reply #234 Top

 

Nice tinkering Ptarth.   Master goals should be a valid item for it to look up as there is a chat you can enable where the AI will chat its master goal.   The master goal changed far to frequently for me to leave that enabled.  Generally when I test something with a chat command from the AI i will enabled only that, though i have left on some of the use chats like buying upgrades and a couple of the teleports.  

 

Bloodraven,  The portal teleport may not have a distance check.  Most of the other teleports make a distance check to see if the AI could walk to the location fast enough.   I'll check into it, but not actively developing this right now.  

The AI may overuse's teleport, but my intent was to help get them in a better location, so if a tower or a portal flag is in danger they have teleport actions with a high weight (selected often) they will use.  A human would probably already be at the flag or near enough to the towers to go defend them the AI is often off doing its own thing.  I forget the threshold, but if you go ping on a tower for a little while usually at least a couple on the AI team will notice, select the teleport action, and show up at the tower.

Reply #235 Top

First, thank you very much for all the work put into this modification.  Fantastic!  I am not very good at this game and don't find many opportunities to play with a group of people so this will keep the game fresh for sure.

What I was wondering is how this modification worked with the standard difficulties?  If I selected Normal difficulty, would it have the improved AI with the same starting gold as myself?  Do I need to select a certain difficulty in order for the new AI to take effect?

 

Thanks!

Reply #236 Top

What I was wondering is how this modification worked with the standard difficulties? If I selected Normal difficulty, would it have the improved AI with the same starting gold as myself? Do I need to select a certain difficulty in order for the new AI to take effect?

No, you dont need to do that. The mod will work with any difficulty.

Although I would suggest Hard difficulty, its really up to you, depending on your skill, to select any difficulty you want.

"Mr Anderson, welcome back....we missed you...."

Reply #237 Top

just a bump to move this up a bit.

Reply #238 Top

Quoting morpheas768, reply 236

What I was wondering is how this modification worked with the standard difficulties? If I selected Normal difficulty, would it have the improved AI with the same starting gold as myself? Do I need to select a certain difficulty in order for the new AI to take effect?
No, you dont need to do that. The mod will work with any difficulty.

Although I would suggest Hard difficulty, its really up to you, depending on your skill, to select any difficulty you want.

"Mr Anderson, welcome back....we missed you...."

Hard is for the week, true followers of the queen only do nightmares!

Reply #239 Top

So - played a couple games using this mod.  The teleport logic is pretty bad at this point.  The dg's would try to port like a foot away for some reason.  It happened pretty frequent and got nuts when I started to push the middle.  The ai's would engage, then tp a foot away - then re-engage. 

Wonder if peppe's still around and has that ol dg desire to tinker with code. 

Reply #240 Top

Quoting OMG_blackmage, reply 238

Hard is for the week, true followers of the queen only do nightmares!

Well, he said he wanted to try normal, so I didnt want to suggest Nightmare difficulty, because I thought it might be a little hard for him.

 

That would be all.

Reply #241 Top

Quoting OMG_pacov, reply 239
So - played a couple games using this mod.  The teleport logic is pretty bad at this point.  The dg's would try to port like a foot away for some reason.  It happened pretty frequent and got nuts when I started to push the middle.  The ai's would engage, then tp a foot away - then re-engage. 

Wonder if peppe's still around and has that ol dg desire to tinker with code. 

 

In addition to this, the 'run home at all costs after we capture a flag' thing is really irritating.

1) flags rarely end up contested against the AI - they cap them, port out / run away, and you recap them.  of course AI will always be more predictable than human players, but jeez they could at least try to advance to another nearby flag, or chill and wait for a fight, or something.   they shouldn't ever be porting back unless they actually need to shop or are badly wounded and have poor regen.

2) allied ai that happen to be near you when you cap a flag will immediately stop and port back to base, even if that's where they just came from 15 seconds ago, seemingly even if they weren't specifically going to capture that flag.  if they were, they'll sometimes stop and teleport out when you cap it and they're nowhere near it.  looool.

 

Also, they seem to weight their own goals so highly now that pings don't even register.  If they were super-smart, I wouldn't mind so much, but they're always going to be dumb as a bag of rocks sometimes, and being able to ping them to a different location would be nice.  Seems like they were more responsive to pings without the mod, but I haven't tested it specifically or looked at the goal weighting code.  Significantly increasing the weight of pings seemingly had no effect.

 

I've had very little time or motivation to mod dg lately beyond trying to fix new little bugs that are found, but I can probably take a look at this eventually.  I just have no experience at all with the AI, so even if I get around to it, it'll be a slow learning process.

Reply #242 Top

I've had very little time or motivation to mod dg lately beyond trying to fix new little bugs that are found, but I can probably take a look at this eventually. I just have no experience at all with the AI, so even if I get around to it, it'll be a slow learning process.

yeah - i was contemplating looking through the lua and seeing if I can just remove tps completely as a quick fix (as I really doubt I could enhance or fix the existing logic). 

Reply #243 Top

Quoting miriyaka, reply 241

1) flags rarely end up contested against the AI - they cap them, port out / run away, and you recap them.  of course AI will always be more predictable than human players, but jeez they could at least try to advance to another nearby flag, or chill and wait for a fight, or something.   they shouldn't ever be porting back unless they actually need to shop or are badly wounded and have poor regen.

The failure to aggressively contest flags is the biggest shortcoming of this otherwise great mod.  I could even take the random teleporting if I knew that the AI would consistently capture flags for warscore.  I think that the problems lie in competing AI priorities.  I play on Nightmare difficulty, so the AI has plenty of gold.  So I think it teleports back to base frequently to upgrade its gear, even when it should be capturing flags.  At other times, it wants to capture flags so badly it will take an enemy portal early in the game (occasionally dying in the process). 

If someone was curious and enterprising enough, I think that they could tweak the teleport and flag-capture priorities to fix some of this stuff.  Unfortunately, I think that Peppe has moved on. 

Reply #244 Top

I've modified the code.  Peppe's a pretty smart fellow.  So far, what I know I have accomplished - disabled tp purchases by the ai.  Peppe built a ton of code to tell the ai when to head back to base.  This resulted, in some cases, for the ai to port back to just rebuy some consumables.  I, frankly, don't have enough experience to tweak what he built, so I simply removed the ai's ability to buy ports.  This seems to have resolved the wasteful usage of them along with ported back to buy a small pot, etc.

What I THINK I've accomplished:  changed the way the ai views portals.  I the last 2 test games (me + 2 ai vs 3 ai), I'd make efforts to snag their portals asap.  In peppe's original version, the ai never seemed to care all that much and wouldn't prioritize recapturing... it could be minutes before the ai would bother.  After my updates, the ai seems to try to get it back within 30-40 seconds or sooner.  At least, that's how its worked in my last 2 games.  Probably going to do some more testing, but then I'll probably release something if the enhancements are worthwhile enough (granted, turning off the ability really shouldn't be an enhancement... but it is atm). 

Reply #245 Top

No more time to test tonight - if you want to give it a shot and provide feedback, here you go:  http://www.mediafire.com/?9ry10266fp7rbbc.  No self installer - must unzip to mods directory, etc.  It has its own UID and incremented version number .

Reply #246 Top

Oak needs to be taught to shield and TP out when he is level 7. :)

He should also send a To ALL message when he does this- "Shenanigans, bitches! :D"

Also... testing... I love offline mode to try some things.

Reply #247 Top

What did you do to modify the behavior pacov? In the previous version the AI would fixate on capturing the opponents portal flags and it was difficult for it to switch to another behavior (like recapturing its own flags).

I spent some time browsing the changes that pacov made while I'm avoiding work for a bit. (the version I compared it to one was I had been tinkering with a few months back, but I don't think I made that many changes).

First off, I'm pretty sure # is another comment character, so all of those changes do nothing.

Peppe and pacov look to be a little heavy handed when it comes to adjusting weights for actions. I think part of the problem is that the weights are getting way too large and this is throwing the system out of its normal bounds.

Consider the following example. Pacov offers me one million dollars to get me a sandwich from the store next door or $10 to get a sandwich from the vending machine outside. I choose the million dollar goal and set off for the store. I go to the store, but someone keeps moving it around when I get close. I still want to get the million dollars and the store is still close, but I can never get there. Because I don't know they are going to keep moving the store, I keep trying. Likewise, the AI keeps after its highest priority goal, even though a human would consider a different, more achievable one.

Reply #248 Top

Game 1: 

One of my AIs caps the enemy portal around level 4. Nearly immediately an enemy AI moves to it, but loses the fight against the capping AI and has to retreat to base.

The AI never tries to recap the portal again.

:(

Game 2: Much better early on, During levels 4-6 there were 2 port caps by each side. The recapping AIs were on their way to those flags within 30 seconds.

Then things starting to get weird. At levels 7-12 the AI was trying to do nothing but port cap. It would walk past the HP/Mana flags, creeps etc...

Around level 13 my AIs were trying to kill the cit, and the enemy team left a portal capped for 5 minutes and then the game ended.

Reply #249 Top

Quoting Ptarth, reply 247
What did you do to modify the behavior pacov? In the previous version the AI would fixate on capturing the opponents portal flags and it was difficult for it to switch to another behavior (like recapturing its own flags).

I spent some time browsing the changes that pacov made while I'm avoiding work for a bit. (the version I compared it to one was I had been tinkering with a few months back, but I don't think I made that many changes).

First off, I'm pretty sure # is another comment character, so all of those changes do nothing.

Peppe and pacov look to be a little heavy handed when it comes to adjusting weights for actions. I think part of the problem is that the weights are getting way too large and this is throwing the system out of its normal bounds.

Consider the following example. Pacov offers me one million dollars to get me a sandwich from the store next door or $10 to get a sandwich from the vending machine outside. I choose the million dollar goal and set off for the store. I go to the store, but someone keeps moving it around when I get close. I still want to get the million dollars and the store is still close, but I can never get there. Because I don't know they are going to keep moving the store, I keep trying. Likewise, the AI keeps after its highest priority goal, even though a human would consider a different, more achievable one.

I'm a bit of an amateur when it comes to modding.  My quick and dirty solution (eg shotgun coding) was to eliminate the tps as I don't know enough to fix the logic and then try to ensure that that the ai would capture and recapture portals.  Hence, the VERY heavy handed weighting i put on the portals... I tried a lower, more in line but elevated weight, but in my tests that accomplished nothing. After I went heavy handed, all of my games had better results for recapping ports etc... but it may have just been a fluke.

What I couldn't figure out in the code was how to tell the AI to really focus on their own portal if it gets captured.  Instead, I think its focused on capturing any portal it can.

Reply #250 Top

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

Anyway, here are some things I've seen watching the Global goal settings. Global goal settings influence demigod AI behaviors. There are individual demigod goal setting, but I haven't gotten it to display correctly yet. Capturing the enemy's portal flags are goals that stay around 40 to 65. To give you an idea of what that means, most other goals are around 12. Defending your own flags is -25 to 0. Defending your citadel without anyone attacking it is an 8. When one of your portals is captured, recapturing it normally is around 50-75. However, under some circumstances it is not adjusted and is left at -25 to 0.

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.