Frogboy Frogboy

Stupid AI tricks

Stupid AI tricks

image With Elemental: War of Magic v1.1 BETA now out, you can see the direction we’re heading with the game.  Global mana has made a huge positive impact on game play and having your population being put to work (literally) not only provides a great game mechanic but connects the player to the game more closely.

As you can imagine, such significant game play changes require a lot of new AI coding to make it effective.  With Kael joining us to relieve me as the Producer on Elemental, I have more time for working on the AI (I am still handling the role of senior lead developer on the game which is a position I’m looking to fill – hint hint). 

A 5 step process

The process I use to make good AI works roughly as follows:

Step #1: Make the AI multithreaded.

This is the most important thing because it allows the developers to focus on making the AI effective without worrying about time so much.  Games with single-threaded AI have painful late games where you can wait a long time between turns. 

This part was accomplished in the v1.1 beta. It still has to be debugged (90% of crashes are due to this) since you have to make sure the AI isn’t monkeying around with main game data.

Step #2: Play the game at a basic level

This is pretty obvious. Can the computer players do everything that the human can do? This is something that I’m working on this week.  This can be effectively described as playing the game without worrying about opposing forces.

Step #3: Play the game at a competitive level

This is where it plays the game knowing that there are others trying to thwart it or destroy it.

Step #4: Play the game at the meta-game level

This is where it gets good at handling diplomacy, its dynasty, trade, and maximizing resources.

Step #5: Eliminate stupid AI tricks

Stupid AI tricks are simply little holes or little exploits that really need to be explicitly looked for and eliminated.

So for those of you who have v1.1, can you list THREE (no more, no fewer) things that you see the AI do that are either stupid or result in its destruction and what you would do if you were them?

113,186 views 54 replies
Reply #26 Top

1. The AI declares war long before it is prepared or able to attack me. This gives me time to prepare a defense or to just attack them first.

That is something I found annoying in many 4x game. They declare war on you because of bad diplomatic situation. You prepare yourself to go to war, and then 50 turns later when you are bout to invade, they want to make peace because nothing happened between you too.

If an AI declares war, he should be prepared to invade.  It might not be the best preparations, but at least have some people available to attack.

 

That is because it is a BETA, If you want to downloaded it (be warned it is a BETA and so prone to crashes and issues), you need to tick so prerelease versions in Impulse.

You mean that there is a place in the options that I could select to activate the download of BETA patch? You see, I a trying to lead a modding team, and if I do not have the most recent version, well I am like behind everybody.

Reply #27 Top

Can someone test the next release more before it released, I don't understands releasing any version that crashes every 15mins.

 

Reply #28 Top

test

Reply #29 Top

sorry, forum is lagging.

Reply #30 Top

Ill get back to you when a build gets released that doesn't crash every few turns, because at the moment, the game doesn't get far enough to see any AI effect.

Reply #31 Top

1. AI attacks with low powered stacks in late game. The AI should consider using low powered stack in the early game when the human player may not have any trained units to defend his cities.

2. If AI knows its going to lose a conquered enemy city it stays to defend it or it runs away. The AI should consider razing the city and runnning away.

3. AI never builds bowmen, this allows the human player to do damage (or eliminate) AI forces before they can engage his troops. I would add different AI build personalities, with each havng a greater or lesser focus on training ranged attackers.

Summary

AI Personality should be a combination of different a) conquest strategies and b) unit trianing strategies.

Example:

Conquest Strategies:

  • Strategy 1: Mongol Horde - Raid, Pillage and Raze
  • Strategy 2: Anzio - Advance and Hold

Trianing Strategies:

  • Strategy 1: Melee Attackers 100%, Ranged Attackers 0%
  • Strategy 2: Melee Attackers 50%, Ranged Attachers 50%

Thus you might face an AI using:

  1. Case A: Mongol Horde Strategy with Melee Attackers 100%
  2. Case B: Mongol Horder Strategy with Melee Attackers 50%, Ranged Attackers 50%
  3. Case C: Anzio Strategy with Melee Attackers 100%
  4. Case D: Anzio Strategy with Melee Attackers 50% and Ranged Attackers 50%

 

Reply #32 Top

1. In the early game I have seen the AI settle cities at "tactical" points where they could control the continent better if they were powerful in the future. The problem is that a 4X game is super-linear, so by choosing a city spot that is less optimal growth-wise just means I am going to walk all over them later in the game and their tactical points will mean nothing. The AI should only start meta-gaming when they can afford it growth-wise.

 

