• Paradox Games has announced today their new game “Millennia”, a semi-historical turn-based 4X game. Find out more here .

Feeling Bored Cause the AI is too easy? Simple handicaps to improve gameplay.


Feb 25, 2008
I've spent some significant effort testing some of these for balance and/or troubleshooting. The bulk of these edits are just to allow the AI to get way ahead of you so you have to be more economical with your resources in general. They are all contained within editing the LUA or using IGE to add population.

***SECURITY NOTE*** - You should definitely have a backup of the R.E.D. file somewhere safe before editing this stuff. Editing it improperly can make the game crash or the engine to not function properly. I don't have any scripting experience to speak of, and these are the mild insights of a humble fan, not any authoritative hotfix.

1. Pre-building good AI cities with bank/factory/<advanced factory>

In the default script, very few cities start with a full gambit of buildings ready to produce high quality units. Most don't even have Banks or Factories. An easy fix to this is editing in the DefinesEuro1940 or whichever map specific scenario you want to edit, the following:

Within the "Cities" section, it appears like this:

{X = 27, Y = 52, Key = true, Buildings = { FACTORY, HARBOR }, AIBuildings = {SHIPYARD}, }, -- LONDON

-- Within the curly brackets after AIBuildings =, you can add ", BANK, BASE, ARSENAL, ACADEMY"

The case sensitive seems to matter, as does a space between the first bracket and the last bracket and the contents of the brackets.

Furthermore, If you want the AI to focus more on Air or Naval, you can edit that in specifically by adding shipyards, medium/light air factories, or land factories. Generally speaking, England should be almost entirely Light Air or Shipyards.

2. Fixing the Hard-Cap of AI Units ratio.

Within the DefinesEuro1940, under the Units section, there is the "-- Combat type ratio restriction used by AI"

Messing with these numbers can dramatically alter the way the AI builds units. If your system can support a huge game with a ton of units, then i highly recommend doing the following, but only in conjunction with adding factory/bank/land factory to basically every Russian AI city:

Replace this: (The default)
[USSR] = {Air = 5, Sea = 7, Armor = 3, Artillery = 7.5,},
With this: (my own adjustment)
[USSR] = {Air = 8.5, Sea = 25, Armor = 5, Artillery = 4,},

This would be of some help by itself, but its really only effective if you also give the Russian AI a huge advantage in starting structures and by adding some population to basically every city with IGE. A few more manufactories by Leningrad, Moscow, Stalingrad, Novgorod, and basically 1 by every other city towards the East will guarantee that Russia has a huge number of Infantry, a good amount of artillery, and some decent armor. With the defensive bonuses that they receive from defending over Rivers, it is a serious challenge to properly invade Russia without beggaring yourself in a materials deficit from overuse of armor and airpower.

Other edits to be done in this section are important for Italy, which could afford to build less Navy and more land units, and England which should have navy and air power put at 2.

I wouldn't advise against putting anything at 1, because it makes the AI a little unreliable that it will only produce that type of unit, which would be a bad tactic for anything.

3. The reserves system.

I've only begun to tinker with this, and im honestly not sure exactly how it works or the tolerance with which it could be adjucted without causing crashes or some other kind of unforeseen problem.

It looks like the following:

