HOI4 - Together For Victory AI Update #2

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

SteelVolt

Technomancer
2 Badges
Aug 4, 2014
735
4.201
  • Paradox Order
  • Hearts of Iron IV Sign-up
Hello again!

It is already time for another AI mini diary, going into some more detail about points in the changelog for the upcoming Together for Victory update!

(To read part one, scroll to the end of the last DD, which can be found here.)

Todays story from the trenches relates to one of the seemingly basic AI features that is a hell of a lot harder than it seems; balancing the divisions between the orders. A human can do this without much thinking, given our superior pattern recognition capabilities. The AI is not as lucky, and has to do some educated guesses based on what numbers are available in a given situation. The code for doing this has grown in phases since about two years back, in some sences almost uncontrolably so due to chasing a good enough state for deadlines. After a while, what easily happens with such systems is that parts of the code "fix" problems that are no longer problems. Indeed, more than just making the code unnecessarily complicated, it can cause new bugs.
This is exactly what happened with this system. It can roughly be divided into three steps, and after some failed attempts at fixing some bugs related to it, I ended up ripping out and rewriting the entire step two, reducing the size of it by about 30%. This also meant that I could remove about 20% of step three. The result has been that the system is easier to read, debug and maintain, even though it lead to some new bugs related to the rewriting. I still see cases where the behaviour is not 100%, but the overall performance of it appears a significant improvement, and the AIs ability to recover from strange situations is a lot better.

- Fixed bug where AI would keep swapping a fighter with land equipment at the top of the list for all eternity.
  • If you ever observed the AI (sorry about observer mode still not being a guarantee), you may have noticed at least some countries getting stuck swapping the two top lines if they were a fighter and some land equipment. A fairly basic code booboo that has now been resolved, resulting in a positive impact to AI production.

- AI should now be capable of using rockets.
  • Exactly what it says. The problem here was that rocket bases, though internally represented as air bases, are kept in a separate list from the regular air bases. Just including that list when considering missions should mean AI can now use their sometimes ample supply of rockets.

- Fixed overflow that cause some countries to not build planes causing USA to end up with 0 strategic bombers.
  • Yet another basic one. When implementing features it is easy to just look that the standard cases, and thus miss the late game edge cases. In this case the USA wanted strategic bombers so much that the number overflowed and became a ridiculous negative number in stead.

- Made sure released AI countries don't get stuck building nothing.
  • Again, pretty basic. A flag was not set, and the AI was never run for released countries. But who releases a country without playing as it, anyway? ;P

That covers some more of the fixes that has been made for the AI. As before; I have more to tell you about so hold off on worrying about your favourite AI bugs ;)
Next time I will be talking about some of the improvements, though when it comes to AI the line between what is a bugfix and what is an improvement is very blurry.
 
Last edited:
  • 70
  • 31
  • 1
Reactions:
I really enjoyed this AI mini diary, more than those about "cosmetic" features like new focus trees for nations I will probably never play as.
When will be the next AI mini diary published?
 
  • 5
  • 2
Reactions:
That's why my puppet state Israel didn't make any divisions in my German WC run? Ohh...
 
I really enjoyed this AI mini diary, more than those about "cosmetic" features like new focus trees for nations I will probably never play as.
When will be the next AI mini diary published?

That depends on how many more we settle on, but it looks like you may be getting one as early as monday, but absolutely no later than wednesday :)
 
  • 13
Reactions:
This reads like a response to my efforts to optimise division building. These are exactly the things I've noticed in the last two days watching the AI play the game and have been trying to fix. I'm glad to hear they're fixed.

