I created a post that tracks the history of the AI in Demigod and it covers a good chunk of the development that has already been handled by the modding community. If you are interested, see over here for more details: http://forums.demigodthegame.com/409712

The Project

Using the last version of peppe’s AI mod (0.26.35), I’ve started development on updated versions of the AI mod. I’ll be releasing those versions here, tracking bugs, enhancement requests, rebalancing, etc. I won’t be adding a new version to my combined DG installer until we make a decent amount of progress or come up with some sort of significant enhancement to justify a new release to the community at large. It took us a long time to get reasonable adoption rate on the existing ai mod – I’d rather not force folks to redownload the bundle over and over.

The Project Team

Project lead: pacov

Lead design/coder: pacov

Lead support: miriyaka – without miri, the majority of the changes we are looking at would not happen

Testers: sledge, plaguewraith, and darkliath

Contributors: Lord_Orion

If you’d like to help in any way, we are happy to have you on the team.

Current status (what’s being worked on)

Build updates (removing inefficient builds and replacing them with new ones) - complete

Reprioritization of citadel upgrades, items, trips to the shop - largely complete - some late game tweaking still possible, but its improved quite a bit

Implementing a fix for AI’s with summonable minions so that they do not waste mana summoning more after the have created the max number of minions (miri created some code and I’m looking to make it work) Resolved in 0.26.41

Recoding the ShouldSave functionality to improve the coding efficiency and gives us additional flexibility. If we get this working, it will be a very solid improvement and provide more options. - this has been implemented

Bug list (unless otherwise noted, these are all bugs from the original 0.26.35 version)

Stuck AI – the AI can get stuck on occasion for > 30 seconds

Poor scaling based on AI difficulty - this has been improved but there is still room for improvement

Not enough shopping trips for the AI unless it is killed or sent back the base with low HP (eg an AI could have 10k gold and still not attempt to shop and get better items) - 1 forced shopping trip at wr 4 has been added... might be good to do more, but much better now.

AI is not always getting fs1 in a timely manner (resolved in 0.26.39)

Some abilities are not being used as often as they should (a sedna, for instance, with pounce as her only ability would use it once in a blue moon) - continuing to make improvements (pent/pounce/grasp/deep freeze have all been fixed)

Some abilities are being used at inappropriate items and wasting mana as a result

Customized settings often throw the AI off. For instance, if you set a game to being at WR10, the AI don’t shop (not sure if we want to try to code this to cover all possible settings) - improved some.

AI standing around at the shop at the beginning of the game (introduced in 0.26.38 – happens randomly and seems to only impact 1 ai on a team) - resolved in 0.26.40

Not truly a bug, but something I want to change - need to make it so the high gold dg can still buy things for themselves (resolved in 0.26.49 "siesta")

AI considers minions as part of a DG's army... this is good and bad - its good to target healers from time to time, but if I can make an enemy target a shambler while I'm wailing on him...

Enhancement requests (these are changes that folks would like to see happen with the AI)

Better healer distribution. The over all goal would be to ensure that monks/clerics/etc are sent to appropriate players. The basic code works fine, so this is a lower priority change imo.

Improve da’s shadow swap usage – plaguewraith suggests removing it completely from his build (might be a good temporary solution until we can tackle this) (removed 0.26.55)

Better creep farming with skills. Plaguewraith indicated that he never saw a tb use circle of fire to farm. This is something we could tweak, but we’d need to think it through

Lord-Orion suggests we remove all ub builds except for Spit/Ooze life - REMOVED 1 OF THE BUILDS 0.26.40 - still 2 left

Lord-Orion suggests we optimize all builds for skill dmg output as the AI cannot currently rationalize like a human can.

Lord-Orion suggests we go with a basic item prioritization of 4 life/1 helm builds – I agree to some extent… (pretty much done as of 0.26.52)

Come up with a way for the ai’s to intelligently chain stuns or interrupts to go for kills. In theory, the AI could be even better than a human at this if it was tied to precise timing

Teach the AI to teleport for ganks (this could be tricky – would probably result in a lot of pointless tp’s)

Find a way to help the AI manage mana better. Early game the ai’s are almost always out of mana

Teach the AI when to shop! (big improvement with 0.26.49 "siesta")

Have the AI always engage a simple enemy opponent if on a flag if hp is good, etc

Have the AI choose to engage towers on a regular basis (improved a lot since 0.26.54)

Have the AI refuse to run past towers in most circumstances and instead TARGET THE TOWER if no dgs around

Improve cataract map logic – the ai often goes into the middle of the map instead of staying in a lane. This is probably due to the proximity of the creeps when the ai is working on capturing the middle flag (or if all flags are controlled by their team). Ideal behavior would be to try to capture the middle flag and if its already controlled, then get into a lane on HP or Mana.

Override the flee functionality if there is an enemy dg and its likely possible to get a kill

Better decision making for flags – Ai heading over from mana side all the way to Hp without capturing mana. this is likely due to flag weights… just not sure why it didn’t evaluate hp as the priority initially – could be some conflicting code?

