[17.0.12182.0] AI neglects economy and military after Raiders Update

Version: 17.0.12182.0
Mode: 1v1 against AI
Difficulties: Various, including Ridiculous

Since the Raiders Update, affected AI opponents produce few or no military units and appear to prioritize reaching Imperial Age while poorly managing their economies. At the start of matches, I also observed villagers gathering berries and walking back to the Town Center to drop off food.

This has occurred across several games with different civilizations and difficulties. Malians appear particularly affected; Vikings seem okay in initial testing.

Steps to reproduce

  1. Start a 1v1 against AI.

  2. Observe its opening economy, military production, and age progression.

  3. Repeat across different civilizations, maps, and difficulties, particularly with Malians.

Expected: Effective economic management and military production alongside age advancement.

Actual: Poor economic management and little or no military while advancing to Imperial Age.

Updates: All civs baring Vikings appear to be totally broken, tested a handful of maps and all difficulties.

Thank you for reporting this change in the Ai’s behavior, across varying difficulties and with differing civilizations.

I’ll get this info sent over to others on the development team.

Hi Devs,

I am an AI player (Singleplayer) and can confirm this bug. The AI is completly passive and is not doing much. Would be cool if this could be fixed soon.

Great DLC though - love the Scots and the new Biom :slight_smile:

Best

@TheKingofFüt-Würk @Shifty1 To help investigate this, it would be very helpful to confirm which difficulties you have seen this on specifically. I see that Ridiculous is mentioned and it will be great to confirm which others are affected. Thanks!

@ADragon8602 After further testing, the issue appears to persist across difficulties from Easy to Absurd, so I don’t think difficulty is a factor. I’ve tested a handful of maps and configurations, and it seems widespread. Watching replays, the AI also appears to focus too heavily on gathering food. Lots of small things like refusing to tech up at all. Like I mentioned it’s pretty seriously busted and probably worth escalating in my estimation.

I’m happy to run any additional tests you’d find useful to help narrow down the cause. Based on what I’ve seen, this should be very easy to reproduce and pretty systematic.

Since the update, AI opponents of all difficulties are extremely easy to defeat. They play far, far worse than they did yesterday, before update 17. They neglect their economy, they neglect technology upgrades, and on higher difficulties, they are far less aggressive.

I have screenshots which highlight some of the most damning problems.

Here, the Intermediate AI (Japanese) only ever utilised half the population limit:

They hardly built any military units at all until well after the imperial age. They scouted my base with Shinobi and saw that I was without any military units, yet they never did anything about it:

They hardly gathered any gold, only the bare minimum needed to advance to the castle age, and then the imperial age. Once they had the amount needed to advance, they stopped gathering it, and didn’t use it to upgrade their gathering rates:

They hardly gathered any wood either, until after the imperial age:

Now, against the Hardest AI (Jeanne Darc), they still didn’t build any military units until well into the imperial age:

Incredibly, they stopped producing villagers once they reached the feudal age, and they didn’t produce any for ten minutes, well into the castle age:

They gathered next to no wood for 20 minutes:

And even though I let this game go on for over 40 minutes, the hardest AI only researched a total of 14 technologies:

Here is a game I just played against A.I Outrageous. They were the Malians. They didn’t gather wood for 25 minutes:

This lack of wood correlates to a lack of houses, as shown by the fact they stayed at 10 population for 20 minutes:

After 35 minutes, the Outrageous AI had only mustered a total population of around 50:

Playing against AI isn’t enjoyable since the update. A huge problem seems to be their disregard for wood and houses. They seem to care about gathering just enough food and gold to advance to the next age, neglecting upgrades and not prioritising increasing their population limit.

In the last game i have played aggainst French IA, it didn´t make any military units, and all their villagers go to gather Berries, without any worry of being attacked, or any hurry to attack.

Viking IA only produce Volvas, like 8 or 10 without get any relic.

The enemy IA in Single Player simply is not working, didn´t know why.

@ADragon8602 @Cobaltdragon913

Edit: Updated with the root cause, two tests that confirm it, and an AI-only workaround. My earlier hint about the tree’s own gatherer override was a dead end and has been removed.