@podcat, just a small something I noticed. In the generic templates file, stuff like anti_tank and anti_air are wrongly labeled it looks like. Specifically support names seem to be used for the brigade (let's say the mainline unit) and mainline names seem to be used for the support ones. I realised the AI was not using anything in their mainline or support other than artillery. So I cross checked their name with their definitions under "units" folder and realised they were the opposite. Then I changed the templates.

Not sure if it's a bug, but now the AI is fielding anti-air and anti-tank in their divisions now, so apparently the changes I've made were effective.
 
  • 8
  • 2
  • 1
Reactions:
Cheers for the DD Steelvolt, and all your work wrestling the AI into submission :). I look forward to the AI rocketing me into submission after next Friday :D. Particularly great work on the rewrite - always a bit painful to commit to, but almost always worth it once it's done. Looking forward to the next AI DD :).
 
@SteelVolt

Without going into details, do you believe the AI be more challenging overall with Torch in cases where there weren't really any noticeable "bugs" originally?

Not asking for like a sworn statement, just your opinion :p
 
This reads like a response to my efforts to optimise division building. These are exactly the things I've noticed in the last two days watching the AI play the game and have been trying to fix. I'm glad to hear they're fixed.

@podcat, just a small something I noticed. In the generic templates file, stuff like anti_tank and anti_air are wrongly labeled it looks like. Specifically support names seem to be used for the brigade (let's say the mainline unit) and mainline names seem to be used for the support ones. I realised the AI was not using anything in their mainline or support other than artillery. So I cross checked their name with their definitions under "units" folder and realised they were the opposite. Then I changed the templates.

Not sure if it's a bug, but now the AI is fielding anti-air and anti-tank in their divisions now, so apparently the changes I've made were effective.

Very observant. That was indeed a bug. Unfortunately there is no really good way of error checking that script for bad tokens, so mistakes like that can happen.
 
  • 15
Reactions:
@SteelVolt

Without going into details, do you believe the AI be more challenging overall with Torch in cases where there weren't really any noticeable "bugs" originally?

Not asking for like a sworn statement, just your opinion :p

I would absolutely say yes. I am not claiming to have accomplished miracles, but certainly noticable improvements in several areas. The next one or two diaries will go into the improvements we have worked on for areas where the AI performed badly :)
 
  • 13
  • 3
Reactions:
Thanks a lot for these AI diaries... the normal DD are nice but to be honest, I think most players really wanted to see this for a long time. So again thanks and I look forward to the next one :)
 
  • 9
  • 1
Reactions:
Currently the a.i. is a mess and parts of it are easily fixed by mods.
I'm not too confident that the a.i. issues will be adequately solved by PDS because they ignored the solutions provided by modders thus far.
There are 3 major a.i. issues I can think of right now:
1. A.i. produces way more units than it can supply --> supposedly going to be fixed in the next patch. The solution though was discussed in the forum long ago: Just make the a.i. stop producing units when certain thresholds are reached. Those restrictions come from total number of factories and equipment stockpiles. For instance: a minor nation with 40 factories should be restricted to fielding x divisions and halt production when the limit is reached and so forth.
2. The templates are way too small. Minor nations tend to use divisions with ~5,000 men or even less. If you let the a.i. use historical sizes of ~15,000 men per division you will automatically end up with 2/3 less units on the map. The most efficient templates are of such sizes anyways, so the a.i. would benefit from it.
3. The mods "No Man's Land" and "August Storm" made sure that the Sahara is impassable terrain. AS was less restrictive and more elegant. Both mods are popular solutions to the a.i. sending gazillion troops into Africa and both made Northern Africa an enjoyable battle ground. Still in patch 1.2 the African problem is not solved! Btw. AS doesn't suffer from the "Allies stomping Germany in Europe due to less troops in Africa"-issue that has been mentioned in the last DD.

Sometimes the best solution to a problem isn't the most complicated solution, but the most straight forward. I think the devs should examine the popular mods more closely and integrate working solutions quicker.

PS: I'm sorry if that sounds too negative. I'm sure that the a.i. guys are doing a good job and aren't responsible alone for the existing problems. I just sometimes wonder why we have to rely on the modding community for fixes and you guys don't incorporate them quicker.
 
  • 25
  • 6
  • 4
Reactions: