AI vs. Tar Froglar Games: Episode 2

Lots of changes have been put in the past day while I wait in my SWTOR queue (Kaas City, character: Talax, Sith Marauder)…

Anyway…

These are a series of 1 on 1 battles.  When the AI is sufficiently challenging on Normal, I’ll test our the harder difficulties and then go to multiple players.

Sufficiently challenging means being able to survive 100 turns consistently against me on a small map.

Game 40: 11:30am, 12.28.11

image

Result:Victory in 96 turns. Nothing very interesting. Fixed some AI glitches, nerfed constitution bonuses.

Game 41:

image

Wow. Started with two champions near, green valley with a river.

Unfortunately, monsters killed the NPC. That’s a problem. Will have to fix monster AI since that kind of defeats the purpose.

Aborted to fix.

Game 42:

image

Found a second champion near by that only required “recruiting” to get. So I b-lined to that.

Foolishly went on a dangerous quest (really need these quests to have labels as I got my clock cleaned).

Heh, found a bug with the Administrator ability which, presently, reduces 25% from training/construction.  It stacks.

image

Everything in 1 turn.  I’ll fix it…after this game…

image

AI is starting to get pretty good at putting together defenses while expanding.

Now to see if I can still steam roll him. Note all the archers. Standing there waiting isn’t an option.

Tactical test

image

Well not quite a steam roll. Took multiple armies led by champions but the deed is done.  That took 360 turns.

Will do one more to see if it was a fluke.

Game 43:

This time I’m playing as Kir-Talax (character I made up) who is Emperor of Magnar. Let’s see how I do as an Empire.

image

Found Altar fast this time and took his first expansion city.

Relias is pissed. He came right at me.

image

My sovereign and champion are really weak having just lost a battle to a spider related quest. This may be closer than it seems.

Hmm.

image

Way closer than it seems. This is where computers have an advantage, they can calculate their odds of victory better than us.

image

I do have some pretty decent spells and armor early on.

Rematch…

image

This time he bit off more than he could chew.

Time to go for his capital…

image

Little pigs, little pigs, let me come in. It’s just me and my apprentice.

image

Casting time…this is how we were able to have really powerful magical spells without debalancing the game completely.

Casting a fireball

The town is mine but only after losing my Apprentice.

image

After some back and forth, we’re down to his last town. There is an issue with champions dying too often still.

image

Curse spell in what might be the final battle.

But I lose. Sad smile

On the other hand, there’s something…right about building a Slave Pen in Athica (former capital of Altar).

Lots of very close back and forth for that last city.

I recruit a new apprentice…

image

Hopefully this time I’ll kill him.

image

In this game, the big problem the AI is having is he’s now outclassed in weaponry and armor. It’ll be interesting to see the tech difference after this game.

In Fallen Enchantress, metal is a big deal. It’s out there, it’s not “rare” but you gotta have it to build the good stuff.

image

image

Yea, that sucker punching him early on did him in. But he held on really well. I’d say it’s time to turn up the juice to…Challenging level AI.

But not until I do some tweaking. Gonna had some new functions for handling sucker punching and delivering them. Winking smile

My score: 28 points.

Game 44: 6:30pm CHALLENGING AI

So I’m pumping the computer AI to “challenging”. At this level, he’s identical to the human player still except there’s a few more APIs that get used (a little more CPU gets used).  Those APIs largely revolve around recruiting champions more aggressively and more intelligently handling quests. In the XML, these algorithms are based on  <AIIntelligenceFactor>1.5</AIIntelligenceFactor> which is my own voodoo I use to determine what functions I’ll use.  Go over 1.5 and it might include cheats so for future modders, never go over 1.5 if you don’t want the AI to potentially be “Cheating” (where cheating would include an imbalanced map, getting champions placed in slightly closer to AI starting locations, etc.).

Now, keep in mind that this doesn’t mean the AI is “done”. I’m focusing on algorithms but a lot of the XML isn’t even hooked up.  I can’t, for example, really have the AI use spells intelligently yet. When you see Relias hasting himself and others you’ll know it’s starting to get better in that area.

We’ll see how many turns it takes me to win.

image

 

image

Relias must be nearby as he found me (he doesn’t know I’m here, just got lucky).

image

Fun vs. Bastard: The AI could totally wreck me. My sovereign is out exploring and his champion and armed units is 2 tiles away from my capital. This is the kind of thing that game AI coding has to take into account.  Post-release, I can do what I did with GalCiv and let modders add in “Bastard AI” but there’s no way I’ll get to it prior to release. Or probably not anyway. And besides, would that be fun? Most people would just reload the game. What’s the point?

It isn’t until turn 125 that I feel confident in attacking him with 2 high level champions and my sovereign as my main force.