TL;DR: since 17.0.12182.0, skirmish AIs put almost every villager on food and almost none on wood, so they stall at the pop cap with no army. The cause is the AI production planner’s estimate of how many more villagers to train. In 17.0 that estimate comes out far too high, and its food cost (50 per villager) is counted as food demand, which swamps everything else in the gatherer split. Making the AI’s villagers cost 0 food fixes the AI completely (tests 4 and 5). Vikings are spared because their town center villagers already cost 0 food.

Symptoms (every civ I tested except Vikings; Mongols vary from game to game; others in this thread report it on every difficulty):

  • 0 or 1 villager on wood from the first minute; nearly everyone else on food.
  • Nothing that costs wood gets built: houses, mills, lumber camps, farms, barracks.
  • The AI sits at its pop cap with 1 or 2 military units and 2000+ unspent food by 10:00. The Malian AI stayed at 10/10 the whole game.

What’s broken (for the dev team)

How the pieces fit, using the names from the AI state tree and scardocs. The two defects are from comparing the 16.3.11308 and 17.0 builds; the tests below confirm the villager food cost is the link.

  1. Gatherer split. The AI’s gatherer distribution gives each active resource one slot, then assigns each remaining villager to the resource with the best demand / (gather rate x villagers already on it).
    • Demand per resource is base demand from planned production, plus the strategy targets from AIStrategyTrack_AddRequiredResources (Age 1: 550 food, 500 wood), minus the surplus stockpile.
  2. Base demand. AIPlayerTask_GenerateProduction keeps it as a moving average of cost x count over the planned production items. The live gatherer re-solve then reads it.
  3. Villager count. For villagers, the count comes from a “how many more villagers are worth training” simulation. It runs a temporary gatherer solve, then adds one villager at a time (20 s and 50 food each) while that shortens the time to meet demand, up to 100.
  4. Two defects in that simulation in 17.0. The gatherer solver was restructured in 17.0 to group gatherers by unit blueprint and check which resources each one can gather. The planner’s temporary solve didn’t get the matching changes:
    • The counter it returns is never initialised.
      • In 16.3, “gatherers left to place” and “extra villagers” were separate counters, and the second one always started at 0.
      • In 17.0 they were merged into one counter that the pre-allocation step decrements and the “train one more” loop increments, and nothing resets it.
      • The solve is a short-lived temporary, so the counter starts from whatever was left in memory, and the result is leftover value plus up to 100.
      • My guess is that this leftover differs between games and civs. That would explain why Mongols vary and why some AIs drift onto wood late in a game.
    • It never places the AI’s existing villagers. Only the live gathering update fills the new per-blueprint groups. The planner’s temporary solve starts with about 1 gatherer per resource, so adding villagers always looks worthwhile. The gatherer count passed into it is never used.
  5. Result. In my reconstruction of the logic, the planner wants 100+ more villagers, and the number keeps climbing. At 50 food each, base food demand runs into the thousands, against about 500 for wood.
    • The split puts nearly everyone on food and leaves wood with its single slot.
    • Banked food doesn’t help, because the imagined demand is bigger than any stockpile.
    • It matches test 1: nearly every villager on food and 0 to 1 on wood, with 2000+ food banked.

Suggested fix: in the planner’s villager estimate, initialise the counter to 0, and place the AI’s existing villagers (or use the gatherer count it is given) before adding new ones. The counter is the critical part; placing existing villagers is also needed to match 16.3.

Vikings: both Viking town centers have item_cost_adjustment food -100 on the villager spawn item, so Viking villagers cost 0 food. A broken count times 0 food adds no demand.

  • When I removed the discount (test 4), the Viking AI showed the broken pattern in its opening, then recovered by 5:00. So something else protects them later.
  • My guess is that villager production via toggle_villager_production_vik keeps them out of the estimate. Unverified.

Tests

Setup: single player skirmish, Dry Arabia (seed 744b0fde), me idle vs 7 allied Hard AIs. A read-only logger in the dev SCAR console recorded every AI every 30 seconds.

Test 1, unmodified, at 10:00:

Civ Pop / cap Villagers on food / wood / gold Lumber camps Food banked
Malians 10 / 10 9 / 0 / 0 0 2160
English 25 / 30 20 / 1 / 2 0 2600
Japanese 26 / 30 22 / 0 / 2 0 2263
Scots 24 / 25 23 / 1 / 0 0 2131
French 26 / 30 24 / 0 / 1 0 2624
Vikings 45 / 85 16 / 6 / 9 1 572
Mongols 34 / 200 11 / 7 / 3 0 (gers) 125