-- unit type called when AI need reserve troops
g_Reserve_Unit = {
[FRANCE] = { {Prob = 50, ID = FR_INFANTRY}, {Prob = 10, ID = FR_AMR35}, {Prob = 10, ID = FR_FCM36}, {Prob = 5, ID = FR_AMC35}, {Prob = 5, ID = FR_CHAR_D1}, {Prob = 5, ID = FR_CHAR_D2}, },
[ENGLAND] = { {Prob = 50, ID = UK_INFANTRY}, {Prob = 20, ID = UK_VICKERS_MK6B}, {Prob = 10, ID = UK_MATILDA_II}, {Prob = 5, ID = UK_MATILDA_I}, },
[USSR] = { {Prob = 50, ID = RU_INFANTRY}, {Prob = 20, ID = RU_T26}, {Prob = 15, ID = RU_T28}, },
[GERMANY] = { {Prob = 50, ID = GE_INFANTRY}, {Prob = 20, ID = GE_PANZER_I}, {Prob = 15, ID = GE_PANZER_35}, },
[ITALY] = { {Prob = 50, ID = IT_INFANTRY}, {Prob = 20, ID = IT_L6_40}, {Prob = 15, ID = IT_M11_39}, },

-- Thresholds used to check if AI need to call reserve troops
g_Reserve_Data = {
-- UnitThreshold : minimum number of land units left
-- LandThreshold : minimum number of plot left
-- LandUnitRatio : ratio between lands and units, use higher ratio when the nation has lot of space between cities
[FRANCE] = { UnitThreshold = 8, LandThreshold = 108, LandUnitRatio = 10,
Condition = function() local savedData = Modding.OpenSaveData(); return savedData.GetValue("FranceHasFallen") ~= 1; end},
-- initial plots = 216. France won't get reinforcement once Paris is captured
[ENGLAND] = { UnitThreshold = 14, LandThreshold = 100, LandUnitRatio = 5,
}, -- no condition function means always true
-- initial plots = 111
[USSR] = { UnitThreshold = 20, LandThreshold = 2350, LandUnitRatio = 50,
-- initial plots = 2469
[GERMANY] = { UnitThreshold = 20, LandThreshold = 300, LandUnitRatio = 10,
Condition = function() local turn = Game.GetGameTurn(); return turn > 5; end},
-- initial plots = 204 : German AI get reinforcement almost immediatly (after 5 turns because LandThreshold > initial plots)
[ITALY] = { UnitThreshold = 12, LandThreshold = 90, LandUnitRatio = 5,
-- initial plots = 114

As i understand it (and Gede or anyone else, please correct me if i am not explaining this correctly), but by turning down the LandUnitRatio, especially for Russia, you can increase the frequency with which they spawn units.

I would be open to further explanation. I've turned down the USSR LandUnitThreshold = 20 from 50, but i haven't seen a single 'alert' that reserves have been called up. I suppose its possible that the system is not active on the Euro1940 map that I've been testing all of the other stuff on. Furthermore, i don't have the tolerance to play several hours testing each individual adjustment, so my adjustments have been fairly hyperbolic.

I know Gede has a new version in the pipeline, but if i stabilize my hotfix, I'll post a complete link to my version of the DefinesEuro1940 so people could just copy/paste it (which is a lot easier than editing all of this stuff individually).

Some precision, the condition must all be meet to trigger the AI reinforcement spawn:

UnitThreshold > number of land military units left
LandThreshold > number of territory tiles left
LandUnitRatio < number of territory tiles left / number of land military units left

And yes, lowering it will spawn more unit. It's used to prevent spawning of unit when the AI has no territory to put them on. Should keep it > 3.


in g_Reserve_Data:

[USSR] = {	 UnitThreshold = 20, LandThreshold = 2350, LandUnitRatio = 50,
-- initial plots = 2469

Say, USSR has 19 land units left, has lost 120 tiles of it's original territory (2349 tiles left), and 2349/19 (= 123.63) is more than 50

Conditions are meet, now the mod will test (one by one) the prob of each unit in g_Reserve_Unit with a random number between 0-100.

[USSR] = { {Prob = 50, ID = RU_INFANTRY}, {Prob = 20, ID = RU_T26}, {Prob = 15, ID = RU_T28}, },

3 unit to test, so 3 random numbers are generated, suppose (67, 5, 34)

67 > 50, so no infantry spawn
5 < 20, one T-26 unit spawn
34 > 15, so no T-28

For testing, try to raise the prob of one unit to 100 and set UnitThreshold and LandThreshold to something big, if nothing spawn then there may be a bug in the code, please post your Lua log, I'll have a look.
I started to look at some files to do some changes like ilshur, and I discovered that the AIBuildings and the AI bonus units didn't appear in my games.
So is it just a bug coming from my game or the functionality isn't yet established in v.37 ?
look at your Lua log for errors, the AI buildings bonus is working.
Indeed they are working... It's just that it only happens for enemy AI.
Would it be possible to allow the bonuses for our allies too (I think they have already enough handicap) ?
Top Bottom