The Forums Are Now Closed!

The content will remain as a historical reference, thank you.

Fallen Enchantress: Tactical Battles - Part 1

AI Talk

By on October 3, 2011 1:45:16 PM from JoeUser Forums JoeUser Forums

image

As some of you know, I’ve never written tactical battle AI before.  Galactic Civilizations and Stardock’s other games didn’t have tactical battles. War of Magic had tactical battles but I wasn’t involved in that portion of the game.

This series of journals will take you through the journey of how to write AI for tactical battles.  In my experience, games have tended to have pretty crummy AI when it comes to tactical battles (War of Magic no exception).

 

Preliminaries

So for starters, I’ve got help.  Seasoned developer Charles Lentz, who has been at Stardock for some years now, is assisting me on this project.  The first thing I asked him to do is make it easy for me to do mock battles.  When I was working on War of Magic v1.4, which was the first build I even got to look at how tactical battles were done, I noticed that there was no way for me to conduct mock battles.  I’d have to “get lucky” and find an AI player who could cast spells to see if it even worked which was time consuming.

So for Fallen Enchantress, I asked Charles to set up a cheat key that would create opposing armies and that it would read from an XML file that I could mod to decide what powers those units would have.  That way, I could test out all kinds of combinations.

Counter-Spells

Since I come from the modding world, I prefer to have my games let me, the player, mod as much as possible.  My AIs have not been very moddable in the past because, frankly, the coding necessary was far outside my area of expertise (i.e. making it read variables and data from external XML files rather than just hard coding it in C++).  But with Fallen Enchantress, Charles is going to take care of that for me.

So one of the things I intend to do is stuff as much data as I can in XML files.  I want to be able to have the AI gather as much data as it can about who it opposes and then look at the XML data to help it decide what to do.

That means I want to make it so that every spell, ability, weapon, etc. in the game has in its XML AI data that I (or others) can mod with good things to go against it.

Does the enemy side have a spell that rains down a fire storm on me? Then I want that spell to include in its XML what spells are good counters to it. Then,  the player comes in with his fire mage and the enemy casts a frost shield on her first turn. 

Moreover, this gives me the excuse to request the UI team to let both sides see what spells/abilities each other have easily because a good tactical battle, in my opinion, should be a real battle of wits making use of terrain, spells, counter-spells, and maneuver. And the more data the player gets to see, the more data I can let the AI see without “cheating”.

+912 Karma | 119 Replies
October 3, 2011 2:02:08 PM from Elemental Forums Elemental Forums

You know, we don't need Deep Blue level of AI skill in Tech battles, would just be fun if the AI used it's abilities and they did something other then pick one guy and chase the hell out of him.  I think some basic tactical battle concepts would have helped WoM, like true ZoC meaning it's difficult to run around units, limited range on spells and bows, flanking, and meaningful terrain.  It has to be hard to really write good AI without those basics in place, I would think.

October 3, 2011 2:12:27 PM from Elemental Forums Elemental Forums

Quoting Lord Xia,
You know, we don't need Deep Blue level of AI skill in Tech battles, would just be fun if the AI used it's abilities and they did something other then pick one guy and chase the hell out of him.  I think some basic tactical battle concepts would have helped WoM, like true ZoC meaning it's difficult to run around units, limited range on spells and bows, flanking, and meaningful terrain.  It has to be hard to really write good AI without those basics in place, I would think.

 

I second this, we need more battle concepts in our tactical battles.

Also note that if you wish to have truly modable AI you must have the logic code modable/scriptable in an XML. I have played with far too many modable games to know that by adjusting weight values or changing priorities you can't really change/improve/fix an AI.

October 3, 2011 2:14:48 PM from Elemental Forums Elemental Forums

Sound great. Now tell us how the battles in FE will work...are any of the features Lord Xia mentioned included? Zoc and flanking would be great, range on spells are already in WOM, but different ranges on bows would be a step forward, and maybe spears could have a range of 2 etc. Add terrain features that makes sense (archers on hills!) and we would have a REALLY interesting game combat wise...

And thanks for sharing Frogboy, looking forward to future posts.

 

Tomas

October 3, 2011 2:15:50 PM from Elemental Forums Elemental Forums

Cool! Small but interesting update. I'm really looking forward to seeing more of this, since tactical combat is one of the main areas that FE seeks to improve.

 

