Artificial intelligence

The Artificial intelligence or AI, is the computer orders on how the enemy and ally computer player and some units react in the environments of a game.

The AI in the Age of Empires series has improved greatly on many aspects since its implementation in Age of Empires.

Age of Empires
The AI in Age of Empires and The Rise of Rome has several notable traits, including: Under these circumstances, the AI will send all of their villagers to attack the threat.
 * AI will rarely, if ever, build walls. If AI does build walls, it will only be a short segment. This is common at the Scenario Editor under the default personality.
 * AI will often send their villagers to scout the map early in the game and will continue to do so late in the game even after more capable military units suited for the task are available. Scouting villagers will continue their job indefinitely until their death if they are able to effectively dodge range attacks.
 * With the exception of Campaigns and custom scenarios, AI will continue to build villagers/fishing vessels until they have about 30 or so.
 * AI will almost always construct most of their buildings at a certain distance away from their first Town Center. The space occupied by all of their buildings will often be a rectangular ring surrounding their Town Center if there are no natural obstructions.
 * AI will keep sending their villagers to repair damaged buildings/towers/walls until it is destroyed, even if it would be foolish to do so.
 * AI will often reconstruct a recently destroyed building near its previous location, even if the area is controlled by the enemy.
 * Later in a game AI will not build storage pits/granaries next to resource sites, but will instead gather resources as far away as they can.
 * AI do not hunt elephants and will not gather food from predators such as lions and alligators even if they have been hunted down.
 * Once AI military units are attacking a target (such as a building), they will never stop attacking it for any reason unless directly threatened.
 * AI will sometimes use military units that are outdated if resources are becoming scarce, for instance, they may use clubmen in the Iron Age.
 * AI will generally train a few specific types of units corresponding to its civilization bonuses and tech tree, and will rarely have a diverse army.
 * AI will strictly build their army based on their civilization's strengths, for example, an AI who is the Choson civilization may train only swordsmen.
 * If AI has multiple Priests, AI will attempt to convert it with as any priests as possible within its range.
 * If an elephant is within the range of the priest or near the unit that are trying to convert, the Priest will sometimes attempt to convert the elephant instead of the attacking unit.
 * In the Rise of Rome expansion, the AI seem to like training slingers regardless of their civilization and age, perhaps because of their ability to inflict full damage against buildings and towers.
 * AI will never attack with their villagers unless one or more of the following circumstances occurs:
 * They are attacked early in the game, such as in the Stone or early Tool Age.
 * Towers are built near their Town Center.
 * Their civilization is being crushed and defeat seems imminent.
 * If an enemy starts building a tower in AI's base, sometimes AI will send everything including villagers to attack the tower.

There is a special circumstance in the campaign, where the AI has a minimal script. in which it uses a dialog to communicate to the player. It will demand tribute from the player, and this will affect the AI's diplomatic stance with the player. This is seen in two campaign scenarios, namely in Oppression and Coming of the Huns :

"Tribute 400 gold to me or you shall be destroyed?"

If the player complies, AI will remain as an Ally (no Allied victory checked) meaning if that AI player wins by Wonder, Artifact, or Ruins countdowns, the player will still lose. AI then delivers the following script:

"A wise choice. Together we shall rule the world!"

Otherwise, if the player refuses to pay tribute within a certain amount of time, the AI will change diplomatic stance towards the player to Enemy, and will deliver the following script:

"You dare defy me? Prepare to die!"


 * In Oppression, the AI will only demand 300 gold, however it will change its diplomatic stance towards the player to enemy faster compared to the AI in Coming of the Huns, if the player does not comply. In the latter, the AI will demand 400 gold, as shown in the example dialog.

The Age of Kings
The AI in Age of Empires II is much more advanced than the AI in the previous installment. The Computer Player Strategy Builder Guide lists what each difficulty of the AI will do and what not:

Note that the hardest AI does not only get resources at the start, but upon reaching any Age, including the Dark Age. They get 500 of each resource every time for a total of 2,000 each when they reach the Imperial Age.

The Conquerors
In The Conquerors, the AI has been improved slightly, being more aggressive. The AI tends to build walls around its main base.

The Forgotten
In The Forgotten, the AI has made a huge step forward, being a challenging opponent in higher grades of difficulty. Some aspects of the Computer Player Strategy Builder Guide do not apply anymore. The resource bonus, for instance, was removed. Also, the AI uses the trade heavily now, thus generating more gold. But the aggressiveness they play with is the biggest difference, though. The AI either rushes or booms with heavy attacks in the early Feudal Age or late Castle Age, respectively. If an army is outnumbered, sometimes it even retreats. But still, when being besieged and mostly destroyed, they do not rebuild their base.The AI tends to use about 60% of the population limit or more to create Villagers, which causes its economy to boom rapidly from mid to late game, thus making its army nearly unstoppable as it would just quickly replace its defeated army due to the fact it has gathered high amounts of resources. This AI tends to stop attacking and prefers defending their base if it is running low on resources

