• 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.

Terminatrix

Captain
2 Badges
May 30, 2004
336
395
  • Hearts of Iron III
  • 500k Club
Hello all,

This is your friendly spokesperson for the AI for HOI 2. I am just now introducing this thread as a series of threads that will go on and on until the AI in HOI 2 is about as good as we can get it. This is also a thread for other modders out there that understand and want to learn the workings of the AI in HOI 2. Hopefully these series of threads will enlighten a lot people and will be a sort of instruction guide for anybody in the future that wants to mod the AI.

I have been modding HOI ever since last summer and HOI 2 ever since the HOI 2 demo came out back in december. It is safe to say that when I finally got my copy of HOI 2 I started modding right away. I mostly do it all, except for sprite making and pretty much anything with graphics, I have almost no graphical ability, but a lot of technical ability. With that said I will now kick off this AI discussion by stating a few general facts that I have discovered about the AI in HOI 2.

First off I would like to make it clear here and now that the AI in HOI and HOI 2 is not really Artificial Intelligence, all it is really is a set of instructions that the programmer tells it and then the program carries it out. What I mean is that the AI in HOI is not like game AI's, it cannot adapt itself, it cannot switch to a different AI file by itself, it cannot learn from it's mistakes and try new things, like some other AI files out there for other real time strategy games. Just keep in mind that when programming the AI for HOI it will only do what you tell it to do, if you want it do something different at any point in the game you will have to program it. Ok enough of that, now for some basic realities that I have discovered about HOI 2 AI file workings.

#1 - As many people have found and can atest to the game does need to be rebooted from time to time. Some people have said that a player needs to reboot 1 time every year, others have said every couple of years, and so on. I personally think, that a player needs to reboot the game every month. If you have autosave turned on and set it to save every month, then a good practice is to reboot the game after the monthly autosave.

You must reboot because I have seen the AI do or should I say no do some basic things and pretty much act stupid. I have seen the AI forget to supply it's divisions only 2 provinces away from it's capital! I've also seen it not conduct invasions like it was told to and not attack like it was told to, and a lot of other wacky things. So the point is reboot the game often! Ok, enough of that now.

#2 - You have to be careful alot of the time you program. Sometimes you think you tell the AI to do something and then you run the game and it doesn't do it. Don't get frustrated though, because sometimes the AI really is in actual reality stupid! I've seen the AI just not do something, and I can't explain why! Just know that the people who made the HOI 2 AI workings haven't got everything figured out yet either otherwise why would they keep coming out with patches.

#3 - With #2 clearly stated, know that the AI is not fully complete by any means. Again the patches are a good example. A great example is when, I think it was either patch 1.05 or 1.06 when a the people at paradox came out with a new command for the AI files. It was a command that affected how effective the invasions were by the AI. It was a great command and was well needed, it worked really well and made a difference.

#4 - The last thing I can think of right now, is that I just want to make it clear that I don't know everything about the AI. That is why I am starting these threads so we can all put our minds together and figure it out, because we won't get any answers from Paradox. "NDA" is one of the worst abrevations in history!!!

Ok I will now start the first of these threads and start some good threads here. I will make these threads from top to bottom of the AI file based on the default AI's with the Vanilla HOI 2. By default I mean all of the 1936 AI files. Thanks ahead for all those who contribute!
 
What do you want to know about the AI. I can pretty much answer any question you have about the AI. Much of the design work (as in concept and scripts) was done by Tamerlan and I and we both have had our massive share in dealings with it. So if you have questions as to why something is happening etc.. perhaps I can just answer it rather than you guess what is going on.
 
Lothos,

I want know,

1) what in the save game file