image

This could be interesting.  We win, but only my sovereign survives. The champions do survive too (they’re revived) but they’re now injured.

Nevertheless I take my army to Relias.

image

Relias casts Haste. Yay, good sign. It’s looking like it’ll just be he and I by the time we kill off all of each other’s units.

image

Victory in 160 turns.

Score: 18.

You can see where the AI is blowing it in this graph. Ridiculously sloppy use of magic means that when he needs it, he doesn’t have it.

Time to tweak.

That’s all for tonight. Winking smile

50,691 views 52 replies
Reply #1 Top

You have no idea how much I love this stuff, thank ya sir

 

Reply #2 Top

Glad you're spending so much time on improving the AI.

Reply #3 Top

Wow thanks.

 

Reply #4 Top

Yes. Very interesting to see the process. :)

Reply #5 Top

With regards the video, will there be any zones of control on the Tactical Battle map to stop the horsemen breaking past so easily? It appears they could just waltz past without an issue. Having at least a movement/initiative penalty would be good to force players to play formations. Even better would be adjacency bonuses etc.

Reply #6 Top


Cool.

Reply #7 Top

Why is the AI sovereign almost never with his army? You seem to win most the time because you kill his army and sovereign separately.

Reply #8 Top

DsRaider - that remains a problem. Without explicitly scripting it, it can be difficult to get the AI to require subunits just for the sake of having them.  When I'm losing, I am often doing most of my action with just my sovereign since he's my most powerful unit.

Reply #9 Top

I admit to no real knowledge of AI programming but maybe the problem is in the weighting of the power of sovereigns and champions. I imagine magic is hard for AIs to calculate for and predict. With the sovereigns and champions being as powerful as they are the AI is effectively splitting its army if it doesn't have them together, so why is it doing that?

Perhaps when defending against other players the AI needs to play it safer by checking to see if there are possible reinforcements if there is a fair chance of it losing.  When it sees a hostile army instead of just calculating if it has a good chance of winning maybe it should try to maximize its chances by avoiding battle in order to bring in reinforcements, if they exist, like its sovereign. Even if it loses a city it could take it back once it masses, but if it loses its army piecemeal then it's game over. Defending cities to the death might sound like a good plan but really it is the army that you can't afford to lose.

I understand how complex these things can get so I apologize if the AI already does this or if I'm spouting random nonsense.

Reply #10 Top

"(2) AI is too timid to send a major force around my strong point (I don’t have a choke hold) to attack my vulnerable rear city (I have a weak city and a strong city but the strong city is relatively close to their capital and they’re not sending units to attack the weak city because that would leave the capital city potentially vulnerable"

 

