View Full Version : Battle AI Blog
Fisherking
11-10-2009, 20:02
Tuesday Nov 10, 2009
Battle AI - By Mike Simpson
Just before the end of Empire the lead Battle AI programmer left CA to return to his family up north.
Unfortunately, thanks to Mr Wilberforce’s efforts 200 years ago we couldn’t stop him. It left us with a battle AI, which at that stage, struggled to beat good players in a fair fight, and was pretty much at the mercy of great players, even with a level of handicap (I call it cheating) that is all too obvious.
Since then we’ve had our most talented programmers pick up where the deserter left off, but becoming the master of a chunk of code that took almost three years to write is not an instant thing. In the updates so far we’ve got rid of some of the worst behaviours that are close to the surface, and have started to tackle deeper issues like unstable decision loops that cause the AI to mill around rather than hold its line and fire. We’re also starting to add new behaviours, for example taking better advantage of hilly terrain. These improvements take the code further than we’ve been able before and will be there for Napoleon but we’re not sure yet whether we’ll be able to reverse them back in to Empire in a future update - the code has moved on. If we can we will.
Our overall aim with the improvements is first to get rid of any erratic behaviour, second to improve general performance to the point where the obvious handicaps can be removed, and then to add a greater variety of ’smart’ behaviours. None of these have a fixed finish line - it’s a process of continual improvement, and each game will get AI better than the last one. Including Napoleon.
Progress is frustratingly slow but thankfully rewriting the Rome: Total War codebase has left us with a clean codebase that is easier to work on, and an architecture that has way more potential than Rome’s. The main difference is the shift to a goal oriented planning system rather than a static system that has no long term plans. This has yet to fully pay off. But it will. When it does I’ll talk about it again.
Battle AI is not rocket science - its way, way harder than that. It’s so difficult that very few strategy games attempt it. Most use simple scripts of canned behaviour that fire when you bump in to them, and very simple swarming behaviours. They’re limited, and are “gamey” rather than real world. What I mean by that is that the tactics you use to beat them are something that you have to learn for each game or sometimes each scenario/level, and bear no relation to reality. What we strive for is a game where real world tactics actually work. It’s not the easiest path to take, but it is the most rewarding.
If you’re a genius C++ programmer, you understand exactly how difficult this problem is, but still think it’s the most interesting code problem in the world, apply for a job. We’ll find space for you.
Posted by Mark in CA Updates on 2:42:07PM Nov 10, 2009
http://blogs.sega.com/totalwar/2009/11/10/battle-ai-by-mike-simpson/
Owen Glyndwr
11-10-2009, 20:17
That's nice, now where are the modding tools?
This was a nice entry - unfortunately the main programmer leaving in the midst of development happens in many games (it has happened to Crusader Kings of Paradox too) - and its a thing that very little can be done about. Its to be commended uopn that a single coder was in control of the whole, this gives more cohesion and allows greater amount of control and detail over the code due to a single person being able to achieve greater knowledge over it, rather than compartmentalise the effort in between other coders and introduce the "broken telephone" effect of inter-team communications.
The battle AI of Empire TW is by no means finished and i still feel cheated that Napoleon won't upgrade it - but it undoubtedly has potential to be better and the problem at hand (coding battles that all units have missile weapons) isnt an easy one indeed.
PS To all those that have argued that M2TW had a better battle AI than RTW:BI, note that it is again stated in this entry that the best AI battle code they had was in BI and not in Kingdoms; apparently only peripherals were touched in M2TW by CA oz; it seems that there was no or very little work on the AI for that game, so statements from CA in general and Mr Simpson in particular at the time, that said "we are improving things accross the board" (the TW Story) were most likely simply marketing talk. As many have said for M2TW it was little more than an extensive mod for RTW.
Peasant Phill
11-10-2009, 21:24
Since then we’ve had our most talented programmers pick up where the deserter left off
I hope he means this humourously, otherwise we're playing the blame game again.
That's indeed most unfortunate. Especially the part about the upgraded battle AI not being integrated into Empire.
I hope he means this humourously, otherwise we're playing the blame game again.
I concur. To be fair, I *do* believe he said that with his tongue planted firmly in his cheek, but he probably should've placed quotes around it ("deserter") or otherwise worded it better to reduce ambiguity.
antisocialmunky
11-11-2009, 01:16
That's some good insight. Never thought about that happening but I guess those are the risks you take when you hire a specialist like that. Maybe NTW will have some of the bugs worked out...
I do disagree about the 'canned reactions' part. All game AIs use a deductive process to narrow down a set of possible actions to a single action that the AI has been scripted to do. It doesn't make them up as they go. I guess if you had some sort of crazy evolutionary algorithm for an adaptive AI like everyone wants to see it would be different but ETW is just as canned as everything else.
At the end of the day, I rather see CA produce a game as great as they market it than another total failure of a game.
peacemaker
11-11-2009, 06:27
will be there for Napoleon but we’re not sure yet whether we’ll be able to reverse them back in to Empire in a future update - the code has moved on. If we can we will.
Heh. I knew it. Try to convince people to buy NTW because of the 'fixed' BAI which UNFORTUNATELY can't make it into empire.:laugh4:
we’re not sure yet whether we’ll be able to reverse them back in to Empire in a future update - the code has moved on. If we can we will.
None of these have a fixed finish line - it’s a process of continual improvement, and each game will get AI better than the last one. Including Napoleon.
Seems a little contradictory, no?
Since then we’ve had our most talented programmers pick up where the deserter left off
The second they mentioned the lead programmer leaving, I knew they were playing the blame game again. CA has proved to entertain me though nowadays...
Zenicetus
11-11-2009, 18:21
CA could make an immediate, major improvement to the BAI just by eliminating the ability for the AI and the player to garrison buildings. In a more realistic game, both the AI and the player could choose to garrison any building or structure on the battlefield, which would keep the army together. Instead, (and probably due to 3D graphics limitations), only a few scattered buildings can be garrisoned, and they're never close together. The player is smart enough to choose one building to put troops in, with supporting troops nearby, using surrounding buildings to protect the flanks. The AI never does that. It just occupied all possible buildings with single units, while the rest of the army remains somewhere off in the distance. This allows the human player to pick off units one by one. Even when driven out of a building by artillery fire, the AI unit never rejoins the rest of the army, and the rest of the army never provides support. They're sitting ducks.
I know there's a lot more that could be improved in the BAI, and this doesn't happen all the time because not all battles included buildings that can be occupied. But this is such a failure of a game "feature" that they should really just remove it. Sometimes simplifying the design is the right answer to improving it, instead of piling on more features that just become player exploits. I doubt that CA would ever do this, but it would immediately improve at least some of the battles.
Rubbish. Nothing more than an attempt at raising sales for Napoleon.
I'll be proven right as soon as Napoleon is released, which I won't be buying, by the way.
Crazed Rabbit
11-14-2009, 08:49
Makes me wonder; what would CA do to cause a very important programmer to leave the project shortly before launch? :inquisitive:
Still, I hope they make a competent AI and I hope even more they put it into ETW.
CR
Makes me wonder; what would CA do to cause a very important programmer to leave the project shortly before launch? :inquisitive:
Still, I hope they make a competent AI and I hope even more they put it into ETW.
CR
Probably because he didn't have the time to finish it, and SEGA executives wearing black suits, sunglasses and earpieces dragged him from his chair and took him to a black professional car and he was never heard of again.
He was later found in the basement of EA, made to suffer scorn for eternity, programming DRM.
Well, this new system of AI has me optimistic - the less scripted behavior the better.:yes:
Well, this new system of AI has me optimistic - the less scripted behavior the better.:yes:
Being honest, scripted behaviour actually makes it better. less scripted can usually overcomplicate or overwhelm.
Owen Glyndwr
11-15-2009, 21:22
I'd rather see scripted cohesiveness than unscripted confusion.
Elmar Bijlsma
11-15-2009, 21:53
In lieu of clever AI, cleverly scripts can be pretty effective.
antisocialmunky
11-15-2009, 23:29
Less chance of machine rebellion anyways.
Elmar Bijlsma
11-16-2009, 00:07
Good point!
Get too clever an AI and there is bound to be a hot robotic chick being teleported to the past causing all kinds of messy paradoxes and outdated history books.
peacemaker
11-16-2009, 03:15
Hmm. I honestly was hoping for more information out of this. Looking at the sad state of BAI, andd the cool things the modders have done WITHOUT tools, the BAI is decent now but still not that great.
To me, all this says is "Oh, now we're blaming the guy who did some programming. Go buy Napoleon and we (once again) promise that it will be awesome. Oh, and we challenge you to do better except you don't get tools."
Seamus Fermanagh
11-16-2009, 22:24
Each AI has been better than the last.
CA cannot possibly expend the resources needed to resolve the problem. The market for 500 USD/copy games is much smaller than the 50 USD/copy market. The US DOD buys military simulator games with sophisticated AI...but they aren't worried about making a profit, now, are they?
If they open the engine to the modders who WOULD expend the time, then they lose their game entirely and make nothing.
All-in-all, despite the flaws. I have liked the entire series. Modded with better values in the data sets etc. (e.g. EB, XGM, RTR) the results are quite enjoyable.
But the 500 USD/Copy games only sell to a specific audience opposed to the mass market, where such a price would be dropped anyway.
The sales for 500USD a copy game would probably be 1,000 or so, CA with E:TW is looking at near the million mark, or which ever it is.
Also, couldn't they look at the source code of such a simulator anyway?
Owen Glyndwr
11-17-2009, 01:09
All I know is that I was promised modding tools, so I want modding tools.
In a choice between online multiplayer and modding tools I'd have to go with the tools. At this point, mods are the only reason I play ANY of the TW games anymore.
AussieGiant
11-17-2009, 19:33
As usual, I hope we are all aware of what exactly we are all talking about.
Try and imagine the Intellectual Property of "human realistic" Artificial Intelligence in a game code...
....just take a few short "crack induced" moments to comprehend that.
Excellent...
now ask yourself what part of the military or scientific multi billion dollar industry would pay for it?
Great...so lets get it straight...IF CA actually did manage to code "human realistic" AI in their game, we'd bloody well know about it, or maybe they would just disappear because DARPA buy's them out for lets say....1 Billion dollars!!!
:wall:
Christ on the cross people.
It's 50 dollar game and your equating a section of CA's code with something that would be as valuable as what the quantum physic coders make for billion dollar investment companies to predict the stock market.
Cecil XIX
11-18-2009, 01:39
It's true that AI is a difficult thing to achieve properly. But I think most, if not almost all, of the people complaining about ETW's AI also think that the AI in the first games was markedly better than that in Rome onward. So I think most people aren't asking CA to come up with new, hyper-intelligent software. Most are asking for a return to the competance of Shogun and Medievel. To focus on AI, rather than graphics.
Perhaps that's unreasonable as well, but it's not asking for a miracle. They made a living with those games as well.
antisocialmunky
11-18-2009, 01:43
TW has always been a primarily singleplayer experience so it needs a decent AI.
As usual, I hope we are all aware of what exactly we are all talking about.
Try and imagine the Intellectual Property of "human realistic" Artificial Intelligence in a game code...
....just take a few short "crack induced" moments to comprehend that.
Excellent...
now ask yourself what part of the military or scientific multi billion dollar industry would pay for it?
Great...so lets get it straight...IF CA actually did manage to code "human realistic" AI in their game, we'd bloody well know about it, or maybe they would just disappear because DARPA buy's them out for lets say....1 Billion dollars!!!
:wall:
Christ on the cross people.
It's 50 dollar game and your equating a section of CA's code with something that would be as valuable as what the quantum physic coders make for billion dollar investment companies to predict the stock market.
CA promised a revolutionary new AI, never before seen. In the demo of the game, when playing as the British, it seemed like they had made good on their promise. The American troops defending the fjord stayed in place and ripped any units you sent at them to pieces. If you moved troops to cross the undefended fjord, they would swing around 60% of their army to meet your troops, and march toward you in order, engage you in order, mimicking tactics of the day, and would put up a bloody good fight.
All scripted behaviour, deviously designed to fool people into buying Empire. If we played that battle with the AI we have now, the American soldiers would charge at you over the first fjord, the one they have fortified, and abandon their excellent defensive position. If you crossed the second fjord, you would be lucky if they sent a unit of cavalry, and if they did send a unit of cavalry it would charge head-on into a 4-rank deep unit of line infantry with bayonnets equipped, getting ripped to shreds.
The rest of their army would then bunch up into a huge cluster, unable to make a decision, and be annihlated.
If CA can't make anything but crap AI, then they ought to just admit it, not lie to me and talk about revolutionary this and revolutionary that, and then let sympathizers like you try to convince me (unsuccesfully) that they did the best they could with the funding available.
Once again, perhaps they did do the best they could with the funding available, but the AI is not revoltuionary, nor is it an improvement on Rome or M2, and it is a hell of a lot worse than MTW1, which I find funny, considering that was released... 9 years ago?
peacemaker
11-19-2009, 02:47
Peh. I just want an AI that can stand and shoot, not cluster up 10 feet from my men and do the chicken dance. It doesn't have to outsmart me, just make me believe that it isn't as stupid as it may actually be.
Nobunaga
11-19-2009, 08:03
CA just fails... so badly...
And no it ain't rocket science it is much much easier than that...CA just can't make good AI so there marketing policy is to tell poeple that a good AI is not doable :shame:
Just look at the campain map AI for example and compare it with that of paradox games and you will see why CA fails...
Alexander the Pretty Good
11-19-2009, 08:56
Peh. I just want an AI that can stand and shoot, not cluster up 10 feet from my men and do the chicken dance. It doesn't have to outsmart me, just make me believe that it isn't as stupid as it may actually be.
'Zactly. No one's saying we expect the AI to outwit us at every turn. But at least be plausible. I didn't lose a whole lot in MTW but that's because I picked my battles when I could, in an attempt to bring more and better troops to bear against the AI. Not because I could just plow through their flanks with cav and insta-rout or whichever cluster :daisy: the AI is engaging.
Shogun Total War for the win :laugh4:
The last game they did with at least reasonable AI was RTW: Barbarian Invasion. I had high hopes for ETW but since I bought it at launch I have yet to finish my first campaign, in fact I havnt played it for about 6 months. I thought that perhaps the AI would improve over time with patches etc. but if that is going to happen it looks like I`ll have a long wait...
I have gone back to playing Shoggy again and even after all this time it is still an engaging all round experience. I actually lose battles from time to time :yes:
antisocialmunky
11-20-2009, 06:10
Yeah, the indecisiveness of the AI is the msot annoying thing. Its a weird edge condition between two states that the AI alternates between or a anti-missile behavior. It first popped up in RTW(custom battle archer vs archer) and plagued every unit in MIITW. Now its still present in ETW...
HopAlongBunny
11-21-2009, 17:41
Shogun Total War for the win :laugh4:
I actually lose battles from time to time :yes:
This is all that needs to be said. The AI in STW/MTW/VI was capable of winning a battle from time to time. It made you pay for not paying attention.
Is that too much to ask for from a battle simulation?
antisocialmunky
11-21-2009, 19:20
I also think that each battle in thsoe games mattered more. You win a battle, there are consequences. In RTW++, you wade through hordes of units all the time. I actually finished STW campaigns... lol.
AggonyDuck
11-22-2009, 02:20
The problem is that while the AI keeps improving the complexity of the battles is increasing exponentially, making it harder and harder for the AI to be competitive. Missile-based combat has always been a weakness for the AI and it hasn't really been improved much since Shogun. That's why the decision to move into the gunpowder age was a pretty risky gambit as they had to more or less start from scratch. At the moment the battles are so complex that the AI is in a perpetual state of confusion. It seems like it just has too many options to choose from and thus fails to select the proper response (if it selects any at all).
I must admit I'd hope that they'd go back to their roots and understand the elegance of simplistic design. What made Shogun and MTW have such a relatively challenging AI was the simplicity of the engine and unit selections. The more complex the series has become the more the AI has struggled to adapt. It would truly be interesting to see what a modern day AI might pull off on modernized Shogun with a Risk-style campaign map and relatively few simple unit types.
Originally posted by AggonyDuck(y?)
The problem is that while the AI keeps improving the complexity of the battles is increasing exponentially, making it harder and harder for the AI to be competitive. Missile-based combat has always been a weakness for the AI and it hasn't really been improved much since Shogun. That's why the decision to move into the gunpowder age was a pretty risky gambit as they had to more or less start from scratch. At the moment the battles are so complex that the AI is in a perpetual state of confusion. It seems like it just has too many options to choose from and thus fails to select the proper response (if it selects any at all).
I must admit I'd hope that they'd go back to their roots and understand the elegance of simplistic design. What made Shogun and MTW have such a relatively challenging AI was the simplicity of the engine and unit selections. The more complex the series has become the more the AI has struggled to adapt. It would truly be interesting to see what a modern day AI might pull off on modernized Shogun with a Risk-style campaign map and relatively few simple unit types.
Agreed with every word. They wont do it though because it makes them lots and lots of money. Its the complexity and graphics that sell not strategic depth and challenge. They had aimed for this and succeded with RTW and there is no turning back. TW will remain flashy and mediocre until its concept has been milked to the point that there is no more interest in it.
:bow:
antisocialmunky
11-22-2009, 15:47
The problem is that while the AI keeps improving the complexity of the battles is increasing exponentially, making it harder and harder for the AI to be competitive. Missile-based combat has always been a weakness for the AI and it hasn't really been improved much since Shogun. That's why the decision to move into the gunpowder age was a pretty risky gambit as they had to more or less start from scratch. At the moment the battles are so complex that the AI is in a perpetual state of confusion. It seems like it just has too many options to choose from and thus fails to select the proper response (if it selects any at all).
I must admit I'd hope that they'd go back to their roots and understand the elegance of simplistic design. What made Shogun and MTW have such a relatively challenging AI was the simplicity of the engine and unit selections. The more complex the series has become the more the AI has struggled to adapt. It would truly be interesting to see what a modern day AI might pull off on modernized Shogun with a Risk-style campaign map and relatively few simple unit types.
Yes it is crap with gunpowder weapons. But it doesn't mean it should also be crap at drawing a line of dudes, marching them into range, decide to shoot or charge...
Agreed with every word. They wont do it though because it makes them lots and lots of money. Its the complexity and graphics that sell not strategic depth and challenge. They had aimed for this and succeded with RTW and there is no turning back. TW will remain flashy and mediocre until its concept has been milked to the point that there is no more interest in it.
:bow:
My sentiments exactly, Gollum and AggonyDuck before you.
CA chooses more features over better AI because it looks better on the marketing. Much better to say you can garrison buildings and fight naval battles than to say you can do the same as (or less than) the previous game but that the AI will put up a reasonable fight...
Going back to the original post, a single developer is insufficient for BAI of this complexity. The way I see it CA has three viable choices:
Take on more BAI developers.
Switch from AI to scripting (for CAI especially I think this might even be appropriate).
Make the situation less complex for the BAI.
But it seems they choose option 4 - promise better AI in the next game or expansion.
Alexander the Pretty Good
11-24-2009, 09:07
It would truly be interesting to see what a modern day AI might pull off on modernized Shogun with a Risk-style campaign map and relatively few simple unit types.
And they could still go crazy with the graphics to attract the people who are dis- hey shiny!
antisocialmunky
11-24-2009, 15:32
Today's modern day AI is still the same modern day AI from 10 years ago.
AI isn't like graphics where its scales easily.
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.