Send the AI back to base if its low mana (sledge) – We might do something for this, but it would have to be a conditional statement – perhaps add a check to see if they are at low mana around X Ws have > X money, then run back and prioritze getting a helm as an override

Plaguewraith suggests removing mist from erb’s build – I’m not sure about this yet. He says remove it or build a routine to cause erb to use it just to get rid of negative buffs – I agree that we could use a routine like that. - mist removed in 0.26.40

Encourage the AI to react quickly if they are losing a flag that is near 2 or more towers (eg gold flag)

Increase the frequency that the AI picks up sigils – not sure about this one – I agree a good player should generally have one, but the AI might just blow a lot of money casting when it doesn’t need to and fall behind as a result. Perhaps this becomes a conditional statement to raise the priority after ws X (0.26.47 - implemented)

Add an override so the ai will only go for flags like gold if the tower is down. Add another override so the ai doesn’t go for portals early (probably WS related)

version 1.02- created new UID and incorporated all changes since version 1.01

version 0.27.09 BETA- Disabled a substantial amount of logging (will result in a substantial performance boost for many)- added miri's scenario name capture function to CommonUtils.lua (doesn't work now, but isn't being called)- began to tweak ub's usage of ooze. Reduced health activation from >= 40% hp to >= 30%. Also reduced the deactivation health value from < 40% to < 30%- reenabled the attack override in herogoap- updated the flee mastergoal to set at 50% HP instead of the current 75% hp- Added an action time to health pot usage to hopefully keep the AI from using a pot at lower HP, having the pot bring them up to full strength and then having the ai immediately sigil

version 0.27.08 BETA- Added new action and instant status function in useitemactions to keep the AI from "double locking" flags (eg wasting locks on a flag that is locked)

version 0.27.07 BETA- increased sigil activation health % from 45% to 50%- added new hammerslam calculate rates function - should increase the odds that rook will slam if the unit is stunned (should work for any type of stun)- rebalanced weights of rook's actions to bring them more into logical numbers- rebalanced weights of erb's actions to bring them more into logical numbers

version 0.27.06 BETA- reduced sigil activation health % from 50% to 45%- changed orb of defiance usage check so that it will consider using it before sigils- removed grunt check on orb of defiance (previous the AI would refuse to use use the orb if the threat level was < 15)- added nearby enemy hero check to orb of defiances - if no enemies nearby, then orb will not be used- reduced the value of narmoth's ring on the AA ub build so that it is not choosen as the only item at the start of a game on nightmare difficulty- reduced the captureflag override at the start of the game from 60 seconds to 40 seconds- disabled the attack override to allow the ai to make its own decisions based on weight- Reduced the reteat values if there are nearby enemy heroes and towers from 85% to 75%- modified rules for dg vs dg fights. AI will run if there are more enemies than allies present

version 0.27.04 BETA- continued to enhance the documentation in heroGOAP- added new logic to provide a count of heroes/enemies in heroGOAP for decision making- added rule so that the AI's goal will flee if 3 or more enemies are present vs 1 ai - changed default value of gold and portal flags to 0.5- increased unit.movecutoffrange from 1.2 to 2.5 in attackactions- fixed a problem with da's new swap logic- continuing to test out flagassets.lua - I don't think values are being loaded for each map

version 0.27.03 BETA- removed erb's desire to cast stun as an interrupt as its not possible- increased erb's desire to bite- increased oak's desire to use surge to kill units- removed sedna's desire to use silence as an interrupt as its not possible- added comments to heroGOAP to try to track where the AI is getting stuck (NOTE - this could slow down some lower end pcs)- added new logic to count the number of grunts near a hero for decision making purposes - previous check was based on threatlevel- changed the balancing capture flag logic so that the AI will re-prioritize capturing flags if there is a difference of 50 in warscore- changed AI's desire to buy capture locks from WR 4 to WR 6 - AI will not purchase them prior to WR 6

version 0.27.02 BETA- major revamp to DA's swap ability - da will now only swap if the number of allies is > enemies near da- disabled existing DA build- enabled STANDARD_ASSASSIN da build (eg what most players use when playing da) now that swap is working as desired- disabled pounce sedna build

version 0.27.01 BETA- updated TB's frost nova so that it is used more often

version 0.27.00 BETA- created new UID - this is done so folks can still keep the release version 1.0 installed and try out new "beta" versions and help with testing, etc- added additional documentation to AIGlobals.lua- adjusted the saving routine so that angels are not saved for until ws 7- changed the way the AI evaluates additional shopping trips. Now based on warscore- fixed a minor bug with reg's mark of the betrayer squad target- added additional shopping trips (see details below) # SHOP PERIODS # Warscore >= 300, AI with most money, possible to buy fs1, at least 600 gold # Warrank >= 3, AI with most money, possible to buy cur1, at least 1800 gold # Warscore between 2450-2575, NOT AI with most money, at least 1500 gold # Warscore between 3100-3225, AI with most money, at least 1500 gold # Warscore between 3800-3925, AI with most money, at least 1500 gold # Warscore between 4150-4275, NOT AI with most money, at least 1500 gold # Warrank 8 OR AI already bought the upgrade, priest/angel/cats available, AI can afford the upgrade # Warrank 10, possible to buy giants, AI can afford the upgrade

