This mod (version .24) is the latest revision of Peppe's AI Skirmish mod (http://forums.demigodthegame.com/369930). It further refines Peppe's excellent work by addressing a few outstanding issues. The mod is designed to make single-player skirmishes more challenging and enjoyable.
(This version of the mod incorporates some of miriyaka's code for checking team status and upgrades, which makes the gameplay more dynamic and "human like.")
-AI demigods upgrade citadel health (fortify structures upgrade) based on war rank and the percentage of health that the citadel has loss due to enemy attacks. AI demigods will buy trebuchets and Finger of God based on whether the enemy team has catapults or war rank of 9 or higher (creeps are still the highest priority).
-Teams start buying creeps at war rank 8 or when the enemy team reaches war rank 8. So even if a team has less than war rank 8, it will try to get priests and angels if the opposing team has achieved war rank 8.
-AI demigods will dynamically buy Armory and Blacksmith upgrades based on war rank, the creeps its team has, and the creeps that the enemy team has. By war rank 10, AI demigods will try to buy all Armory and Blacksmith upgrades.
-Tweaks to flagassets file that makes AI demigods more aggressive for portals after either the allied team or enemy team achieves war rank 8. Also, makes AI demigods fight for portals well after giants show up.
-AI demigods will now only buy capture locks after their team or the enemy team reaches war rank 7. At that point, capture locks become a high-priority consumable and are used for locking portals and the reinforcement (fortitude) flag.
-Teleport scrolls become a higher priority for AI demigods by war rank 7 (they are a high-priority consumable throughout the game).
Known Issues (v .24):
Installation:
Place the Skirmish_AI_v24 folder in your Mod folder in your Demigod game directory. This is usually found in C:\Program Files\Stardock Games\Demigod\bindata\mods. After starting the game, go into the “Mods” option and enable the mod. Be sure to disable any previous version of this mod.
Disclaimer:
The core code of this mod belongs to a guy named Peppe, who apparently no longer frequents these forums. The Demigod modding community is in his debt for improving the AI of this game.
Download:
Get version .24 of the Skirmish Mod at: http://www.filefront.com/17277395/Skirmish_AI_v24.zip/. Download includes mod folder and readme.
--------------------------------------------------------------------
.23 Changes: 8/16/2010
.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.
ok - basing the following logic on cataract.
Standard MP logic is as follows:
All dgs shop at start. About 70% of the time there is a big battle at mid (eg all 6 dgs fight at mid). Its brief though. 1 team will give up and leave to go to other flags. Its generally not too intense (like 10% of the time it is, but peeps usually back off). Then, 2 will go to hp on both teams and 1 will go to mana to power level. The dgs on mana will trade flags with the other dg on mana for mid (eg 1 will cap mana while 1 is walking to mid, then go to mid while the other is going to mana - and so on... there is generally not a huge conflict). That's the meta game in high level games for awhile. No one generally dies for a long time. And important AI logic change - stand by your tower and absorb creep waves if you have lower hp... not low enough to die... but low enough that you can't go out and fight. That way, your dg still levels up... much better than running to base.
The next big thing that happens is that if towers are getting jacked up, someone goes back to get fs1 early (unless its pointless). The MOST important thing is having someone buy currency 1 AS SOON AS WAR RANK 3 is up. This MUST happen as close to 3 as possible - especially in a high level mp game.
Anyway, that should cover the early game for you. A way to offset some of the logic would be to have 1 AI buy fs1 at the very beginning as a super high priority. I think the biggest tweak would be to make sure some AI buys cur1 as close to level 3 as possible (including SAVING 1800 gold for cur3 AFTER they make their initial shop).
Ok really going to call it a night now . Interesting that humans do a battle royal in the center as well. Guess the AI does it the right way now. They finish shopping a few seconds after the opening camera spin finishes and head right for the center. They then tend to trade the 3 center flags back and forth and usually a corner tower is picked off a few minutes later.
For the leveling up at a tower... i might be able to accomplish this with a little override. Maybe under level 5, between 40%-60% health the action should be move to ally/defense. Not sure they will move to the right ones. Whats the range on xp gain? In the game i tried even if you catch every wave to get yourself to 5 the nightmare AI will outlevel you.
Getting sleepy, so don't have time to replicate changes and release mod version. But here is the TE edition:
new edition in post below.
Per Pacov's suggestions: New mastergoal override - At war rank 3, if the demigod has 1800 gold and currency has not been purchased yet it should drop everything and get back to base to shop. Currency has the highest priority, so once 'shopping' begins it should be the first item purchased. You should see currency through the AI's going very close to war rank 3.
I found a repeatable stuck demigod in x slot issue. I played around with shop timings and cleared that up. If you get a stuck demigod at game start let me know what slot and how many AI's on each side and usually it can be recreated and maybe fixed. Stuck demigods later may be a path finding issue, so let me know the situation and map.
New functionality to Auto Fill button in lobby. Game options now has drop down to set difficulty and drop down to set game size for auto-fill (1x1, 2x2, 3x3, etc). Autofill only adds unique demigods (no duplicates). Clicking the button multiple times will regenerate the demigods selected and which slot they are in.
I don't know - you could set it to something arbitrary like gain 1 level or something to that effect. In normal MP games, you generally stay as long as its practical... and "practical" is determined by how well your teammates are doing on the HP flag, what the flag control situation is, etc.
That's great. Happy to test and confirm.
Nice idea.
Side note - love that you added additional options to the game option menu for auto fill level and auto fill size.
Only had time for 1 test, but that play through was fun and challenging at points in a 3v3 all nightmare.
I had a couple hours tonight. No major changes I took a swag at the random stuck at start AI issue. I believe I have settled on a reliable work around. I started 5v5 games for about 20 minutes and had a stuck ai every 4-5 games, but they all recovered through the work around (details below).
Version E -- Newer version in post below
Maybe its time to get with Hunger on making a .25 release. I touched way too many files testing a work around, but i'll try to pare it back to the minimum and make a mod version of this as well.
Changes
One cool thing i stumbled across is in sim\ai\BrainPlanner.lua you can set line 99 to true and the AI will play for you. You can issue commands as well, but the AI will also be issuing commands for your demigod. I didn't test for more than a minute or two, but it was cool spectator type mode.
I see you implemented a value cap for initial item purchases - this is great. From what little I know of the AI purchasing functions, it should also be fairly simple to change this (for all purchases) to a graduating value cap dependent upon how many open slots there are in inventory, i.e. a lower cap with 3 slots free than with 2 free, to encourage the AI to fill its inventory before it splurges on an expensive item. In a case where the AI can find no prioritized items under the cap and has plenty of gold to spend, the cap could be further increased or lifted.
@miriyaka yeah. I just inserted a fixed cap based on time, but a function that counts the free slots and ups the cap by a range would be optimal. Would also need to go to each build and make sure they have enough cheap items, or set the priority of the good cheap items globally. I'll add that to the wish list as I would like to see it fill its item slots before getting expensive items.
Anyone else have some ideas?
Release 'F' :
TE Version: http://www.filefront.com/17547655/Skirmish_v24_TE_f.zip
-This version works in all game modes (tournament/skirmish) and adds some functionality to the auto-fill lobby button.
Mod Version: http://www.filefront.com/17547662/Skirmish_AI_v24_F.zip
-This version only works in skirmish mode and has no lobby modifications.
Gameplay should be the same in each version.
Changes to F:
Found a little quirk with what I guess is an endless loop in my 'Stuck Sensor'. The AI stopped shopping outside of the initial buy unless explicitly told to due to the sensor I guess. Modified the sensor to have an exit. It should still be active it will just now cycle properly and will just exit out if the gametime is after 30 seconds.
Tweaked health potion usage. Crimsom vial is lumped in with all the health potion, so i dropped the need for safe location to attempt to use these health items.
Macro game is looking pretty good to me. The AI's master goal is often to captures flags, so it is going to the right spots. The AI's tend to select the same flags, so it looks like they are working as a team
well, peppe - you are the winner of my time for testing tonight.
game 1 - me/kalel on cata - 4 nightmare ai on the other team, 1 nightmare ai on our team. The only thing that caught me as OFF, was at one point our AI (qot) was spamming a LOCK FLAG message (at least 20 times) when a portal was threatened. We won without too much effort
game 2 - me/kalel on levi - 2 nightmare ai on our team - 5 nightmare on the other team. We actually got beat. Anytime one of us would start to work on an tower (towers were on high) the ai seemed to be right there and took us off the tower. Didn't see anything horribly off. I was leveling great, but the ai had a level 20 sedna that was a complete nightmare end game. So, it actually was challenging. I'm not sure if kalel was goofing off (don't think so), but I had a very good kit and was fine in 2v1 combat... just not against sedna. Anyway, good stuff.
Playing a final game now 3 human + something vs something ai.
game 3 - kalel/thunder/pacov/nightmare ai v 5 nightmare ai on zik. We had an easier win this time. Good comments though - our ai bought about 90% of the upgrades allowing us to focus on buying bad ass items. It was fun. And also challenging mid game. The ai swarmed to us alot...
playing 1 final game on brothers.
last game - jona/pacov/kalel/thunder/1 nightmare ai v 5 nightmare ai on brothers.
Not super interesting - lots of action at points. The biggest challenge game early game with the ai swarming folks. It was chaotic at points as well (which is good). But, the overall message was that things were all that interesting. Still - fun after a sort. I think we decided that if we do another 4 human game we should drop the 1 ai on our team.
I can't make this clearer, though - having an ai on our team was actually a huge benefit and THAT is VERY different from traditional dg logic (eg if you a player dropped and you got an AI, you were done). In this case, the AI seems to buy the majority of useful upgrades freeing us up to do whatever we want with our money.
Welcome back, Peppe!
After being away for a while (and assuming that this thread was dead), I just happened to check in again today. I am very happy to see that work is continuing on this mod, especially the tournament AI. I still find (modded) Demigod quite fun offline, so I'll occasionally stop by for updates. Thanks to everyone for their work and feedback.
@OMG_pacov
Thanks for the testing glad to hear the AI is finally a worthwhile teammate and tougher to go up against.
I think if a player drops the AI that takes over will still purchase upgrades, select decent items, and capture flags. So it won't be a useless teammate. The only difference should be the lack of a skill plan. Its skill selection is going to be a weighted random using the default settings that come with the game. Its a neat looking function that makes the next skill purchase based on the existing skills selected.
I think Sedna is one of the best AIs because she spends like 90% of the game in the field. Most AI's retreat back to base when they get hurt, but as long as she has mana she will retreat, heal, and reenter the fight. She shops much less often as a result, but then usually has the cash to buy nice upgrades.
@the_hunger
If you are not active I may start up a thread and release a .25 version. I didn't want to step on your toes if you were active.
I have an offline version that i think is a release candidate. I hope I have finally found the source of the stuck shopping AI. I have slowed down all its shopping functions. So now it a slow deliberate shopper taking about a second per action. Haven't seen it get stuck yet.
I have to go into work for a couple hours, so the mod version may be delayed. Here is what i think the .25 release will be:
http://www.filefront.com/17550380/Skirmish_v24_TE_RC1.zip
@the_hungerIf you are not active I may start up a thread and release a .25 version.
By all means, release v.25 and a new thread!
Do it to it! Looking forward to reading the changelog and providing feedback.
Quick thought on this - I'm wondering if the spammed message was because the qot's lock was on cool down. Not sure if it was, but I do know she had a lock at the time.
One final bug i want to squash and then i'll replicate changes in the mod version and do a release. For some reason the AI refuses to buy unbreakable boots when it has the cash and it is the highest priority item. Its driving me crazy. In then like 10 minutes into the game it will buy them.
heh - you can do it, Peppe! Crush dem bugs!
Getting closer. Logged every step of the function. The AI thinks the boots cost 1750, so won't buy them at start (where i have capped the purchase at 1500 to get it to buy more items with its 4k. I'll see if i can find why it thinks an item that costs 1500 is 1750.
Found where it is marked 1750. Wonder if this could be the cause of some of the AI's shopping woes rather than how fast it shops. Just doing a quick look at the boots file and 3 of them have the wrong price. This isn't a major issue when the price is marked higher, but if an item is marked lower in these files, so the AI thinks it can afford it, but is actually more expensive it could cause unexpected behavior.
For anyone curios, File is dgdata\units\ug\b\ugbshop01\UGBShop01_unit
Going to check each shop.
Oh, nice catch. Those should probably be zeroed out, as all but one of them is wrong, and will be influencing prices (and possibly even availability) for any function that returns the main shop unit (ubgshop01) instead of the shop tab blueprint (ugbshop10 in this case). Out of curiosity, which function is being used to the shop blueprint?
I'll try setting Tree = {} and see if that causes any problems. If not, it's going in the UberFix.
Function is FindBestBaseItem(...) In lua\sim\ai\AIshopUtilities
It derives the shop types from the item:
First it gets a list of all item priorities from the brain. And loops over each item to find the best item to buy.
for _,itemData in asset.ItemPriorities do
...
# Store out each shop only once; this way we don't have to find shops more like crazy if shops[itemData.ItemTable.ShopType] == nil then local shop = aiBrain.GoalPlanner:GetFriendlyShop(itemData.ItemTable.ShopType, unit:GetPosition()) if shop then shops[itemData.ItemTable.ShopType] = shop else shops[itemData.ItemTable.ShopType] = false end # all shops of this time seem dead, continue to next item if not shop then continue end end
....
end
The other individual shops all looked good, except there are the two boot shops in the folders. ubgshop01 (missing some boots) and ubgshop10 (looks like everything we see).
-----------------
There is another bug where the ai cannot buy the experience upgrades at the citadel. I was going to take a fresh look at that.
While i was in there I saw the experience level 4 removes the wrong buff when it is upgraded:
In the normal code when you upgrade to experience level 4 it has loses 04 in there.
CPortalFrequency04 = { Dep = { 'CPortalFrequency03' }, Icon = '/CitadelUpgrades/CitadelUpgrade_PortalFrequency', Level = 8, Cost = 4800, Loses = { 'CPortalFrequency03' #[MOD] TE Fix Port 4 upgrade },
Yes, both of the Experience-related bugs are fixed in the 1.03 UberFix. The reason it can't buy experience is because one of the functions in AIShopUtilities (GetUpgradesList) ignores any cit upgrades that don't have a buff with the same name. Experience upgrades are named 'CPortalFrequency', while their buffs are 'CTraining'. I fixed this non-destructively by just pre-generating some dummy buffs with the same names as any cit upgrades that don't already one associated with them.
As for the boot shop thing, ugbshop01 is the actual shop structure itself that appears in the world. Why it has boots in its shop tree, I don't know. Why it has a shop tree at all, I don't know - it relies on sub-unit blueprints (ugbshop02-10) for its actual shop tabs.
Setting its shop Tree to false in a unit blueprint merge should fix it just fine, if all functions are returning the correct shop type and blueprints for non-boot items.
any concerns that uberfix and ai skirmish won't play nicely together? Thinking of compiling both into a quick release for the folks helping me test.
I've always played every test game with both, so I'm not too worried. I haven't had time to look at the code for Peppe's .24 versions yet, but unless he's radically expanding the scope of it, it shouldn't be a problem. All of the fixes I've used in the UberFix related to AI have specifically avoided overwriting anything, and are meant to be fully compatible with any mod that changes anything in those files (e.g. this mod).
Of course, I have no idea what extra files are modified in the tournament version. I assume that Peppe is just replacing any files in the campaign branch mod with AI Skirmish Mod variants, and there's no way I know of to get the UberFix running in tournament mode as well without doing the same, so it's not really a concern.
Edit: Peppe, I just took a browse through AIShopUtilities, and if I'm correct, the AI will not be able to purchase any boots that are not listed in that errant table in ugbshop01, even though that's not the real boot shop that the AI will be buying the item from, or (hopefully) not the real prices they'll be paying. Likewise, I can't just blank out ugbshop01's shop tree in the UberFix, without doing something about the mis-assigned boot shop in GetItemsList.
The only solution I'm seeing to the problem is to change the Boots shopId to 'ugbshop10', as it's supposed to be. Unfortunately, it's a local table within the function (I hate hate hate when they do that for things like this, agh), so the whole function will have to be overridden. I assume you're already doing this? If so, just make sure that gets changed in your copy, and it should override whatever I decide to do with the UberFix version.
Hah came to post my fix for the experience and you had posted you already fixed it.
I don't know if this will work in mod form, but i just updated the buffs to match the upgrade name. I don't believe there are any citadel upgrades without buffs.
I haven't looked at UberFix yet. Should i look to combine the changes in there into the AI mod?
I initially tried changing the buffs, but I recall that having a few unintended consequences - one of which is breaking any mod that rebalances citadel upgrades. The buff creation fix I used is really clean and non-destructive. You're welcome to include a copy of it it, if you're not already overriding GetUpgradesList in AIShopUtilities. If you are, just remove the check for the buff, and it'll resolve fine.
Edit: The copy of .24 I have installed right now has an overridden GetUpgradesList to add the priority stuff, so just remove the buff check at the top and you're golden.
Edit 2: AFAIK, the buff check is totally vestigial. I just looked through AIShopUtilities and FriendlyAsset, and I don't see buffs ever referenced for citadel upgrades anywhere else in the priority change. Maybe they were planning to add some kind of buff evaluation, but (smartly) decided not to bother, because there are a jillion better ways to handle citadel upgrade priority.
There are many great features available to you once you register, including:
Sign in or Create Account