under Construction = {

transports = -1
escorts = -1

means?

2) And what under technology = {
endgoal = { xxxx }

does? Does reasearch after this tech stop?

3) Under Front = {

province_priorities = {
357 = 2.5
}

does not have such a big impact. Far more important seems to be

distrib_vs_ai = even/defensive/...
distrib_vs_human = even/defensive/...

How do I make the AI place more troops in a specific front province (no garrision), lets say in Madrid?
 
Last edited:
transports = -1
escorts = -1


Never looked into those two but I will get info for you. Have not yet needed to use them.

endgoal = { xxxx }

I believe as in HOI 1 this has not been implemented yet so no point in trying to use it.

province_priorities = {
357 = 2.5
}


In the front section this allows you to manipulate the multiples for a specific hex when it is touched another hex. Although it works a little flacky and I actually question sometimes weather it works correctly. It was designed so you could literally control hex by hex where the AI would launch his attacks or ares on a front you do not want him to place allot of troops on. For example the Maginot line.

distrib_vs_ai = even/defensive/...

What exactly do you want me to explain about these? You want to know what the front distribution types do etc...? List out the ones you want me to explain.
 
Excellent Lothos, your knowledge will be invaluable in contributing to everybody's knowledge. I know people just had to ask you before, but not alot of people out there probably knew that you were such an AI expert, but with these threads now, people know and can ask you millions of questions. Thanks!
 
Lothos said:
What exactly do you want me to explain about these? You want to know what the front distribution types do etc...? List out the ones you want me to explain.
Thanks for the info. I know, what they do. I was just disappointed, that I could not force the AI to place more troops in front province A and less in B, not to the extent, I wanted to. Province_priorities really is not that great in doing that.

Will passivity = 100 work in 1.2? In 1.1 it did NOT turn attacks 100% off.
 
Will passivity = 100 work in 1.2? In 1.1 it did NOT turn attacks 100% off.

In HoI 1 passitivity worked on both air power and ground power. In HOI 2 it only works on ground power. 100 passitivity should turn all ground attacks off but air power will continue to do it's work.

Are you sure you know everything about the front types cause some of them do not have good explanations in the AI doc file. At some point I really need to do a complete write up on the AI file parms etc....

target = xxx

For example the above command that says it makes the AI want to go after the specified hexes does nothing. It was never implemented. I did put some hexes in the AIs on the off chance that it would get implemented but at this time it does not work.

Hmm there are tons of more stuff so just list out the items you want clarifications on and I would be happy to explain.
 
Lothos said:
In HoI 1 passitivity worked on both air power and ground power. In HOI 2 it only works on ground power. 100 passitivity should turn all ground attacks off but air power will continue to do it's work.
The problem is linked to movement. E.g. China, Japan has some beachheads in the South, now we use passivity = 100, they will still try to move troops through enemy provinces from North to South and vice versa and by that initiate some combat, so passivity = 100 does NOT stop that.
Lothos said:
Are you sure you know everything about the front types cause some of them do not have good explanations in the AI doc file. At some point I really need to do a complete write up on the AI file parms etc....

target = xxx

For example the above command that says it makes the AI want to go after the specified hexes does nothing. It was never implemented. I did put some hexes in the AIs on the off chance that it would get implemented but at this time it does not work.
I have made the experience, that is does work (the independent "target"). Example Ethiopia, England AI has

target = {
1058 = 100
1056 = 100

the AI tries to move into/attack 1058. The problem is, that the sequence is important. It will not move in 1056, before 1058, even if the province is empty.
Lothos said:
Hmm there are tons of more stuff so just list out the items you want clarifications on and I would be happy to explain.
If you want to explain, feel free to do that. The fact, that I know some few things, does not mean that all know.
 
Trust me target = {} does absolutely nothing. The code for it was never implemented. If the AI moved stuff in those hexes it was coincidence.

passitivity
This goes by the controllers hex. For example if you say in the passitivity section CHI = 100 if the chinese troops are in CGX territory Japan will still attack the Chinese troops as long as they are in CGX territory but as soon as they are in CHI territory again he will halt his attacks when set to 100.

passitivity = {
CHI = 100
CGX = 100
}

etc... in the Japanese AI file should get the results you want. Now remember if the AI is alreayd moving the troops and the AI file gets loaded with those parms the AI will finish all existing attacks and moves and then stop.

This concept applies accross the board as well. For example if USA troops where in Chinese territory and the passitivity was set as mentioned above in the Japanese AI file then the Japanese would no even attack the USA troops as long as they are in Chinese owned provinces.
 
Lothos said:
Trust me target = {} does absolutely nothing. The code for it was never implemented. If the AI moved stuff in those hexes it was coincidence.
might be.
Lothos said:
passitivity
I think I had passivity = 100 for CHI and CGX. You are sure, that there are not some movement issues, that make passivity = 100 fail? I had the impression, that the AI did not want to attack, it just wanted to move troops to certain provinces and by incident there were some CHI provinces and units on the movement path. I will have a close look in the next game.
 
Keep in mind Passitivity is ignored against humans. So if Japan is attacking a human Chinese player he will ignore his passitivity and handicap commands in the AI file.

as for target command it is not that it might not have been it really was not implemented. I can not say why etc.... cause of the NDA.
 
Panther II said:
The China example was AI against AI.

Do you know if MOV_NIGHT from "modifiers.xls" was disabled?

Sorry Panther I do not

Code:
# Even - Distribute forces evenly along the whole front.
# Reactive - Try to match enemy troop concentrations.
# Defensive - More troops in strategically important provinces (IC, Victory Points, Oil, etc)
# Offensive - Concentrate more troops where the enemy us weak
# Operational Defensive - The fewer avenues of escape, the less troops (to avoid encirclement.)

Above is what it is in the AI File DOC and below is a better description

Even - This front has had the most work done to it and is the most stable. You shoud use this when you want to do things defensively for the AI or covering a very large front.

Reactive - Also worked on allot and the AI will try and shift his forces around to match his opponents. Just be careful cause it is easier to fake the AI out by doing force concentrations so you can have the AI not defend other parts of his front well.

Defensive - Advise not using this. Although implemented it has not been tested as much as Even has and you will find Even will do a better job on defense.

Offensive - Very aggressive attack AI just becareful to only use it if the AI has a distinct advantage cause if not it makes the AI easy to encircle.

Operational Defensive - Has been tested allot and is a great replacement for Even. It makes the AI put less troops in areas that have less avenues of escape. It helps prevent large quantity of units from being encircled. (used for Russian AI when they are attacked by Germany)


Code:
	#Odds modifiying variables
	# the following is to reduce odds-strength for attacker.
	frozen_attack 	= 0.50
	snow_attack 	= 0.50
	blizzard_attack = 0.25
	storm_attack 	= 0.60
	muddy_attack 	= 0.75

	#reduces the size of odds in total.. (1.0 = no difference, 0.5 = halved.)
	jungle_attack 	= 0.85
	mountain_attack	= 0.60
	swamp_attack 	= 0.60
	forest_attack 	= 0.85
	hill_attack 	= 0.75
	urban_attack 	= 0.40
	river = 		x

All of this is obsolete in patch 1.1 as the AI derives the values straight from the modifiers. BUT if you do put something in there it will effect the calculation. It is best to make them 1.0 (why urban bug was present in 1.1)


I guess I could put a little bit of information every day.
 
max_garrison_prop = 0.30
min_garrison_prop = 0.20
neutrality = 90.000
war = 0
strat_redeploy_threshold = 25
exp_force_ratio = 0.04
exp_force_ratios = {
ITA = 1.0
}

What do each of these do and what are the "useful" ranges of the values?

EDIT. btw, thanks for this thread and thanks lothos for answering so much about the AI :)
 
If I want Germany to defend the coastal hexes from Denmark (atlantic side) to the netherlands (exclusive), so basically the 4 hexes or so that can be invaded between those two points. How would I do that? I want them to build coastal forts and man them with 3+ divisions each. I assume it is something to do with the garrison command, province priorities and area_multiplier maybe?
 
Graymane said:
max_garrison_prop = 0.30
min_garrison_prop = 0.20
neutrality = 90.000
war = 0
strat_redeploy_threshold = 25
exp_force_ratio = 0.04
exp_force_ratios = {
ITA = 1.0
}

What do each of these do and what are the "useful" ranges of the values?

EDIT. btw, thanks for this thread and thanks lothos for answering so much about the AI :)