version 1.00- created new UID- removed any "pacov" labeling- changed name to Enhanced AI (peppe's original version was Enhanced_AI- updated version name to 1.00 (numbering convention will be 1.00/1.01/etc going forward)

version 0.26.55- fixed a bug that still allowed demon assassin to pick up swap- fixed a bug with unclean beast's grasp code- enabled new hammerslam/tower rook code and tweaked desire to hammerslam- increased sedna's desire to pounce (did not re-enable the pounce build yet)

version 0.26.54- removed the remaining demon assassin build and added a new build without swap per request- reworked the valor flags weight. Should be less desirable for AI prior to ws 8- tweaked deep freeze to be cast much more often- re-enabled ai priority to attack structures. Tweaked the formula so the AI will immediately back off if any enemy dgs come into range. This should reduce the odds of death and also keep the AI from wandering past towers for the gold flag, etc

version 0.26.53- increased artifact weight so they will be kept if the AI purchases- added mageslayer to the generic equipment purchase list with a priority of 110, moved godplate to 120- enabled oak to cast surge when trying to flee

version 0.26.51- rebalanced the general equipment builds- rebalanced the specific demigod equipment builds- removed AI's desire to purchase any graveyard upgrades- removed "cloak of invisibility" from artifact prioritization as the item does not exist

version 0.26.50- Reduced priority from 35 to 20 for boots of speed on UB HP/ooze build to keep the AI from purchasing boots of speed as the first item if the AI is set to normal- increased priority of grofflings plate in the general build- substantially increased ub's desire to grasp in game- updated flag goal for cataract to reduce the AI's desire to grab the valor flag early (eg the AI running to the middle of the map)- increased ice tb's goal to make it use deep freeze more often (tb's abilities all need a bit of an overhaul)- various item selection tweaks

version 0.26.49- changed desire for flag locks to increase at wr3 instead of wr4- adjusted AA ub build so that it will never choose mana items (unbreakable is still acceptable, though)- implemented the "siesta." At warrank 4, any ai (not the high gold AI), will return to base to shop as long as they have 1500 gold. Then, towards the end of wr4, the AI that is the highgold AI will shop alone.

version 0.26.48- added miri's check to force the tb to stay in whatever mode its build is designed for. This should improve the AI's usage of abilities tied to the pure ice or fire builds. Confirmed that fire tb will stay in fire form and ice in ice form based on build. - continued to balance item selections- Changed Rook's favor item to blood of the fallen- TEMPORARILY turned off the attack structure code