Test 2, 500 wood gifted at 3:00: the AIs spent it sensibly on houses, mills and military, then went back to zero on wood. AIs with a lumber camp still kept zero on wood. So the build logic and dropoffs are fine.

Test 3, gatherer override: AIPlayer_SetGathererDistributionOverride plus AIPlayer_UpdateGathering restored wood gathering within a minute. Re-applied every 45 s, it gave 39 to 42 pop and 15 to 19 military at 10:00, vs 10 to 26 pop and 1 to 2 military. So the gathering machinery works; the default split is wrong.

Test 4, villager food cost (tuning pack, no scripts): French villagers set to 0 food. The Viking TC villager discount removed, so Viking villagers cost 50.

Food / wood / gold villagers at 3:00 Pop / cap at 10:00 Military at 10:00 Food banked at 10:00
French, unmodified 10 / 0 / 1 26 / 30 1 2624
French, free villagers 0 / 8 / 0 42 / 50 17 331
Vikings, unmodified 0 / 8 / 1 45 / 85 13 572
Vikings, paid villagers 10 / 0 / 3 41 / 85 10 71

Test 5, AI-only fix (script): a player modifier (resource_entity_cost_food x0 on the villager) for four AIs only. The script charged the food back for every villager they made, about 1000 food per AI by 12:00, so they got no free economy. The Japanese AI in the same game was left untouched as a control.

Civ Pop / cap, military at 10:00, unmodified With the fix
Malians 10 / 10, 1 33 / 35, 12
Scots 24 / 25, 2 34 / 45, 12
English 25 / 30, 1 41 / 50, 17
French 26 / 30, 1 35 / 40, 11
Japanese (control) 26 / 30, 2 27 / 30, 2 (2482 food, 0 on wood)

By 12:00 the four fixed AIs were at 41 to 45 pop with 14 to 20 military. The Japanese AI was capped at 30/30 with 3085 food.

Ruled out:

  • AI attribute data and AI Lua scoring: no changes for existing civs.
  • The new allow_far_gather_on_deposit_types field: a tuning pack adding tree, gold and stone did nothing.
  • The tree’s SetOverrideResourceGathererDistribution node: it’s in the campaign root only.
  • Strategy resource targets: unchanged apart from a new ScotsStart entry.
  • Vision and naval map detection.

Details:

  • Build 17.0.12182.0 (rtm 4184287), Steam, Windows 11, offline skirmish, standard_mode.
  • No Lua or SCAR errors during any test.
  • Docs note: scardocs types the second argument of AIPlayer_SetGathererDistributionOverride as Real, but it takes a table such as {food=0.4, wood=0.4, gold=0.15, stone=0.05}.

Happy to share the logs, scripts, test replays (they only play on this build) and a more detailed technical write-up with the team privately.

Hardest AI playing Mongols just gathered a total of 111 gold and never advanced to the feudal age in 20 minutes:

I can confirm, however, that Mongols are a mixed bag. The first game I played against absurd Mongols, they stomped me. They kept harassing me with waves of enemies which kept increasing in number, and I couldn’t keep up.

Then I played against Hard Mongols, and they were similarly aggressive for a while, but after 15 or so minutes, they stopped attacking me and let me recover, until I was able to take control of the game and crush them.

Across a few games I noticed a trend that the AI would not send villagers who are under attack to safety if they were gathering berries or fish. It prioritises gathering more food over saving the villagers’ lives. Which is very ironic, if @TheKingofFüt-Würk is correct and the reason the AI wants so much food (and not other resources) is a supposed need for more villagers.

Strangely, it did seem to garrison them if they were gathering from sheep. At first I thought it would be to do with the distance from the Town Centre, as villagers were gathering from berries and fish and making quite a trek to drop off the resources, while sheep were always clustered around their TC. However, even when the villagers made the trek to the TC to drop off their berries or fish, they would still return to the resource while under attack, or while villagers at their destination were being killed.

Update: workaround mod is up