One example: Magnar settles a narrow passage that is between me and another AI. Smart for controlling our access to eachother. Stupid because there was a number of metal and gold mines just nearby that it never settled, and when I needed that passageway, it could just take it, because they were puny.

 

2. Another attempt to be smart is the AI leaving cities they believe to be lost. It is an excellent way to save troops, but ONLY if you believe it is possible to withdraw and make a stand at the next city. If the AI cannot defend the next city, it should either surrender, or play spoiler by just defending the best spots: The cities. Also the troops leaving the cities currently doesn't as much withdraw as they scatter randomly across the wasteland, just making them easy to pick out one by one. This could have been a smart move, but is currently just another example of a criminally stupid AI, that just doing everything it can to make it easier for the player to beat it up.

 

3. AIs that know they are being dominated are not doing enough to avoid pissing their overlord off. I you believe you are being dominated, then stop tempting your fate, by moving pioneers through your overlords territory and settling in random positions within it.

Reply #33 Top

1. AI sending pioneer needlessly and endlessly.

 

I suggest instead of players/AI can only capture resource in their sphere of influence, let hero/unit/carven/builder capture the resource and be able to use the resource. Resource in sphere of influence cannot be capture by other fraction and give more bonus.

Thus there are no need to script the AI sending pioneer stupidly in enemy way, built next to own city and be limited, built in area with no resource and can never grow.

Players need not build cities everywhere even when there is only one resource to be capture (horse / shards)

 

This will dramatically save programmer work scripting the AI on whether to sent pioneer or not, where, when, efficiency, food limit, enemy way, defending pioneer and city, army spread too thin etc etc.

Reply #34 Top

1) The AI packs its cites very tight failing to hook up resources into their city walls or using the mobility advantages of snaked-out cities. That is something that deserves looking into since there are not much obvious advantages to that kind of tight city building...


2) The amount of resources needed for an AI to go to war and given for champions seems off and doesn't seem to much take into account relations ect (there seem to be modifiers but those seem far to small).

The AI might want to be a bit less eager to declare world war for a few measly gold pieces or a single champion, also the AI shouldn't shove gold into our gullets for us declaring war on some innocent bystander the AI even doesn't really care or even know about and we want to attack anyways. Only for factions the AI actually wants dead or at least dislikes, considerable amounts of money should be given. (This should also be important for inter-AI relations. Bringing other factions into war might be a worthy AI / Player goal and thus shouldn't be trivial imo.)

Also heroes (going both ways) are worth obscene sums in trade (+ the display in the diplo-screen seems of with the numbers for AI heroes being about 10 times higher than that of the player but if put on the table they even out to about the numbers of the AI side. I reek a decimal error and that the value given on the player's side are the real planned ones. Might be worth looking into.).


3) Hireable heroes and resources in the wilderness seem woefully undervalued by the AI (with regards to heroes this seems to have gotten considerably better actually with 1.09n but still far from there yet).  Especially for the more charismatic of sovereigns hiring heroes can be a serious boon.

The AI should shoot for those nearby first and get their hands at least on those heroes that wander its terrain if the AI is not totally resource drained (and especially those that match its needs / personality / tactics like if gold drained hire each merchant you come across ect.). The AI so far seems to play its most basic game of building cities and building troops + maybe slaying monsters while ignoring most of the environment. Which is a shame given how much can be gained from it.

Also playing into that is the AI seems to have targeting all wrong trying to take the toughest and highest level troops out first regardless of more squishier troops with way more firepower around. (Killing a puny spellcaster / archer especially if in enemy territory thus potentially finishing the sovereign off should obviously be a priority...)


So priority/targeting issues all around in combat and out of it.

Reply #35 Top

I have faith that you will make a very strong and enjoyable game and at this point I’m not in a hurry after all I’ve been waiting for a game like this ever since Temple of elemental evil.  I have noticed for a game that has “war of magic” in its title I rarely see the AI use it, I would think that if you could find a way for the AI to use magic like a player would, it would help mimic a human player. It also makes the player more inclined to use counter spells. This way we see a lot more magic in the game being used witch I think is your original design in the first place. May be you should tailor one empire and kingdom for this specifically. Or always have a spell caster with an army that uses spells. Anyhow more AI magic is what I would like to see. Keep up the fantastic work.    

Reply #36 Top

My post got eaten. :(

Anyway, working away on this.

Reply #37 Top

Someone already said it, but please ensure (at least in relation to the difficulty level of the AI) that they do not declare war until they are ready for war / already mobilizing for war.

 

This may be already in full use, but one way to scale the AI difficulty would be to scale their "mistake tolerance" where a mistake would simply be a misinterpretation of a value.

For example, say the player's army "danger" value is 100. An easy AI may have their mistake tolerance set to +/-40%. So when getting the value, they may interpret it as being anywhere from 60 to 140. This would make the AI harder to predict (making them appear more human) and result in more enjoyable games while also scaling their intelligence level.

Reply #38 Top

Reposted from https://forums.elementalgame.com/400279

I assume this has not changed yet... But was noticed on the last production 1.09 version.

"Brad,  you wanted CHEESE, here is my cheese.

The current AI is flawed in that it does not react to the following situation.

AI 'X' decides I'm a good target and attacks my newest outpost, while I may be weaker ATM I used summoned creatures and magic to break the AI's assault and then immediately follow up with a counter assault of my own which steamrolls the AI all the way back to its Capital.  My analysis is that the AI is not capable in its present state to adapt its supply line of fresh troops allowing me to pick them off 1-3 at a time before they can consolidate and become a serious threat.

That was problem #1, problem #2 is that the AI Sov seems against common sense to refuse to defend its capital and the Sov's stack tends to be the last significant threat once war breaks out and I have broken its offensive and rolled it back to its capital. 

Combined, these are the two flaws that make the Hardest AI setting to be a cakewalk imho ... "

This is probably fine AI behavior on lower difficluty settings but is not very satisfying nor challenging at the upper AI difficulty settings...

Reposted again here in hopes it will get noticed and addressed.

Reply #39 Top

1) The only enemy spellcaster seems to be the sovereign.  They should cast imbue champion on at least a few of their heroes.

2) They seem to have trouble stacking their units.  A couple of times I have picked off large groups of enemies because instead of being in a single stack, they were in a bunch of small groups even if they were in the same tile.