anyway for them to treat the sov like they do the capitol? (don't know if this will work, but seems to be sorta the desired result), I figure the only difference would be the sov is mobile, but I would think at least as important as the capitol they protect so well

Reply #11 Top

The challenge is always getting it to perform well without actually scripting. You don't want an IF <specific dondition> THEN <specific action> otherwise it'll fall apart if we mod it or if the values change or the gameplay changes.

The other thing you don't see here is that there aren't a lot of units. These are small maps where even I'm running around alone at times.

Most of the time, the AI does have other units with it.

Reply #12 Top

The big problem it's really having is effective use of magic. There's a lot of coding to be done still in the tactical battle arena.

And when that gets done, there's diplomacy and better use of research.

Reply #13 Top

Quoting Das123, reply 5
With regards the video, will there be any zones of control on the Tactical Battle map to stop the horsemen breaking past so easily? It appears they could just waltz past without an issue. Having at least a movement/initiative penalty would be good to force players to play formations. Even better would be adjacency bonuses etc.

The way I see it, mounted units should have an advantage on the turn they plow into a fray (perhaps via a 'charge' ability of some sort), but once they're in melee (within 2 or 3 tiles of a melee unit) they should be quite a bit less useful, having a significantly low initiative due to the difficulty of maneuvering in that situation.

Reply #14 Top

Very good stuff. It's nice to see the thought process going on with the AI development.

Also, the game looks cool and I love the tactical combat animations. It looks very similar to MoM. :grin:

 

Reply #15 Top

Anyway thanks for responding Frogboy. I appreciate it.

.

Reply #16 Top

I love this stuff!!!   This is absolutely my favorite part of following Stardock games, is to see the game evolve in terms of what the AI can do.  I know that good AI is not the most popular thing in the industry, but it is what will get my $$$ everytime.

 

Brad, thanks for sharing the "sausage factory" with us.

Reply #17 Top

The AI could totally wreck me. My sovereign is out exploring and his champion and armed units is 2 tiles away from my capital. This is the kind of thing that game AI coding has to take into account.  Post-release, I can do what I did with GalCiv and let modders add in “Bastard AI” but there’s no way I’ll get to it prior to release. Or probably not anyway. And besides, would that be fun? Most people would just reload the game. What’s the point?

Sorry if I'm misunderstanding, but are you saying you don't want the AI to capitalize on that situation because the player will just reload from the last save?

That seems like a problem if the AI doesn't capitalize on that.  The point isn't simply to defeat the player, but to teach the player that they need to defend in the future.  If the AI never takes advantage of a lack of defenses, then the player quickly learns that he doesn't need to defend.  The AI, however, will always need to defend because the human player is always a bastard!  Forcing the AI to defend while the human doesn't have to effectively hands the AI a big penalty right out of the gate.

 

Reply #18 Top

cheating would include an imbalanced map, getting champions placed in slightly closer to AI starting locations, etc.

For what it's worth, I love this type of "non-cheat" cheat - have the AI still play by the exact same rules, but simply give it a bonus of circumstance.  I've been playing Distant Worlds lately, and you can give the AI a leg-up by simply giving them a better starting situation.  It's still playing by the same rules, so the player never feels like they're being cheated.

For difficultly levels, I would love the following:

  1. No cheating, no improved starting circumstances
  2. No cheating, no improved starting circumstances, but uses as much CPU time as necessary
  3. No cheating, improved starting circumstances, uses as much CPU time as necessary
  4. Cheating, improved starting circumstances, uses as much CPU time as necessary

 

Reply #19 Top

Programming question for you Brad regarding the tactical AI:

Given the turn based nature of FE, would it be a possibility (in theory, I know you can't rework everything at this point) to adopt a more brutish, chess-like approach for the AI?

Where the AI literally builds a tree of all possible outcomes for (let's say) 3 turns in advance and then selects the best move based off difficulty mode and perhaps some randomization?

Reply #20 Top

I can answer that one for you, TheProgress.

Short answer: No, it would not be possible.

Longer answer: A typical situation in chess sees a very limited amount of possible moves. For instance, in the beginning of the game, both sides have 20 possible moves. After both have moved, we have 400 outcomes. After second move, we move up to about 200 000. Counting three turns ahead would come somewhere around 100 million. That's quite possible to calculate with modern computers. Just a single move forward would add at least 400 times more outcomes (that would assume only 20 possible moves, which is no longer the case).

With FE, the amount of moves that can be done within a single turn is rather large. Not just moving troops and casting spells, but adjusting build queues, taxes, diplomatic relations. For the sake of simplicity, let's take only army movements into account. Let's assume 10 possible hexes to move to.

If I have 1 stack: 10 possible outcomes

If I have 2 stacks: 10 * 10 = 100 possible outcomes.

If I have 3 stacks: 10 * 10 * 10 = 1000 possible outcomes.

If I have 10 stacks: 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 = 10000000000 possible outcomes.

Now take that final figure, multiply it by the same figure as many times as you have empires active and that's predicting just the movement for a single turn.

That's why it's not possible to do it like chess.

Reply #21 Top

Tar Froglar should take on Lardy Porcupine and Kool-Aid Khan at the same time!

Reply #22 Top

@Vakky751, I realize that the number of available moves is still quite large, but I was actually talking about the tactical map, not the strategic map.

 

Reply #23 Top

Does the AI always follow the same strategy for expansion, research and production?

Reply #24 Top

Quoting Edwin99, reply 23
Does the AI always follow the same strategy for expansion, research and production?

No. That would require scripting.

The AI's I make are different than the standard way of making computer game AI.  Most games rely on scripts of various kinds. Look for a condition (trigger) and perform a script.

My AI's instead are designed to evaluate data and then generate their own reactionary based strategy.  Often times, gameplay exploits are found by the AI before players ever learn of them.

Reply #25 Top

Quoting TheProgress, reply 19
Programming question for you Brad regarding the tactical AI:

Given the turn based nature of FE, would it be a possibility (in theory, I know you can't rework everything at this point) to adopt a more brutish, chess-like approach for the AI?

Where the AI literally builds a tree of all possible outcomes for (let's say) 3 turns in advance and then selects the best move based off difficulty mode and perhaps some randomization?

The GalCiv AI does what you describe to a limited degree.  In effect, it "plays" the game in a background thread and then uses the results to determine what it should do. It's the equivalent of playing the game out 2 turns and then loading their saved game.  FE doesn't currently do this because the decision tree is insane and so unpredictable.

So far, the biggest temptation I've had is having the monsters not attack AI players. The AI could get a huge advantage if the monsters simply didn't squash them so often. That's the big unknown that players (AI and humans) run into.  Unlike in GalCiv or WOM, the monster world itself is effectively its own player.