I’ve published a game mode that works around the bug until the official patch: AI Villager Fix
Mods Single - Age of Empires - World's Edge Studio (or search “AI Villager Fix” in the in-game Mods menu)

What it does

  • It is the Standard game mode with all its usual options: win conditions, player scores, starting resources and age, map state.
  • For AI players only, villagers and every other gathering unit are made free: fishing boats, Chinese officials, Scots cattle, Jin mounted villagers and so on. The full normal price is then charged back the moment each one is trained.
    • This targets the cause described above: the AI counts the cost of the villagers it plans to train as demand, and that estimate is broken in 17.0. With the cost at zero, the broken estimate adds nothing, so the AI’s own gathering works again.
    • Because the price is charged back, the AI gets no free economy.
  • Free and bonus units (Japanese free villagers, Ayyubid House of Wisdom villagers) stay free. Mongol double production and Golden Horde pairs are charged as one item.
  • Player scores count the real price, as normal. Human players are not affected.

Testing

  • Tested against Jin, Scots, Chinese, Japanese, Mongols, Golden Horde, Malians, Byzantines, Abbasids and Ayyubids on Hard and Hardest.
  • They all gathered wood, built houses and lumber camps and made armies, at 31 to 67 pop by 10 to 12 minutes, vs 10 to 26 pop unmodified.
  • The charge-back matched every villager trained, with no AI ever in debt.

Known limits

  • Custom games only. It can’t be combined with other game modes.
  • AIs pay the start-of-game price even after techs that make villagers cheaper.
  • Ayyubids still dip briefly during their very early Feudal age-up.
  • The Tughlaq AI looked stuck on gold in one test. That seems to be a separate issue.
  • Untested on water… to lazy to fix more.

Remove it once the official fix is out. Happy to answer questions here.

I can confirm this. The problem seems to be with AI gathering food only. I played against the hard (Rus) and they wouldn’t build anything which requires wood, all villagers -except for one on gold- were simply gathering food. Then, it seems the priority is to advance civ, so AI built two landmarks, and that’s basically all it did before my patience ran out. Terrible, absolutely terrible and intolerable situation!

There’s a big difference between a community manager saying “I’ll pass this along to the team” and an official announcement saying “We’re aware that skirmish AI is severely broken, we’re working on a fix, and we’ll keep you updated.”
The frustrating part is that players have already done extensive testing, identified a plausible cause, and even created a workaround mod.
At this point, I think the developers owe players a clear acknowledgment, even if they can’t give an ETA. Not knowing when it’ll be fixed is understandable. Not clearly communicating about such a major regression is much harder to justify.

Any difficulty.

If anyone opened a single game vs AI in this patch, they should be able to notice that it is broken.

I can confirm that I’ve been experiencing similar AI issues since the Raiders Update.

I mostly play Skirmish against AI, and I’ve noticed that several civilizations seem to struggle with basic economic management, military production, and age progression, even on higher difficulty settings.

For example, I’ve seen English AI players gathering large amounts of food while neglecting wood, eventually reaching their population limit without building additional houses. I’ve also observed Japanese AI remaining in the Dark Age for an unusually long time, and allied AI players reacting far too late when their teammates are under attack.

Interestingly, in my recent matches, Vikings and Mongols seem to perform better than most other civilizations. Viking AI has actively attacked my allies and produced substantial armies, while several other civilizations remained passive or developed very slowly.

Of course, these are observations from my own matches, and the behavior may vary depending on the map and game conditions.

I really enjoy Age of Empires IV, especially Skirmish mode, and I hope these AI issues can be addressed in an upcoming patch. There are players like me who genuinely enjoy playing against AI rather than focusing on competitive multiplayer.

Thank you to the development team for looking into this issue!

Things have improved a lot since today’s update. I switched to the standard game mode after playing with @TheKingofFüt-Würk’s mod for the last few days. The Hardest AI is too good for me, once again.

However, the AI still has its problems.

I just played against Hard Ottomans, and in 30 minutes, they never advanced to the Feudal age:

It’s not as if they couldn’t afford it; the AI seemed to be gathering resources as normal now:

Nor were they population locked like they would be before today’s update:

It’s strange. This was my second game today against Hard AI playing Ottomans, and in the first one they put up a reasonable challenge. But in the second game, they just stayed in the dark age.