Frogboy Frogboy

It is time for your destruction to begin

It is time for your destruction to begin

T_Pandemonium_PaintingWe have promised, many times, that Fallen Enchantress will be so bad that it’ll give you some sort of disease.

It is now time to pay up.

For today, the tactical battle AI begins its development.  And my job is to kill you. Thousands and thousands of times.  Meanwhile, you’ll be trying to kill the AI in tactical battle with your various tricks. They will avail you to naught. You humans and your armies will be destroyed. Your kingdoms crushed. There will be much farting in general directions.

For the past several months, I’ve been asking my diabolical cohort Charles to write me tons of little functions that I could eventually use to build up the tactical AI.  While I worked on the main game and the strategic AI, Charles did put together a decent tactical AI with what he had. 

Unlike the strategic map where the AI can’t see all, the tactical map AI has no such problem. All units can see each other.  The odds are even.  There’s no reloading your game in the middle of a battle. It’s just you and the AI.

So for the next couple of months, we’re going to get to know each other.  You will beat the AI a lot at first. And hopefully, you’ll share your secrets. From those secrets I will ask for new APIs and new XML that will help.  I still have a lot of data requests (I don’t know how many turns have taken place in a given battle so I have no concept of whether we just started the battle or are nearing its end, I don’t yet have access to what spells are good and what spells aren’t – but I will soon).

I will have to solve the AI’s terrible use of mana strategically so that it has mana left over to do horrible…horrible things to you guys.  I will also probably ask for a lot of new tactical spells that the AI is more inclined to use effectively (I got a few cool new strategic spell requests that are being put in that are…simply ridiculously evil).

So to start this conversation, let’s look at some of the things the AI needs to think about:

  1. What is the balance of power in ranged units?
  2. Should I attack the closest unit or bypass that unit to go after a more vulnerable unit
  3. How important is vulnerablity? No point casting a fire dart at a fire elemental but should I spend a day coding about blunt weapons versus cutting weapons? (remember: time is a finite resource, I don’t get a year to write this, just N engineering hours).
  4. Should I cast a spell? Right now, the AI wastes magic when it shouldn’t (because it rolls the dice rather than calculating it).  No point in using burning hands if I can kill you with a sword almost as well.

This is going to take awhile and it won’t be in the first BETA 2 build.  Or if it is, it won’t be much better than what is currently there.  But together, we should be able to come up with something pretty lethal.

205,056 views 91 replies
Reply #76 Top

With all respect, annoyance is having to read about all these new cool things you're doing without being able to play them.

 

Reply #77 Top

Quoting Frogboy, reply 68

Let me give you the #1 weakness of the AI in your build of the game: Path finding.  Something that trivial. I have to play all kinds of games with the code to make sure that it doesn't have to spend very much time doing path finding to get to your cities. That's because path finding can take a long time when you're dealing with units that are far away.

Really?

 

Has this been fixed, I noticed that you said some of the bugs with it were.

I can recommend a number of excellent methods for this, and a few personally modified pathing algorithms if you want.  Heuristics are fun!  Er..

 

Not sure what you're using now, but AD* or Anytime Dynamic A*, could be a good answer for you considering you might be working with time limits.  It's very efficient with dynamic states and can be work quite quickly to develop an initial sub-optimal path when time is limited.

Reply #78 Top

I wonder if your AI can be my patented Mantle of Fire Spearmen. Plate+MantleofFire+Spear=UnstoppableForce   :grin:

Reply #79 Top

Here's an auto battle (i.e. I just hit auto):

http://screencast.com/t/pxLeoMVX

Reply #80 Top

Quoting Frogboy, reply 79
Here's an auto battle (i.e. I just hit auto):

http://screencast.com/t/pxLeoMVX[/quote]

Very nice use of tactical spells, I love how he cast haste first so he could cast again right away. Also the use of slow against a melee hero when you have ranged units is very nice.

That said why did the player with the archers run to the other guy when they had such a range advantage? They should have run away and pelted him with arrows from afar. Absolutely no reason to engage him in melee.

Reply #81 Top

Quoting Frogboy, reply 74

Quoting StevenAus, reply 73Does that mean upgrading regular units will be cost efficient in the next version , or just that the AI with bonuses will do it more often?

Yes, we are having to substantially lower that cost.

NICE! Thank you =)

Reply #82 Top

I am a little worried that the computer figured out my haste-slow combo.   :S

Reply #83 Top

My combat options are determined like this;

Step 1 - Rank the enemy units by threat (How much damage they can do to any of my units that will be in range when they get an action).

Step 2 - Can the current unit kill the highest Ranked enemy?

     Loop through the whole threat list until I get a yes or get to the end.  If I get a Yes, kill that unit.

Step 3 - Can the current unit cast an AoE spell? - AoE them.

Step 4 - Can the current unit buff my best unit or debuff their best unit? - Haste is King.

Step 5 - Can the current unit survive a hit from every enemy unit? - If Yes - Do as much damage to the highest Ranked enemy.

Step 6 - Hide behind the rest of my army.

 

I play with mostly Champions so my list is geared towards them.

Reply #84 Top

Quoting DsRaider, reply 80

That said why did the player with the archers run to the other guy when they had such a range advantage? They should have run away and pelted him with arrows from afar. Absolutely no reason to engage him in melee.

 

The hasted hero came out to protect the archers from being attacked and kept them away from the front line.  It was well executed.

 

Actually, with a simple 'attack of opportunity' system, you could ensure that this tactic works well, by adding the cost to the AI (player) for any attempt to move out of/past a melee.

Reply #85 Top

Yes, I agree with "attacks of opportunity" if units try to simply move past melee units (while being adjacent to them).