3) If they lose all their cities but their sovereign is still alive, they don't do anything.  The sovereign will wander around the borders of your territory until killed off 100 seasons later by a different AI player.  You should make it possible for a sovereign with their city destroyed/captured to found a new one; or go about killing monsters, level up, and then conquer a weakly defended city.

 

A few more problems:

Too many pioneers (mentioned many times already)

If my power rating is even slightly below the power of the AI they will demand gold with amazing frequency, this gets very annoying after a while.

The AI seems to target random people in my army in tactical battles (doesn't happen with monsters).  I may be going around with 5 heroes and for some reason they will try to attack the one that is sitting around at the far back and get killed in the process.

The damage done in tactical battles has some bugs- i can hit 26's all day with my bows against people with 10 hp and they won't die/ only take damage 1/3 of the time or won't ever be hit by ranged. It seems very random and it is hard to tell if it is doing anything.

Some of the spells are bugged- mentioned in the support forums.

Reply #40 Top

You mean that there is a place in the options that I could select to activate the download of BETA patch? You see, I a trying to lead a modding team, and if I do not have the most recent version, well I am like behind everybody.
End of quote

Yes there is Click on the menu icon to the left of the Explore tab in impulse. You will see a tickbox labeled "Show pre-release versions", tick that and refresh impulse.

 

 

Reply #41 Top

Quoting larienna, reply 26

1. The AI declares war long before it is prepared or able to attack me. This gives me time to prepare a defense or to just attack them first.


That is something I found annoying in many 4x game. They declare war on you because of bad diplomatic situation. You prepare yourself to go to war, and then 50 turns later when you are bout to invade, they want to make peace because nothing happened between you too.

If an AI declares war, he should be prepared to invade.  It might not be the best preparations, but at least have some people available to attack.

 


That is because it is a BETA, If you want to downloaded it (be warned it is a BETA and so prone to crashes and issues), you need to tick so prerelease versions in Impulse.


You mean that there is a place in the options that I could select to activate the download of BETA patch? You see, I a trying to lead a modding team, and if I do not have the most recent version, well I am like behind everybody.
End of larienna's quote

Yea, this is a challenge in every 4X I've played and coded on.

In GalCiv, this is solved by having the AI go into "pre war" mode where it starts to move units to a targeted enemy.

I've begun implementing this into Elemental. It's a lengthy process because you're moving away from reactive AI to multi-turn planning AI which is a lot more complex.  It's much more fun for me but can only realistically be done (by me anyway) if I'm allowed to focus just on AI for several days at a time without interuption.

So this week, I'm getting to spend time doing nothing but Elemental AI which has been amazingly enjoyable and I hope you guys are able to really tell the difference in the next update.

Reply #42 Top

1.  Aggressive AI settlements:  In my last game, an AI swooped in and settled my two new food resources that I spawned with adventure tech.  It also created a choke hold that separated my kingdom in half.  

This would have been a brilliant move except for two reasons.

A.  The AI was much weaker then me.  I was happy to let it exist, but this gave me no choice but to attack and destroy it.

B.  It was not prepared to defend either its new city nor its closest border city.

In that game, I took both his new city and the border one in the next few turns, both of which were basically undefended. 

Enhancement, only settle aggressively if the AI is prepared for war, and has a localized troop advantage.

 

2.  Tactical battles with ranged support.

If AI has ranged advantage, then its melee units should wait in guard mode, preferably moving to terrain advantage squares, and also maneuver for first strike.  Since, the other side is obligated to rush, then you can just put your troops just out of movement range.

 

3.  Settle placement.  Have the AI make sure they don't place settlements that are too far away to protect.  In the last game, the AI had a settlement that was close to its capital in bird's eye distance, but was cutoff by water.  This made the actual route quite distant, and was cutoff by other factions.  This city was the first to fall.

 

Reply #43 Top

Quoting Frogboy, reply 41

So this week, I'm getting to spend time doing nothing but Elemental AI which has been amazingly enjoyable and I hope you guys are able to really tell the difference in the next update.
End of Frogboy's quote

Thanks. I hadn't played a Stardock game until GalCiv2 and was super impressed with Stardock's AI. Can't wait to see that level of AI challenge here too.

Reply #44 Top

I think I'm repeating, but these are the issues I see:

 

AI does not expand effectively early. If I find a nearby AI in the early turns of the game, I can usually drop an outpost and pen them in. Rather than view this as a hostile act (I would), they simply sit there and stagnate. If left to their own devices, they often expand beyond their ability to support, and sometimes completely miss crucial resources. Last game I claimed a fertile land with a gold mine and an earth shard in proximity after the AI's pioneer walked right passed it to settle another patch of fertile land with no other resources, in a totally indefensible position.

 

AI is a warmonger. As soon as it has a slight faction power advantage (even if this does not translate into an actual functional advantage) it starts getting belligerent, and is not usually prepared to actually wage a war once it declares one. Whenever an AI declares on me, I immediately preemptive strike (usually following the road they built to my kingdom) and have them on their heels in short order. It usually builds tons of so-so single troopers while I have a stack of heroes and a few parties of mid-level troops and I just wipe them out.

 

AI has no tactical sense. Archers shoot, casters cast, everything else runs. It's easy to pick off their ranged elements with your own, then soften up their melee stuff and maneuver so that they give you the first hit. So long as it's a good one, they don't get to hit back. I often forgo armor completely in favor of cheap, massed offense.

Reply #45 Top

1) The AI does not appear to give a priority to defending it's children or spouses in war time, I seem to often be attacking a son or daughter who is wandering between cities undefended or finding a spouse armed only with a spear defending a town.

 