Xia, I would argue that those features would make for a more compelling tactical combat experience, but they are in fact additions that would make the combat more complicated, and thus more difficult for the AI to play. I would love to see all of those things, and maybe someday we will get some of them. For now, I would be happy with the first thing you mentioned. A tactical AI that can play the battles as they currently exist. Sounds like Brad is going after things that will make the existing systems fun, stuff like AIs that will use spells intelligently.That is enough of a challenge for now. If they can get all that right, then maybe the next game or expansion in the series can add further depth.

 

 

October 3, 2011 2:29:32 PM from Elemental Forums Elemental Forums



So for Fallen Enchantress, I asked Charles to set up a cheat key that would create opposing armies and that it would read from an XML file that I could mod to decide what powers those units would have. 

Can you please let us do that in multiplayer? It would be great fun to play quick custom battles online.

October 3, 2011 2:47:47 PM from Elemental Forums Elemental Forums

Opening Post:

So for Fallen Enchantress, I asked Charles to set up a cheat key that would create opposing armies and that it would read from an XML file that I could mod to decide what powers those units would have.

 

Posted by Magog_AoW:

Can you please let us do that in multiplayer? It would be great fun to play quick custom battles online.

Sounds like an idea for one of them 'Free to Play' games. And a good way for Stardocks studio to increase their exposure.

October 3, 2011 3:02:59 PM from Elemental Forums Elemental Forums

 And the more data the player gets to see, the more data I can let the AI see without “cheating”.

 

No body likes a cheater

October 3, 2011 3:22:48 PM from Elemental Forums Elemental Forums

I admittedly know absolutely nothing about making video games other than the info provided to us on these forums by Stardock. I just think that writing rules on how the computer does things would be easier in a better defined and structured environment.  I am a psychologist, so I am thinking about it as such, a behavior approach.  The less rules the AI has to follow, the less realistic and abnormal their behavior.  When you have a clear and defined structure in which the AI has to function, I would think that would make writing rules for it clearer. Strange paradox about behavior, is that some times when you create limits, you actually create choices. In WoM, there was no way to define a battle formation, everything has near unlimited range, so everything needs to be able to take damage and mitigate damage, so everything needs armor.  Flanking doesn't exist, and neither does true ZoC, and everything counterattacks, so movement and speed are fairly meaningless.  Terrain is all flat and meaningless, so tactics is pretty void.  In a game like that, how can you write any AI other than Shoot and Chase?  There are no other variables, so I would think that would make writing good AI almost impossible.  

 

Like I said, I think of it as some one trained in behavior, not computers.

October 3, 2011 4:20:19 PM from Elemental Forums Elemental Forums

This is the post we have been waiting for! Can you post some examples of your mock battles so we can see how tactical battles are different from WoM? How does magic countering work? Frost shield negates fire or does fire penetrate a frost shield, but a fire shield makes you immune?

Are you starting at magic for a specific reason or is it just first on the list?

How will magical resistance be seen by the AI? Will they avoid units with a high resistance?

Will enemy nations be able to make mages with unique magical tactics or will they just decide on one that makes the most sense with their resources?

What will the interface look like for spell casting?

How long do shields last? Will casting a shield need to be done every round by a single unit? That would mean having counter mages and attack mages in each battle. Will shields be AoE or target at a specific unit? Can a frost attack get through a frost shield? That would mean that a fire shard nation would be best countered by fire shards. Would air shield do anything different than frost?

Will every damage spell have a counter? Does a frost shield mitigate damage or prevent it from striking? Are protection spells counterable? Can they stack? Can more than one kind of shield be cast?

I am surprised everyone is talking about their personal wishlist and woes of WoM instead of asking critical questions about the content of this post. That is really a discussion for a different thread. The features are already decided on and are being polished. Now we need to talk about that content in a critical way. 

 

October 3, 2011 4:22:06 PM from Elemental Forums Elemental Forums

Xia, no offense but you don't know what does or does not exist in FE tactical battles. 

And even if you did, what you can and can't do in tactical battles does little to shape the general design structure of writing an AI.

October 3, 2011 4:30:22 PM from Elemental Forums Elemental Forums

Quoting Frogboy,
Xia, no offense but you don't know what does or does not exist in FE tactical battles. 

And even if you did, what you can and can't do in tactical battles does little to shape the general design structure of writing an AI.

 