That plus zone of control allowing them to only move 1 tile per turn when adjacent ... would give the defender at least 1 attack of opportunity, and many times 2 (if having a line of defenders) per enemy unit attempting to move past the melee.

 

Of course, this system would work even if melee units could only move 1 tile per turn.

It would be interesting to play with. Another thing to play with would be to have all non-mounted units fixed at 2 movement, while Mounted units are fixed at 3 movement and start with roughly 50% more initiative.

I think the in-house testers should try out the idea in bold :)  (possibly combined with attacks of opportunity of course ;) - that is, disengaging from a melee)

Reply #86 Top

Well, I'm sure it has been mentioned here previously, but I'd like to add my support to/flesh out a bit the idea of different goals for tactical AI based on who is fighting whom and where.

For example, "AI faction" players should go more for strategic objectives than for immediate tactical advantage. The reasoning process would take into account:

  • the general war strategy - attrition strategy means we go for killing off the maximum number of whole units; partisan means we do a hit and run so the player is generally spread thin with a lot of units (high upkeep) with damaged health (low effectiveness); conservative doctrine means we first and foremost limit damage to our units and retreat rather than sacrifice them for victory; decisive battle doctrine means we pull out all the stops to win the battle even though it might mean trouble afterwards; assassin strategy means the battle is weighted towards killing high-level heroes; human wave strategy means we go for maximum damage output irrespectively of losses in order to mop up with second stack, or third stack...; tactical optimization strategy means we concentrate on saving the most of our units while still going after a win or retreating in face of overwhelming odds. Etc.
  • mana consumption limits - what can we afford and what we can't, and how valuable mana versus our units' hitpoints is (do we cast that fire bolt for 10 mana in order to save 2-4 hp of our swordsmen?).
  • are there any strategically important units in the battle? Heroes (almost a no-brainer...), rare elite units (if the opponent uses a strategy of few elite units protecting a mass of low-cost glass cannons), cavalry (if the opponent's kingdom is large and he has some logistical problems already then being able to quickly relocate your army stacks can be important), very experienced troops (replacing them would be hard for the opponent, while allowing them to live on and advance higher still would be dangerous for us), units specifically tailored to match our faction strengths and exploit our weaknesses, pioneers who might in a moment establish a city in our backyard etc. If there are such important units, then weigh the battle towards protecting yours and killing off theirs. And then the next battle would be presumably easier.
  • Do we have a specific objective for the battle, like "weaken this stack enough so it cannot threaten our nearby cities" or "kill off this scout before he learns that we're overextended here and here" or "mop up our backyard so our resources and outposts are safe and we can get back to the actual front" or "We need to live to fight another day, since this is a harassment stack sent here to distract the enemy and absorb a part his forces while they chase us honoring the threat"?
  • AI personality - ruthless warmongers will go for a kill more, while crafty pacifists (heh) will more often retreat and delay.
  • Faction resources - do our gold, resources and building capabilities allow us to outbuild the enemy (so we prefer a brute force approach to battles, as a modifier to our grand strategy), or perhaps it is the other way around (so we prefer to save our units while conducting an elastic defence and possibly wrecking the enemy's economic base to even the odds).
  • Do we need to take this city now at all cost or risk that it falls to another enemy of our enemy (enemy of my enemy is not always and forever my friend) or just weaken it for another pass with our reinforcements? Or perhaps we actually should fake the war while we amass a steamrolling force because this guy actually fights another of our enemies and is doing not so well (which calls for a tactic to actually do LEAST damage and retreat orderly or allow the enemy to retreat unharassed)?

When all of this and more is taken into account, then a general tactic can be chosen for the battle and unit "importance" weights assigned (including flags of "absolute" goals like "this unit cannot die, period." or "this unit must die even if it costs us dearly").

On the other hand, monsters (and ruffians :)) would not be concerned with such things at all. They would simply want one of three things:

  • wreak havoc and make mayhem - go for maximum damage output (monsters and raiding parties).
  • protect their territory - go for tactical optimization (everyone protecting their turf).
  • make trouble and vanish - go for a win unless it is costly, in which case go partisan. As I remember those guys grow in strength over time so it is quite a valid strategy (ruffians but not monsters).

When we have the stage set up, then Brad can work his magic on the units and make them execute the chosen tactics. Smartly and of course calculating all those little odds and ends which bog down the mind (vulnerabilities, zones of control, attack types, ranges, spell choices, etc. etc.).

Hope it helps someone, somewhat. :)

Reply #87 Top

If only one type of combat AI can be made, I'd say it should be faction AI for all. However, I would welcome various combat AIs.

Reply #88 Top


Something I haven't seen other people mention.. and it might be slightly getting ahead of things, but.. if you do come up with an excellent AI, keep a little bit of randomness. Don't always use the optimal tactic. Often, a little bit of unpredictability is a better tactical advantage than taking the obviously best path. You don't want your players to think that they've figured out all your AI's moves and use that knowledge to manipulate it into favorable tactical scenerios. Not only would it make the AI weaker, but also the game more boring.

Reply #89 Top

I think there was some talk of mixing up the AI's 'main priority' ever so often.

Reply #90 Top


Some things I have noticed about the tactical AI in 0.86

-It deosn't seem to like casting damage spells, ie dragons and shrills dont use shock, ember or fire breath.

-For mixed melee caster units like shrills it doesn't cast and charge at the same time. There is no reason shrills for instance can't slow and move towards you on the same turn.

Reply #91 Top


The only offensive monster spells I have seen cast is Barbs by a troll shaman...  Never had a dragon breathe fire at me.  I do get dazed from hoarder spiders.