min_garrison_prop: is percent based 1.0 = 100% while 0.2 = 20% of the amount of troops to have on garrison duty at the minimum. This can be overiden if the Front AI needs the troops.

neutrality: Below 100 the country is open to anyone. 100 to 120 he will only be persuaded by countries in his general area. 120 to 149 only countries he borders with have a chance at getting him to join their alliance and 150 is complete and TOTAL neutral nothing you do will change them.

war: 0 means they will never DOW anyone at all (combat overides this) then the higher it is the more aggressive they are.

strat_redeploy_threshold: Same as in HoI 1. The minimum amount of days for traveling the AI needs before he uses his strategic redeployment.

exp_force_ratio: Percent based of the amount of troops the AI should send to other countries. 1.0 = 100% and 0.04 = 4%

exp_force_ratios: A more detail breakdown of exp_force_ratio which allows you to specify the maximum amount of troops a country can get.

Graymane said:
If I want Germany to defend the coastal hexes from Denmark (atlantic side) to the netherlands (exclusive), so basically the 4 hexes or so that can be invaded between those two points. How would I do that? I want them to build coastal forts and man them with 3+ divisions each. I assume it is something to do with the garrison command, province priorities and area_multiplier maybe?

There are multiple ways to do it better this thread just explain all the individual commands and another thread cover concepts on how to use them.
 
Lothos,

I would suggest, that the best solution would be to put all that knowledge into ..\DOCS\ai_file_doc.txt. I can do that and provide the reworked file for download. Or you can do that, provide the file and tell us, what the latest updates are. The second one is probably the better solution, because you can cut out other things, which are not up to date (and I don't know that) and don't have to check, what I have done to the file. It is really best to mass all the info in that file.
 
Last edited:
Terminatrix, are you a Paradox employee? Exactly where do you fit into the official HOI2 development/production organization? Is your purpose in initiating this thread to informally and unofficially encourage people to post questions about the ai? Just curious.

CB
 
Transport/escorts

Part of theconstruction setting to control the build up of convoyships and escorts. transports = -1 means autobuild.
But the interresting part is:
Waht other settings are possible?
I'll try to hack this at the WE

Passivity

similar to the random factor in events .
A passivity von 50 means that every second move the AI want to make will not be done becauseof passivity.
passivity is a floating point value . So passivity = 100 maybe passivity = 99.999 in the computer so thats my guess , why the AI is attacking with a passivity of 100. ( Maybe you try 101 :D )

Spocky