Frogboy, no offense but is this how it is being coded at present or how you plan to code it? I remember reading the same thing before WOM was released and there was a thread not too long ago saying that modding was not going to be a priority at all for Fallen Enchantress. Has that changed? If it has, I am ecstatic, but I don't want to get my hopes up if it is something you guys "want" to do, instead of something that is being done right now.

October 3, 2011 4:33:44 PM from Elemental Forums Elemental Forums

You're right, I only know what existed in WoM, and that is what I was talking about.  But feel free to tell us what FE will have. And like I said, I don't know anything about writing AI.  I'm just a consumer.  Like with a pie, I may not know what goes in a good pie, how to bake it, but I know when one taste like shit.  

October 3, 2011 4:49:48 PM from Elemental Forums Elemental Forums

a good tactical battle, in my opinion, should be a real battle of wits making use of terrain, spells, counter-spells, and maneuver

 

Does this include the abitity to attack an opponent from behind on the map?  And have that translate into a rear attack (actually standing behind the opponent with first attack and a  + for surprise on the tactical map?  That could be very helpful if your outnumbered or would be overpowered in a direct attack. Or will all battles be face to face?

October 3, 2011 5:22:12 PM from Elemental Forums Elemental Forums

Quoting jshores,

Quoting Frogboy, reply 10Xia, no offense but you don't know what does or does not exist in FE tactical battles. 

And even if you did, what you can and can't do in tactical battles does little to shape the general design structure of writing an AI.


Frogboy, no offense but is this how it is being coded at present or how you plan to code it? I remember reading the same thing before WOM was released and there was a thread not too long ago saying that modding was not going to be a priority at all for Fallen Enchantress. Has that changed? If it has, I am ecstatic, but I don't want to get my hopes up if it is something you guys "want" to do, instead of something that is being done right now.

We're doing it this way not because modding is a priority but because it makes it a lot easier to write good AI.

For example:

In FE, it's initiative based, not turn based.  So on the left side you get a film strip of what's about to happen (who is about to move).  So a guy on a horse may appear multiple times on that film strip before you get to go.

Anyway, human player chooses to cast Deadly Blizzard which takes about 10 seconds to cast (not "real time" seconds but game seconds). Deadly Blizzard shows up on the film strip above a few other units who get to do their thing first.  One of those units is an AI unit who sees that a human caster is going through the motions to cast deadly blizzard and looks to see if he can counter it.  The Deadly Blizzard spell XML contains a list of suggested counter spells including Warming Aura and that spell is an "instant" (meaning it gets cast instantly) and reduces frost damage by 50%.

Now, without the XML, I'd have to go through the spells in C++ and try to figure out what is a good counter and that decision would be mine alone. Now, back when I wrote the AI and was also the design god, that was possible. But with FE, Derek is the design god so when he (or Toby or whomever) creates a spell they may want to come up with a counter spell too.  It makes it a lot quicker.

 

October 3, 2011 5:23:05 PM from Elemental Forums Elemental Forums

Quoting Lord Xia,
You're right, I only know what existed in WoM, and that is what I was talking about.  But feel free to tell us what FE will have. And like I said, I don't know anything about writing AI.  I'm just a consumer.  Like with a pie, I may not know what goes in a good pie, how to bake it, but I know when one taste like shit.  

Well you may want to wait until you've tasted said pie then.

This is a discussion of AI. If you want to talk about tactical battles feel free to use the forums to do that.  I won't be discussing how tactical battles work in general here, just how I'm going about writing AI.

October 3, 2011 5:32:56 PM from Elemental Forums Elemental Forums

Counter-spells sounds awesome... but you know what's even more awesome? AI using it!

October 3, 2011 5:36:40 PM from Elemental Forums Elemental Forums

Quoting Heavenfall,
Counter-spells sounds awesome... but you know what's even more awesome? AI using it!

Yep. That's the key.  

October 3, 2011 6:56:42 PM from Elemental Forums Elemental Forums

Quoting Frogboy,

Anyway, human player chooses to cast Deadly Blizzard which takes about 10 seconds to cast (not "real time" seconds but game seconds). Deadly Blizzard shows up on the film strip above a few other units who get to do their thing first.  One of those units is an AI unit who sees that a human caster is going through the motions to cast deadly blizzard and looks to see if he can counter it.  The Deadly Blizzard spell XML contains a list of suggested counter spells including Warming Aura and that spell is an "instant" (meaning it gets cast instantly) and reduces frost damage by 50%.
 

 

Wow...I had NO idea it was going to be like this. This...this is just awesome. Easily one of the most exciting tidbits we have gotten so far.

 

I rarely ever mess with magic in Fantasy games. I am almost always drawn towards more combative characters, warriors, paladins, etc. In WoM, I often create a Sov with no real magic ability whatsoever! But this...this sounds like so much fun that I am really excited to delve into magic in FE! If you can get the AI to use this system effectively, it will create some AMAZING battles! I can just picture the kick-ass mage duals that will result. While armies clash, two mages battle it out for supremacy with spells and counterspells...really, that is the kind of stuff that we were expecting from War of Magic.

 

Big thumbs up. Can't wait to hear more, and of course to see it in action.

 

How far along are you with the AI? I'm assuming not very far, since you just finished 1.4. However, if you are getting into the AI I would imagine that the rest of the game is getting closer to beta, since you previously said you didn't want to get into the AI much while the rest of the game was being worked on, which seems wise since the AI will in large part be based on what is in the rest of the game. I'm not hinting for release dates or beta dates (although I'm insanely eager for both), but I am curious about where your current efforts fit into the bigger development picture.

 