This AI advances to the Castle Age a bit slower compared to the previous AI however once it does, it will have a stable economy by then. Also, since this AI focuses on booming together often complemented with rushing, it tends to collect Relics slower than the previous AI

The difficulty of the campaigns is much higher than it was in the previous versions.

The African Kingdoms
In The African Kingdoms, the AI was barely modified. The campaigns can be compared those in The Forgotten in terms of difficulty.

Trivia

 * Regardless of difficulty, the AI often dodges projectiles of ranged units. Also, it uses hit-and-run tactics with ranged units itself, making it hard especially for infantry using players.
 * Interestingly, the AI will sometimes cancel the construction of a building if it is only built by a single Villager and that Villager is attacked.

Random map AI personalities
Here is a table showing a detailed Standard AI behavior on different difficulty settings:
 * Standard: the most balanced AI, balances economy and military pressure. Usually attacks starting from the Classical Age, but only sends two waves per Age. Rarely walls.
 * Attacker: attacks early and raids frequently. Spends a lot of time in the Classical Age but will advance to the Heroic Age if their military pressure fails. Does not spend resources on Walls or Towers.
 * Conqueror: begins training a massive army in the Classical Age but does not attack until the Heroic. Is vulnerable to rush strategies.
 * Builder: focuses entirely on its economy in the early game, building and training the bare minimum. Will advance to the Heroic Age as quickly as possible and will follow up with heavy attacks.
 * Protector: will attempt to secure a large section of the map by first walling themselves and will then build many towers in the Heroic Age over a wide area. Will make a modest army in the Classical Age but will not attack until later in the Heroic Age.
 * Defender: will focus on defending the area closest to its immediate area with walls and towers. May attack in the Classical Age as resources permit and will advance to the Heroic Age at a much later time.
 * No AI: does absolutely nothing
 * Random: selects randomly from the above

Titan difficulty AI
Based on the table, you'll notice that Hard and Titan do not have much differences, except the fact that Titan has a handicap bonus of +100%. In terms of the numbers of gatherers, Hard has more villagers compared to Titan to keep its economy booming, while Titan only needs lesser villagers due to the said handicap. Since Titan has fewer Villagers compared to Hard, they have more population room for their army.

Greek AI's rarely spam powerful myth units such as the Colossus, since most of the time they only prefer to train Pegasus. They also rely on heroes most of the time, who cost them Favor, instead of using them to summon lots of myth units.

* Handicap bonus - it is a bonus which gives a particular player speed and gather rate advantage. For example, when fighting against a Titan AI, the player can notice a +100% beside the AI's personality name, which indicates they gain twice speed and gather rate as a regular payer without the handicap bonus. The bonus affects build time, unit's creation speed, research time and the resource gather rate. The said effect on the AI's performance is determined by the total handicap percentage before and after the handicap bonus. Each of the players (including AI's) already has a base handicap speed of 100%.

To explain this further, since every player has a base 100% handicap, if a single player game is played under Titan difficulty settings, it will give the AI +100%, which is like (100% base) + 100% handicap bonus = 200%, hence it is where the times 2 increase comes from.

When the player with a +100% handicap bonus gathers resources, the amount they deposit to the drop off sites are doubled. For example, a Greek Titan AI villager gathers 15 Food from a Deer then proceeds to deposit it to the Granary. In this example, 30 Food will be added to the AI's stockpile because of the 100% handicap bonus. (15 x 2 = 30)

MR. MONDAY
Using the cheat code MR. MONDAY gives the AI +1000% handicap, meaning their production rate is multiplied 11 times compared to a player without handicap bonus. It affects all AI's in the game. It also affects the AI despite which difficulty level the player is playing, and greatly affects the AI's performance. Getting back on the scenario earlier, if a Greek AI's Villager (with MR. MONDAY cheat) deposits 15 Food to the Granary, 165 Food would be added to its stockpile. (15 x 11 = 165)

To explain this further, since every player has a base 100% handicap, if MR. MONDAY is activated, it will give the AI +1000%, which is like (100% base) + 1000% handicap bonus = 1100%, hence it is where the times 11 increase comes from.

On Easy: AI will spam armies at a very fast rate. The AI may also reach Mythic Age quickly, however it will still not upgrade its units (not even to the Medium level) and will rarely attack Still, it will not attempt to capture even unoccupied Settlements.

On Normal: The AI, may also reach Mythic Age quickly and will upgrade their units to the Champion level. It will also attempt to capture two extra Settlements (with a total of 3 at a time)

On Hard and Titan: Since it is mentioned earlier that Hard and Titan AI's only main difference is the Handicap bonus, the cheat code MR. MONDAY will affect them the same way. They will build their armies extremely fast, will advance to the Mythic Age quickly, and upgrade their units to the Champion level. Because of the cheat's great handicap bonus, Hard AI with MR. MONDAY activated will adjust its Villager production accordingly so they can now have more population room to create a larger army.

Other notable traits

 * The AI never builds a forward base against other players