Reply #46 Top

Quoting wraithstalke, reply 45
1) The AI does not appear to give a priority to defending it's children or spouses in war time, I seem to often be attacking a son or daughter who is wandering between cities undefended or finding a spouse armed only with a spear defending a town.

 
End of wraithstalke's quote

 

Yeah. When attacking capitals I usually find the king has run away with his tail between his legs and left his wife to defend the city.

Reply #47 Top

So this thread only managed two pages? After all the complaints about the AI i expected more.

Reply #48 Top

Quoting Lonemessiah, reply 47
So this thread only managed two pages? After all the complaints about the AI i expected more.
End of Lonemessiah's quote

 

The problem, I think, is that currently there isn't much AI to be discussed in the first place. The same question should be asked repeatedly after Brad includes his new AI code variants into the new patches.

Reply #49 Top

There aren't many complaints because it was announced ahead of time that the AI improvements weren't planned for this patch.  Also, there are a bunch of bugs to be worked out also.

 

This game still needs a LOT of work, to be fair and honest, but if it gets what is needed (and I believe Stardock will get it done)- then you have a near-classic on your hands (and expansions could push it into that area, though more likely it will be a "lost classic" that gets discovered around 2016 or so, then some "silly upstart company" in the 2020s will be trying to make a spiritual successor to Elemental.  ^_^)

 

Pre-War AI is a necessity.  One issue I've seen with AI's, in addition to that, is after they conquer the first city, do they know what they want to do next?

Reply #50 Top

1) I have noticed that the AI does not always go after level 0 goods on the ground even when their Hero is standing right next to them for a couple turns never moving waiting for orders.

 

2)I see the computer holding golem summon tokens and never using them in their inventory.