Thanks!

October 3, 2011 7:40:10 PM from Elemental Forums Elemental Forums

Ok I'm ready for part 2.

October 3, 2011 7:52:36 PM from Elemental Forums Elemental Forums

frogboy, from these comments of yours in this thread, I want the beta to start SOON, as in REAL soon NOW.

harpo

 

October 3, 2011 8:01:46 PM from Elemental Forums Elemental Forums

Thank you for the infos, frogboy. Maybe we can have a dev.journals about tactical battles from Derek. Maybe its easyer to follow your journals "Fallen Enchantress: Tactical Battles - Part 1" about writing the AI. Its sounds awesome. Really can´t wait to play this. Will we have a beta with a full working AI?

October 3, 2011 8:13:46 PM from Elemental Forums Elemental Forums

Quoting Lord Xia,
I admittedly know absolutely nothing about making video games other than the info provided to us on these forums by Stardock. I just think that writing rules on how the computer does things would be easier in a better defined and structured environment.  I am a psychologist, so I am thinking about it as such, a behavior approach.  The less rules the AI has to follow, the less realistic and abnormal their behavior.  When you have a clear and defined structure in which the AI has to function, I would think that would make writing rules for it clearer. Strange paradox about behavior, is that some times when you create limits, you actually create choices. In WoM, there was no way to define a battle formation, everything has near unlimited range, so everything needs to be able to take damage and mitigate damage, so everything needs armor.  Flanking doesn't exist, and neither does true ZoC, and everything counterattacks, so movement and speed are fairly meaningless.  Terrain is all flat and meaningless, so tactics is pretty void.  In a game like that, how can you write any AI other than Shoot and Chase?  There are no other variables, so I would think that would make writing good AI almost impossible. Like I said, I think of it as some one trained in behavior, not computers.

quoted for the truth.. i've been saying this for oh so long about social conventions.. and including games and game design.. so many people point problems in game design down to too many rules disallowing them from building the ultimate 'maths based' combination (an army for example), but in fact rules should be in place to create decision making which by extension the forte of a good strategist..

October 3, 2011 9:32:49 PM from Stardock Forums Stardock Forums

What is being referred to as game rules I call game mechanics.

As long as those mechanics are intuitive and FUN I'm all for it.  And what is fun on paper is often not fun in "real life".  

The objective for Fallen Enchantress's tactical battles is for them to be relatively short but still very intense.

The problem *I* had with War of Magic's tactical battles was that they were a) boring and the AI was ineffective.

But it didn't really surprise me either given that there was no quick and dirty way to set up battles. I'm a man of iteration. I expect to have thousands of tactical battle fails before I get it right.  And if I had to "play the game" to get to a natural tactical battle, there'd be no way to do that.

The big thing in this article is that I can, in an XML file, create armies, set up what spells and abilities they have and see what they do with them.

And a lot of the goodness of the AI comes down to the architecture.  For instance, in WOM, the units were pre-defined at the start of the battle, would set a target and continue their strategy until they accomplished their goal.