Random map quotes
Introduction Casts god power  AI Ages up first Player Ages up first Captured Relic Ally captures Relic
 * Just keep your armies in your own lands, and we will get along fine.
 * Good luck! You're going to need it!
 * Build many, many walls. You'll need them when I arrive.
 * To last, I grapple with thee!
 * My empire expands slowly, so you'll have to give me plenty of time before you attack.
 * Hail, stranger. If you keep to your lands, I might keep to mine.
 * May the best commander win.
 * It is a pleasure to meet you on the field of battle. I hope you put up a good fight!
 * This land is too small for all of us. I suggest you surrender now.
 * If it's a war you want, that is precisely what you will get.
 * My people will be victorious.
 * Anger me, and I will burn your cities and sow salt in the fields.
 * Greetings, mortal.
 * I have heard of this god you worship, but I am not impressed.
 * May all your villagers be killed by wild animals.
 * I hope you don't mind if I destroy each and every last one of your kind. Thanks.
 * I have heard of your coming. This should be a challenge.
 * Perhaps my people will build a monument to commemorate my defeating you.
 * My gods have a gift for you! I hope it hurts.
 * The gods have given me great power.
 * The gods favor my people.
 * The gods have blessed my villagers.
 * Take that!
 * Behold!
 * I could have chosen destruction, but I choose this instead.
 * Let that be a lesson to you!
 * That looked extremely painful.
 * This is almost a waste of my power.
 * You cannot possibly expect to win with your limited technology.
 * Your people have yet to discover fire or the wheel.
 * Only a civilization as advanced as ours deserves to survive.
 * You barbarians still fight with clubs and rocks.
 * Someday I will rid the world of primitive cultures such as yours.
 * You may have technology, but we have numbers
 * Even though you are more advanced, it will not save you from defeat.
 * Your gods have showered you with blessings.
 * Perhaps you would like to share some technology with me?
 * If you want this Relic, you will have to pry it from my Temple.
 * Look ma! I found a Relic!
 * I shall present this Relic to the Temple of my Gods.
 * I'm glad I found this relic before you did.
 * It was foretold I would uncover this relic
 * Another Relic to add to my collection.

Allies send signal flares from the spot where they picked up a Relic Prepares to attack Retreats Player caught building walls Player claims Town Center Ally being attacked
 * Sweet this relic is mine.
 * It won't be long now. Soon you will see my banners in your lands.
 * I toy with my prey.
 * You are in my way. You shall be removed.
 * Swords sharpened. Spears leveled. Prepare to attack!
 * My god decrees that I must destroy you.
 * Lock your doors and windows. The storm approaches.
 * You have pushed us back into the fringes of civilization.
 * Run Away! Run Away!
 * I will withdraw. We shall resume our battle later.
 * My victory over our empire will have to wait.
 * Walling yourself in? That won't help you.
 * Fine. Build walls. I will make siege weapons and come get you.
 * You waste more resources on defenses?
 * Men fight with troops. Children fight with buildings.
 * I will soon take from you what is mine.
 * I know where you are expanding.
 * You prey upon the weak.
 * Do not think you can challenge me.
 * Cease this expansion into neutral territory.
 * That was a peaceful village. You did not have to invade it.
 * A bold move, but I shall have the last.

Note that the ally will send a signal flare at their base where they are fighting off enemies Player or ally loses Town Center
 * Can you come bail me out again?
 * Please send aid, or I will be forced to resign
 * They are getting the best of me at this location.
 * Help me here, or I will be forced to resign.
 * I am having some trouble at this spot.
 * I am going to be crushed! Can't you do anything?

Note that the enemy may also quote these if the player casts the Citadel God Power Enemy loses last Town Center Enemy loses Wonder/Titan Gate Offers to surrender The enemy AI will usually offer to leave the game whenever the player has done severe damage to them, such as destroying their Town Center or killed most of their worker units. The player can choose between Yes or No
 * Sniff. Do I smell something burning?
 * Oh, did you need that town?
 * Your empire collapses into anarchy.
 * You have removed all of my cities from the map.
 * My empire has collapsed.
 * I suppose you will not stop until you have destroyed all of my empire.
 * Hey! I needed that!
 * Curse you! I spent a lot of resources on that Wonder!
 * I guess I have to win with the old fashioned way.
 * May I offer my surrender?
 * Perhaps you would allow me to leave with some dignity?
 * Can we please stop this war before more lives are lost?

Age of Empires III
In Age of Empires III, the AI also have their own preferences, copying defenses in each game. The group below presumes that the player is not playing on a post-industrial or imperial gameplay as the towers will already be on Fortified level.


 * Queen Elizabeth, Napoleon, and Suleiman the Magnificent always upgrade Outposts to Frontier level.
 * Maurice of Nassau always upgrades Outposts to the Fortified level.
 * Queen Isabella does not make Outposts but does use the Outpost Wagon card, but replaces it as her level increases.
 * Ivan the Terrible builds Blockhouses due to serving as both a defensive and infantry production building. He does not upgrade them at all.
 * Prince Henry the Navigator and Frederick the Great never build Outposts.