version 0.26.47- made MANY balance changes - all changes are noted in the files, but too many to detail here (so I'll cover highlights)- changed ideologies for the mod. Before the goal was to force the AI to do everything I wanted it to do (simply buy cit upgrades) - now I'm planning on having it scale that back and focus on becoming an arse kicker- odds your ai will have a sigil is MUCH higher - this improves survival odds ALOT- ai will always purchase fs1/cur1/priest/angel/cats/giants - that's it. AI will no longer get any levels of experience.- ai will VERY OFTEN have locks - I still need to teach the AI how to use locks better though... so at least for now, it will have them...- MANY item prioritization changes - If you understand the modding side of things a wee bit, there are 2 ways a dg chooses equipment/items: 1 - a general list that contains all recommendations. 2 - a list that is specific to demigod build. I spent quite a bit of time improving the general list today and started working on the 2nd method that includes build specific items. I've only started on QoT, but I will likely get her to mimic my standard QoT build for items.- removed some additional checks to help reduce overhead of the AI

* note - I have not begun to force shopping trips on the AI outside of fs1/cur1/priest/angel/cats/giants. I'll be looking to start phasing in shopping trips to encourage the ai to get even better items as appropriate. AI will still shop if it gets its arse kicked, but I want to schedule some trips so the AI will get stronger at different intervals even if its doing fine.

version 0.26.46 (the getting back on track version)- added miriyaka's changes to the save function so that we can evaluate based on warscore as well- added saving for fs1 as a priority after ws 200- updated value for fs1 to increase its priority to 200 after ws 300- removed log writes from miri's savefor, etc to see if that helps the lag issue that's been mentioned- confirmed - the generals will now choose monks if they are a normal ai with default settings (instead of saving for fs1)

version 0.26.45 (the lesser of two evils/back to basics version)- the title gives you an idea - if you play on normal settings with 1 general ai, they will NOT purchase monks at the start. This is not desired behavior. But in allowing this, the AI does not freeze between ws2 and 3 for any extended duration. Sadly, the other option right now is you get monks, but the ai stands around like an idiot at ws2. - Added additional documentation for the herogoap file- disabled the trip to the shop for ws 5 to get cur2- developed basic test code to send the ai to the base if its not the high gold ai- backed out the changes that increased rate of fire for bite/pounce/pent. We'll visit this again, but I'm concerned that the ai is overriding their flee function due to the high priority I put on these abilities resulting in more pointless deaths. My goal is to simply make them use their abilities more often... not die like goofs.- tweaked the rules for purchasing sigils. AI will not buy them until ws 2 and only if the AI has a max health > 2750- removed assassin sedna build again until I get back to sorting pounce

version 0.26.44- hopefully corrected a bug that would cause the ai wait around to purchase an upgrade if it did not have enough money of the ws for it. This should give us new opportunies for balancing upgraded in the future. The short version is I updated HeroGoap perform a check if the ai can afford the upgrade they are saving for before heading off to the shop. Not enough money = no shop. I'll be looking into explicitly sending specific ai's to shop on some sort of interval in the future- (not a real change... but started deep dive into integrating miri's savefor function)- removed cur2 shopping trip for now - it still gets a high priority, though

version 0.26.42- substantially increased the rate that erebus uses bite- substantially increased the rate that sedna uses pounce- re-enabled assassin sedna build now that pounce is used more often- substantially increased the rate of oak's penitence- added another shop period at ws 4 - the ai with the most goal should head for base a 4. This might result in a different dg being choosen for highgold after

version 0.26.41- added miriyaka's summon shambler fix. The code would work for QoT, Sedna, and Oculus. I'm only implementing it for QoT as this would be a disadvantage for the Oculus build and sedna does not use yetis in the AI mod- Removed anklet of speed from all TB builds and replaced with Blood of the Fallen. The ai is not smart enough to use a speed fire tb build- Removed the file mod_units. This contains fixes already in uberfix and is not needed here- Enabled master goal chat - this is a debug function that broadcasts what the AI's goals are - you might find this annoying...- Re-enabled code that adds a destroy structure goal for the AI. Peppe turned this off at some point... probably for a good reason, but I did see the AI being more aggressive attacking towers, so I'm leaving this on for now.- Made some adjustments to the flag weights on cataract. This SHOULD end dgs running over the the mana flag at the start and then rushing to HP before they capture the mana flag. Reduced the weight of the gold flag to encourage the ai to attack structures first. Reduced the value of portals prior to ws8.- Removed all oak builds and added a new shield/pent focused build- Minor change for reg's build - added impedance bolt at level 16 instead of stats 1

version 0.26.40- removed the code that placed a limitation on what items could be purchased at the start of the game (AIShopUtilities 736-741)- Changed the priority level trigger from WarScore to WarRank for fs1 (AIGlobals 1433) - this appears to have resolved the ai's standing at mid issue. The Ai will purchase fs1 at ws2 now correctly- Changed AI's priority to get xp2-xp4 to 0. AI will no longer purchase these upgrades- removed mist and added coven 1 as erb's level 2 skill until we get a chance to write a routine for him to use mist to remove negative buffs- Updated ai priority values for minotaurs to 0/5/10/15 (eg an ai will never buy the 1st level minotaurs now) - I was seeing the ai pick this up as a cheap filler if they have the money - not worth it- Updated ai priority values for level 1 archers - dropped from 15 to 0 so the ai will never buy- updated ai priority values for hauberk of life - dropped from 40 to 35 so that unbreakable would be chosen over this if money was available - updated ai priority values for unbreakable - removed conditional formula and set to a static 39 - removed ub skill build spit_ooze_mana (essentially bots ub)- removed hybrid_fire_ice build from tb (bots tb)

version 0.26.39pacov is learning things… - reprioritized AI to purchase fs1 at ws2. Previously, it only purchased it if made it back to base with enough money; this forces it back to base to get it if no one else has- raised priority for currency 2. Logic mirrors currency 1 as I want this purchased every time. Also sending ai with the most gold to purchase at ws 5.- removed assassin sedna build until I have a chance to look at the pounce training – assassin sed should be pouncing left and right… right now its like once in a blue moon – heal_tank sedna is solid though

version 0.26.38removed unitstatussensors code – concerned it might be causing an issue- tweaked erebus build so that he gets mass charm later – he’s not using it well as is

version 0.26.37bugfix – just resolving a sytax issue

version 0.26.36copy of peppe’s version 0.26.35- removed 3 old sedna ability builds- added 2 new sedna ability builds- removed old qot ability builds- added new qot ability build- removed 2 old erebus ability builds - added 2 new erebus ability builds- uncommented some code peppe developed in UnitStatusSensors that might help resolve the frozen dgs*note – all builds that have been added by me will be announced in team chat at the start of the game and will say “pacov” folowed by the build name.

OK. I'll look into this. Thanks. On the other side of things, though, at least whatever code he wrote does work... hopefully its something that can be refined. I'm not exactly sure how to write it so that it would be restricted to checking each shopping trip, though. When you say once per available upgrade - what does that mean in practice?

Each time an AI considers making a shopping trip, it runs every priority function assigned to every citadel upgrade and every item. Most of them are simple enough that it's not a big problem, but I wouldn't be surprised if the current incarnation of the ShouldSave function (which runs for every single cost check of every item/upgrade) is causing minor hitches.

It would require a massive re-write of the entire shopping code across 3 files. I've already spent a few hours working on it, and gave up due to how big the problem is, and again, how much better the whole shopping system would be if it was written from the ground up with game-event based priorities in mind. I wouldn't waste your time trying to re-write anything major, just work with the system that's there.

If you want to try to re-write something, re-do the logic of the ShouldSave function so that it's simpler, and doesn't force the AI to hold onto 10k+ for most of the game. Use the simplest conditions first to skip the majority of the work when not necessary, like first checking own and enemy WR, and not saving anything if currency is already purchased, and neither WR is above 5 or 6.

Have done several games with new ai mod now. Did yesterday 5 games 3v3 and another 2 games 2v2 all on cataract. You feel an improvement already which means the ai is harder to beat.

3v3: Here I play with 2 hard ai against 3 hard ai. This now feels like playing online against mid players. The enemy ai usually plays pretty good, they gank a lot to get kills, they buy the upgrades when they are done and go for the flags. The ai on your team also do a pretty decent job. Sometimes they do stand around but I didnt notice it too often. The items they buy are ok. There is one thing I noticed which pacov already mentioned that they stay out in the battle even with low mana and lots of money. Cant fight a lot but it seems that it only looks at hp to make it retreat, hence the hp has to go below 50% in order for them to go to the crystal or certain WRs happen. I saw a Sedna getting 2 helms and an erb getting 1. The erb is not casting Mass Charm at all though, seen it do 2 or 3 times. Opponent ai does it more often but I guess its because I put down his hp, he goes back to crystal and comes back to battle with me with enough mana.

Overall it was before already not too bad but with new mod its even better practice for online play. If you manage to get in this setup more klls than death you should be good to play online against others with the DG you played.

2v2: Here I play with 1 nightmare ai against 2 nightmare ai. If you play all hard it is too easy. With old and new mod problem is that you fall behind in items and level but its like playing against better players online. From my view enemy plays pretty decent here. Sometimes they do stupid things like not chasing you although you are below 200 hp because the tower made them go below 50% hp but overall they cap flags good, and gank for kills.

Something that makes me go nuts though is your partner ai. That was with old and new mod the same but now it seems even worse. I play Oak with TB but the same more or less happened in the game before with rook. Right from the start I go to cap exp flag. TB decides to go past our portal on mana side heading for mana flag. So I go for hp. TB goes all the way to our portal, up to our tower then across the whole alley over to the hp flag without engaging any creeps or capping any flag to come to the lane I am in. It does that very often. Coming to the lane I am in. UNLESS I am approached by an enemy DG or better two enemy DGs. As soon as I am in a battle mate ai will NOT come over to me. It decides to creep preferably in the center. It still does that when enemy caps our portal and when I go to fight them both at our portal. It stands either in center or in the opposite lane, creeps and eventually attacks the tower. After both are gone it ports over to try to cap the flags back. I constantly try to run away from my teammate until both enemy DG attack me, then I run from them. If you hold long enough and the enemy ai hit level 20 it gets easier again as you can close the skill gap from then on and they endgame with capping and locking portals isnt too great so usually I still win the game but every game feels like you play really good opponents with a stupid partner and you have to save the world for him.

The ai will always do some stupid things (casting shamblers when it already has) as it is too complex to code all the situations that could arise. Skill, exp and money advantage makes up for that. Without mod there is no use to play the ai, with mod it was already good, with this mod its even better. The worst problem I see is the behaviour of your partner ai. I guess it behaves better when it has another ai on same team so its really only the 2v2 part. Cannot say anything to behaviour on normal though as that is just too boring.

The erb is not casting Mass Charm at all though, seen it do 2 or 3 times

hmm.... that's curious. I think I have erb picking up charm 1 and 2 at level 6. It should be casting it then, but not before (obviously). You are saying he's not using it at all after 6? You're just saying its a mana management issue thought, right? Or perhaps something else? Once I get onto tweaking erb's item selection and rate of shopping, that should mitigate the mana issue some.

Enhancement request

- Change the ai so that they will pursue for a kill if certain criteria is met.

- Better decision making for flags - Ai heading over from mana side all the way to Hp without capturing mana. this is likely due to flag weights... just not sure why it didn't evaluate hp as the priority initially - could be some conflicting code?

Played one game against an Erb and one with an Erb (always put the DG on random). The Erb I played against used Mass Charm quite often. Was annoying so good. But the game with Erb on my side I noticed it didnt cast it. I am sure that it wasnt no Mass Charm at all but most fights he joined with me he didnt cast it although we could have used it. When checking him he was always low on mana.

My guess is that in larger battles the ai probably hits the enemy with lowest hp first. That is usually me as the ai has more money and hence more equipment, plus the fact that ai retreats when below 50% makes them never attack the Erb. So the Erb is out for very long as it doesnt lose HP but over time it loses mana. Then he only has a vlemish so not a whole lot of mana either. I mean I am playing and not watching the Erb the whole time. So two things I can say for fact: 1. When in a fight with my Erb he didnt cast Mass Charm a lot and 2. everytime I check on him he was low on mana.

Digging more into the code... jebus... peppe was busy. I think I tracked down where peppe was forcing a shopping trip: HeroGOAP.

I see what he's doing with that high gold logic. I'll have to toy with the logic, but I think I can modify his existing logic to force the high gold unit as of ws 2 to make a shopping trip, etc. I could probably just keep using the high gold variable and force priorities so that the shopping trips get staggered by warscore or some other variable. Even if I just simplify in the meantime, it should work to override the current "I only shop if I'm forced to the citadel at ws 3 or 8 or just had my arse kicked" logic. And it should alternate to a reasonable degree.

I'm going to do some quick dummy testing to see if I can force a trip at ws 2. If so, then I'll see what I can dev.

also noticed an item value restriction during the first 30 seconds of the game... aishoputilities - 736-741

Code: c++

# [MOD] TE Buy more cheaper items at start

if GetGameTimeSeconds() < 30 and gold < 5000 and itemData.ItemTable.ItemCost >= 1750 then

note that destroy structures priority it commented out... also notice how the ai rarely, if ever, attacks structures...

Ok - played about 5 test short test games where I'm forcing the ai with the most gold back to the citadel to get fs1 at ws2. Going to probably test this a bit more to make sure I'm not missing anything.

I agree to some degree about returning on mana empty, but also keep in mind its crap mana management. I agree that it would help with having additional mana and shopping some, but it also would likely result in the ai buggering off really early after it wastes mana.

Here's what I currently have sorted for the next ver. I'll at least give this a few tests. If it continues to look good, I'll either keep working a bit longer or just release for testing. If you do test the next release, please pay close attention to the changelog and let me know if things aren't working as I describe.

version 0.26.39- reprioritized AI to purchase fs1 at ws2. Previously, it only purchased it if made it back to base with enough money; this forces it back to base to get it if no one else has- raised priority for currency 2. Logic mirrors currency 1 as I want this purchased every time. Also sending ai with the most gold to purchase at ws 5.

OK - I just played a game. I very much liked how things worked with even those minor changes. The ai shopped like clockwork at ws 3, 5, 8, and 10. It did get fs1 at ws1, though... which makes no sense to me, as I have it as priority 0 until ws 2 hits. So there is either some bit of code I'm missing (some other constraint in some other file...) or gpg has a very strange math going on in places. My trigger for both the increase in priority and the return to base is ws2. From the debug log it, it definitely queued up before ws2 and there is nothing wrong with my code... oh well. The behavior is fine imo.

I'm going to remove the assassin sedna build as sed is still crap with spamming pounce like she should as assassin sed. Once that's done, I'll upload a new version... soo... maybe 10-15 min.

ah - i think i just figured out the ws1 deal and getting cur1. War rank starts at war score 1 every game, right? Right. As soon as 1 second has passed, its > ws1. Its ws 1.01 or w/e. That's why I was getting strange purchase times.

or maybe not... meh. I changed it ws 2 and its still getting bought immediately. I'm just going to leave it as its not a huge impact, even on normal ai imo.

final changelog - compiling now - upload in a few min

changelog

version 0.26.39- reprioritized AI to purchase fs1 at ws2. Previously, it only purchased it if made it back to base with enough money; this forces it back to base to get it if no one else has- raised priority for currency 2. Logic mirrors currency 1 as I want this purchased every time. Also sending ai with the most gold to purchase at ws 5.- removed assassin sedna build until I have a chance to look at the pounce training - assassin sed should be pouncing left and right... right now its like once in a blue moon - heal_tank sedna is solid though

MIRI! Do me a quick favor and look at mod_units in the enhanced ai package. That occulus stuff can be removed, right? Its covered in uber. Just checking. I'll drop it from the next version if you confirm. Does the same go for the rook stuff?

0.26.39 is live. Testers, please pay close attention to the changelog and let me know if you see any annolmalies. I'd also like one of you to give it a go against normal ai's (with a normal ai or 2 on your team) and let me know how it goes.

Peppe put in a ton of overrides because actually making the AI behave properly w/r/t shopping would require a full re-write of the shopping system, like I said. Some of the things he did could have been centralized a bit more, but again, doing things 'properly' often takes a lot more time, and he already didn't have enough time to fully refine it. Notice that none of the code in the mod is hooked at all.

Yes, the Oculus and Rook blueprint merges are covered in the UberFix. It won't hurt anything to leave them in, as they're identical to the UberFix changes.

Took another look at ShouldSave; contemplated suicide. Yikes. At the very least, that should be refined and simplified. I'll check out where it's used one more time, to make sure there isn't a simpler way to handle it outside of the actual item/upgrade loops.

Miri - if you have the time and inclination, would you mind taking a look at the QoT summoning shamblers problem and see if you can come up with some code? At its most basic level, I just don't want her trying to summon more shamblers if she is already at the max for her level (eg shamblers 1 and 2 = max 2, shamblers 3 and 4 = max 4). I'm going to stay focused on re prioritization for a bit and probably won't get around to trying to sort this for a bit.

and I'd really appreciate this if you get a chance. It will take me some time to wrap my head about it. Thanks if you do check it out and thx if you don't. I'll get back to it at some point, I'm sure.

That's somewhat complicated. There's a lot of disassociation between the HeroAIActionTemplate that provides the blueprint for the ability use, and a weight calculation function, and the actual checking/execution of the ability itself.

I guess it wouldn't be difficult to create a SummonStatusFunction in /lua/sim/AI/AIAbilityUtilities.lua that can check the ability level and max summons, and point each hero's summon actions' InstantStatusFunction at that, instead of DefaultStatusFunction.

Something like:

Code: c++

--InstantStatusFunction for minion-summoning AI actions

function SummonStatusFunction(unit, action)

if DefaultStatusFunction(unit, action) and action.Ability then

--Determine max summons and get the category for the summon unit

local abilityBP = Ability[action.Ability]

local maxSummons, summonCat = false, false

if abilityBP.MaxYeti then

maxSummons = abilityBP.MaxYeti

summonCat = categories.YETI

LOG("SummonStatusFunction: Yeti: "..maxSummons)

elseif abilityBP.MaxShamblers then

maxSummons = abilityBP.MaxShamblers

summonCat = categories.ENT

LOG("SummonStatusFunction: Shamblers: "..maxSummons)

elseif abilityBP.MaxBalls then

maxSummons = abilityBP.MaxBalls

summonCat = categories.BALLLIGHTNING

LOG("SummonStatusFunction: Ball Lightning: "..maxSummons)

end

--Return trueif we have fewer than max summons

if maxSummons and summonCat then

if table.getn(unit:GetAIBrain():GetListOfUnits(summonCat, false)) < maxSummons then

returntrue

else

LOG("SummonStatusFunction: Already at max")

end

else

LOG("SummonStatusFunction: Error: Could not find max summons for ability '"..action.Ability.."'")

end

end

LOG("SummonStatusFunction: Fail")

returnfalse

end

Then point QoT's 'Shambler' AIAction's InstantStatusFunction (/lua/units/heroes/HQueen/HQueen_AIActions.lua) at that, instead of DefaultStatusFunction:

Ok, I spent about an hour on a yet-untested system for re-working upgrade save priorities that is far, far simpler, and easier to extend. It's linear, and doesn't take into account the ability to purchase an upgrade further down the map/queue when one at the top is yet unpurchased, but this works fine when just taking into account a low level upgrade like Currency I, and a bunch of sequential upgrades like the creep adds. This behavior is modifiable, but I figured it's best to keep it simple unless someone determines that the AI needs to save for yet another upgrade (don't do this, because saving for these five hamper its purchasing enough already).

It is capable of having multiple AIs each save for a different upgrade simultaneously, provided that each upgrade's conditions are met, but contrary to the existing method, it has the AI with the most gold save just enough for the next upgrade, and AIs with less gold will save for further upgrades. This is slightly more shortsighted, but will not force the AIs to save tons and tons of gold, and this relationship is re-evaluated each time the shopping sensor triggers anyway, meaning that the AI gold ranks will switch around a lot as they make purchases (both saved-for upgrades and items), but there will always be enough gold reserved for the upgrades currently being saved for (up to the number of AIs on the team).

Mist is is not used to any advanvce. When Erebus hit Lvl 2 and gets Mist, he uses it when engaged and run out of mana.

I would suggest to skip that skill or add a routine that forces the AI to use it when a negative buff are applied for just a second.

The AI saves the points from lvl 3 an 4 to spend it on bat swarm and charm I / II when reaching Lvl 5. That is as intended, isn´t it?

In games with more players I can not tell yet, if the shopping at WR 2 worked properly. It seemed to me, it was not, but I might be mistaken and have to look for that again next time.

The AI often don`t react when their gold flag (near the portal flag that can be captured without shoot by towers) is being captured. It more often reacts when the towers are attacked too, but still not enough it seems. In games with the AI quite often an AI just walks though the tower fire and capture the portal flag. And much too often it get away with that behavior.

Still, the Ai often has a lot of gold in their pocket. I never saw a sigil in any inventory. Once a lock, but that was not used.

Getting Currency 2 at WR 2 worked fine. But I was told it is not worth the gold? Well, maybe this only fits for human players.

To be mentioned is my last game against a single LE while I was playing Rook (tested HW ^^). Around Warscore 800 I killed him behind his first tower on health side. When he respawned again, he went straight to the point where the was killed and stayed there until Warscore 1200. Then he went back to the shop and bought a scroll of teleportation, saving 1800 gold. Then, again, he stood at the shop (with opened shop window in the replay) until 2050 gold, where he bought another scroll of teleportaion. This went on two more times, where he bought to small healing pots. Then he hit Warrank 3 and bought currency 1 and started to act again.

So, it seems the the shopping routine works, but it collides with order to save for currency 1 at warrank 3?

I guess it would be better to let the AI shop by gold amount in pockets after currency was bought. For example, gold hits the 2500 --> Ai wents shopping (since the most useful items cost from 1500 to 1750). When specific items (Nimoth, Plenor, Vlemish for example)are bought it save again for creeps. After catapults are out it could buy the more expensive things or save for giants.

Played 3 games with the new mod. All of them 3v3 on cataract with 5 hard ai. On my team always a Sedna and an Erb all others on random. Fs1 gets bought early, Curr1 and 2 always when ready which is better for me as I used to get curr2 which makes it a bit more realistic though as now I get away with no cit upgrades at all. So this part seems to work.

In all three games I saw 1 (in words one) mass charm from my partner Erb. Maybe he casted them when not in a battle with me but there were a lot of fights together and one in three games. I also did not see Sedna pounce a whole lot. Its harder to see when in a battle than a mass charm but still I would say max 3 pounces in 3 games. On a positive note we owned the opponents in all three games were way ahead in war score in 2 of them and with 5 kills I generated more gold then the three opponent ai which is not normal on hard (its not really the kills is the getting curr2 earlier than them cause of warrank and holding more gold mines than the enemy). So staying alive and flag control is very good with these two DG.

In the third game I noticed a very strange behaviour of my Erb. Right at the start it gets monks. Waits at the shop. At 600 gold it gets FS1. Then it stands at the citadel for about a minute until it has 710 gold. Goes to the shop to buy a banded armor. Then heads for hp flag past the portal, dances back and forth at around the portal to then go for the hp flag. I think it took two minutes before the Erb went past our front line towers.

Just watching the replay of the Erb in that last game. Too much to write. He does strange things. But he is casting mass charm a lot. He needs a different item list to get 2 helms and he is always out of mana because he is in Mist all the time. Doesnt wait at the crystal to get full health and mana, goes back towards crystal, receives a heal from Sedna and then turns around again as he has full health now but still no mana, goes back to enemy center towers and goes into mist for 2 seconds to then move back. I will save this replay in case you want to have it.

Watched the enemy to see if it gets curr2 at warrank 5 or not. It doesnt. Most of the DGs pass by with enough gold but buy equipment. At around WR6 they get curr2, could it be that the calc here is wrong and it waits until 6 to get it? Also noticed that the TB build is crap. Its a hybrid build which I wouldnt play like that.

Thanks for the feedback, folks. I'll see if I can mine some buglists out of them and get it added to the op. As I can't get miri's new change up working atm, I'm going to toy around with the code he made re: minions and see how that works, then back to some reprioritization.

or if any of you folks have the time - take some of your feedback posts and just create a few bulletpoints for me indicating the bug or enhancement requests. That would help me and save some time if you are able. Thanks!

- increased priority when portal flags or towers are threatened (I don´t know about the priorities at all but it seems to me it´s ignored too often)

- AI should have buying priority after currency 1 is bought. It seems it can´t handle shopping and saving for currency at WR 2

- Rethink about Currency 2 and citadel upgrades at all? (Exp upgrade is not so useful, i think) FS 1, CUR 1 and catapults at WS 8, then firepower and armory etc. when gear is bought and moneys left. So first shop then citadel?(human palyers can get the other things when needed as well)

As i wrote, plz ignore things that seem to be wrong to you. Have no problem with that.

I figured out the basic problem with qot summon code - I did a test where I altered the sedna build so she'd get yeti 1 as her first abilitiy. With your code on, I didn't get an error and she summoned a yetti - I didn't wait long enough to see if the limiting code worked... but I can confirm it didn't throw an error like QoT did. That said, I'm pretty sure that narrows down the issue as related directly to QoT. She starts the game in open form. And she gets shamblers as her 1st ability. The error is getting thrown OVER and OVER in open form... and for some reason, qot never changes to closed form (at least when I was watching) when using the code. So, I don't know... perhaps we need some sort of check re: open/close form?

mostly just played some games from 10-12:30AM in MP. Didn't get to work on this anymore tonight. Hopefully we get some sort of break through and I have something to release tomorrow. The more I look at things, the more room I see for improvement (and side note - anytime you see comments like this from me - I think the ai is about 50x better than it was in vanilla - I'm just shooting to make it better and better).

oh, and I had to modify... Then point QoT's 'Shambler' AIAction's InstantStatusFunction (/lua/units/heroes/HQueen/HQueen_AIActions.lua) at that, instead of DefaultStatusFunction:

...

That's the only way it gets called properly and outputs to the log, but I'm getting the error you mentioned. I wonder if its getting a null value right off the bat as none exist.

That's because it's a standalone line. I wasn't meaning for you to override the entire action template, just to throw that line at the end of the file, which sets the InstantStatusFunction without touching the rest of the blueprint.

I'm not sure why it wouldn't work just for QoT. When you tested with Sedna, did you make sure to alter her InstantStatusFunction, and was it outputting at least some messages to the log? Is it listing the correct ability names, e.g. HQueenShambler0*? Try adding this to the line after 'local abilityBP' to see if it's getting the blueprint properly:

Code: c++

ifnot abilityBP then

LOG("SummonStatusFunction: Could not get ability BP for ability "..repr(action.Ability))