By contrast, this AI looks at what a given unit should be doing every initiative activation (i.e. every time it gets a chance).

So a sovereign might start out the battle as an TACTICAL_SUPPORT unit where it casts some buffs on its army or on a particular unit.  Then later it might become a TACTICAL_MELEE unit, whacking away at units with its sword or with a short-range magical spell and then it might turn around and cast a heal spell.  

The point being is that you can't set a role for a unit at the start of the battle, it needs to be able to make a change whenever possible. Who it attacks, who is helps, who is runs from, etc. should be done during each initiative and making that "fast" includes being able to call from XML what the appropriate counter-move is.

October 3, 2011 9:45:33 PM from Elemental Forums Elemental Forums

Some suggestions to make AI design easier which includes ideas from other games:

 

Chess: Calculate all the possible moves and take the best one. The problem is that there is a lot of randomness in the mechanics which adds a lot of uncertainty making it hard to determine the best move.

 

R3K6 Method: I am currently playing R3K 6. In that game, battles are managed semi automatically. For each unit, you define a policy and an action. The unit will do the action until complete, then will follow the policy. You can also set additional parameter like unit speed, weapons used, etc. So that could be an idea, design an AI that give orders and design another AI that simply executes them. The only things AI influenced by XML would be the strategist, else the second AI is only path finding and optimisation.

 

Ogre Battle: For spell and many even unit targetting, Ogre battle allows players to set a proiority (attack strongest, attack weakest, attack leader, etc). When the AI has the choice to target multiple units, the unit selected will be done according to this priority. Ogre battle also have a formation system that dictate how the units will fight. I find this system very interesting and the battles get resolved fast.

 

Simplify the combat system: Who said that battles needed to be played on a tactical square maps. You could design another system which would be easier to play. For example: you have 3 flanks with a back and front row, you position your units and they attack according to your orders or priorities. It looks similar to ogre battle. The idea is that maneuvering units on a square map makes the AI design much harder. If the battles are easier to manage, so will be the AI design. Ask yourself what kind of decision do you want the player to take in combat and focus on that. A full tactical system sometimes demand the player to do a lot of meaningless uninteresting decision which are not fun. Personally, I would designa system that focus on the fun decisions. Even in a real war, the tactician does not manually move each units, he give them orders.

 

Many board games try to substitute tactical combat in various ways since they cannot afford to have tactical combat. That is the case for example of the new civilization board game from FFG. There are many combat simulation mechanics out there that can sometime be very creative. Take a look at these mechanics to get some ideas and it would make the combat system redesign. Try it with an paper prototype first. In fact all game mechanics should be tested on paper prototype, even for video games.

 

Some might say that a full tactical system is essential, but even in Master of magic, sometimes combat just get repetitive and boring to play. There are at most a dozen of combats per game which are actually tense and interesting where strategic decision really matters.  Else, most of the time you auto battle. Tactical battles also takes time, so tactical battles can slowdown the pace of the game especially in multi-player.

 

Other  suggestions

- Cities should be on the tactical map. there should be gates that players want to defend and capture to enter the city.

- It should be possible to start a battle and include all the surrounding unit stacks of the target on the battlefield, like in age of wonders 2.

- Cloth map mode for tactical battles ... please

 

October 3, 2011 9:49:51 PM from Elemental Forums Elemental Forums

I'm really excited about these AI entries, Brad. What you have posted in Part One sounds awesome.

As a developer who mainly deals with boring systems stuff (automated rollout/deployment systems for datacenters and the like) I've had no exposure to AI but it's something that has always really intrigued me.

Really looking forward to the next installment!

Stardock Forums v1.0.0.0    #108435  walnut2   Server Load Time: 00:00:00.0000984   Page Render Time:

Stardock Magazine | Register | Online Privacy Policy | Terms of Use

Copyright ?? 2012 Stardock Entertainment and Gas Powered Games. Demigod is a trademark of Gas Powered Games. All rights reserved. All other trademarks and copyrights are the properties of their respective owners. Windows, the Windows Vista Start button and Xbox 360 are trademarks of the Microsoft group of companies, and 'Games for Windows' and the Windows Vista Start button logo are used under license from Microsoft. ?? 2012 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo and combinations thereof are trademarks of Advanced Micro Devices, Inc.