It's not super difficult to program a good AI or at the very least a set of scripts in relations to events, its just that it takes a lot of balancing and play-testing to make it feel just right and not cheap or dumb. Studios are allergic to QA nowadays though.
QFT!
I'd say at least 70% of the time I spent on improving the AI actually was testing.
And even then about 30-40% of hints about improvements came from other players and our multiplayer-sessions with the AI and seeing what happened there.
That's why you cannot really "finish" an AI before shipping the game. The most work on it starts when you have it play against actual players. Then there's cycles of feedback => improvements => feedback again.
For example at one point my AI was so extremely aggessive towards "players with lower population" (kind of a cheap way of figuring out the human player on higher difficulty-levels without actually cheating in the sense of actually knowin who is human) that playing it felt like a bad joke. ^^
Everyone spammed troops like there's no tomorrow and just declared war on you outright even if you had a lot of troops. Lower population? => You are the victim!
While that made the AI "good" in a sense that it was hard to beat, it would still totally ruin the game as in feeling cheap or dumb.
That's also why I cannot just work on a patch and not get out inbetween-versions. The feedback is essential to me.
I don't expect it to get a lot better cus there are so many variables in a game as complex as civ and computers can't think abstractly. Despite all the sci fi movies that intimate otherwise I don't expect computers to ever be able to think abstractly either, they will just get quicker and be able to process more variables and situations to come up with more, better objective solutions faster.
In my opinion it is barealy about how fast the computer is but much more about how smart and sophisticated the algorithms were that the programmer implemented.
The closer you get to simulating your own thought-process algorithmically, the better the results.
The algorithm for that doesn't have to be calculation-intense or anything, it just needs to be fed with the players experience translated into a formula or number.
For example:
You have a limited ressource and you have an opportunity to spend it for something.
You know:
Not spending it for anything of course makes the acquisition of the ressource pointless.
Spending it on the first opportunity might be quite a waste when compared to using it at later, potentially much better opportunity.
The only way to really figure out if you should rather spend the ressource now or save it for later is experience.
A pandora-related example is a Black-Hole from a blackhole-generator. A very powerfull operation that has a very long cooldown. If you just tell the AI to find the best target there is now and then use the black-hole on it, it is very likely to be considered a waste and not be available when you need it.
That's why you not only compare the score of potential targets with each other but also with a value from experience from what would be the minimum score, when you would use the black hole. Algorithmically it's just one more comparision. Very cheap on processing time. But you need to implement this experience in order to have the AI make a sophisticated decision of saving the blackhole now and waiting for a better opportunity. Now if you save up more Blackholes, that value can drop. Also driven by an experienced-based algorithm.
You basically have to do something like that on any possible non-trivial decision the AI has to make throughout the game.
Look at what you would do, look at what the AI does and then think about what algorithm is lacking or has to be adjusted in order to have the AI come to the same conclusion as you would.
The other major point is at a certain level of friendliness AIs will never attack you and will always do or not do certain things diplomatically. This is the other major area to exploit them. Share a religion, give a couple gifts and bam, you have an ally for life, despite how easily they could wipe you out. This however I don't think should be changed. They tried making an unpredictable diplomatic AI in the first iteration of civ5 and it failed horribly cus you never knew what they would do. It just doesn't fit the civ game design.
Well, I've been there and like to share my experience with this and how I finally found a way to resolve it in a manner that I feel is good enough.
I had to revise my believes about what would be the best approach several times.
My first opinion was: The AI shouldn't really care about relationship when deciding wheter to make treaties or to declare war. It should just calculate the supposed efficiency and then do whatever the algorithm said. The displayed relationship is just cosmetic-reasons to make the player believe it means something.
Well, the players noticed and found diplomacy to be pointless and frustrating at the same time.
Then I was all about dynamically adjusting AI opinion based on what happens and making decisions based on that. It felt slightly better but was way too predictable.
After a lot of back and forth I now use several weigthed deciding-factors for the most important diplomatic actions. It's kind of like an internal debate:
Our relationship says we should trade with them.
Their economy says we shouldn't trade with them.
The way in which they look like they could be a danger for us if we support them says we should not trade with them.
Similarly for war declaration:
Our relationship says we shouldn't declare war.
The close distance to them says we should declare war.
Our strength-comparision says we should declare war.
Our factions aggressiveness-value says we should not declare war.
The outcome is mostly comprehensible and you feel like you have just enough impact on it but you never feel like you are completely in control of how they would act towards you. There have been quite a few revisions till the weighting of the components felt about right. And as described in the other post: I once had another pro-war-component that just felt completely unfair and thus was removed.
The opponents never respond to what the player is doing, but the player sees what they are doing and can counter in a myriad of ways.
Although I'm not 100% sure I want them too... it might be too difficult! It would be nice if they responded to your types of unit stacks and techs though in war.
Um, even before I layed hand on Pandora-AI they had mechanisms to adapt to military-buildup of others and try and counter their unit composition by adapting their own.
So while I improved how exactly they do it, I was under the impression that other games would do something similar.
Implementing a reaction to someone pulling away in any sort of victory-progress by lowering the relations to him was one of the first things that came to mind as necessity to make the outcome of the game closer. Can't have every AI happily be trading with the guy about to win the science-victory, while they have the military potential to stop him, can you? ^^
And if you would come up with mean tricks like the ones described for Civ4, I'd be happy to teach all of them to the AI as well.
One trick I tought them so far was the "use one orbital-bombard per turn on a sieged city instead of using all at once to prevent healing"-trick.
@sherbz:
I noticed your point very much back when I modded Civ 3.
I threw out a lot of concepts from the game in my mod that the AI simply couldn't handle well enough, like siege-units, corruption and the opportunity to freely pick what tile-improvements to build and voila, without having to worry about these, it dramatically increased the comparative performance of the AI!
However, I don't think that this should be a necessity in game-design.
You want to have hard to use mechanics in your game to challenge the player? Then you have to program AI-routines that handle them well enough.
You want a complex concept like corruption? Then it's your duty to make sure the AI gets a good algorithm to determine the ideal location of it's hidden palace!
I mean: While it is nice to see how the AI get's better the simpler the game gets, it's not really what I consider ideal. I want a complex game and an AI that handles the complexity of the game.
EL might be a good example for that. The majority of it's appeal comes from its complexity. I figure it's a pain in the ass for AI-programmers, but I imagine it to be a lot of fun for them aswell.
You would have to have a very very very long beta version for games like civ 5 .
Why would the improving of the AI necessarily all have to be fit in pre-release? I think with either approach it should be expected to ripe after the release.
While my skill as a player gets better, so does the AI, feels kinda natural.
When I started playing SC2 in multiplayer, I was quite good compared to most others because I had played SC:BW for a long time and partook in the beta.
When I play it now, I'll most likely get owned by those who stuck with it and developed their skills to what, back then was imagined to be the very top of the top. Why would it have to be different in a single-player-game with improving AI?
I mean there's difficulty-levels afterall.
There is of course one problem in having a computer AI like this. Eventually it would become too good at the game and it would essentially become unplayable. Imagine trying to play pong against a neural AI system? You would cream it to begin with, and then after a few hours it would win absolutely every single game. I don’t much fancy playing something where I get kerb stomped every 5 seconds.
Again: That's what difficulty-levels are for. They can't just be used to give the AI bonusses. They could also be used the other way around by artifially limiting the AI's ability or giving bonusses to the player.
That's pretty much how non-competative-chess AIs are these days. It's actually an art-form to not make them play as good as possible but give them playstyles and little weaknesses the player can try and find without making it look dumb.
Personally I don't mind the kind of AIs Civ has always had - they make it quite fun. They're rules based but they do have kind of 4th rules built in specifically, like they don't rush on turn 1, backstabbing is limited, etc. I mean what are the AIs there for - to make it fun for us or to beat us? If it's to beat us, see above paragraph.
Well, um, I... you know... If you are too weak, when you meet my AI it will immediately declare war on you. Just sayin'. Is that too bad?
These days game development is such a commercial enterprise that anything which increases replayability above a certain point is actually a bad thing for the devs.
That is exactly what I thought and what made me feel I need to step in and try and counteract!
I don't care about making money. I care about a game with a good AI. That's why I'll work on that for free. "Normal devs" have to work for profit.
The reality is: Bringing out three games that are just good enough to sell well and amuse people for some time is much better for the industry than trying to make a game as good as possible over years to invest.
Interestingly among the most popular games in the industry are those with alternative business-models and thus are constantly developed on over many years.
League of Legends comes to mind.
It's just continuously improved on and still a lot of fun to play. Unfortunately AI plays a very minor role in that game. I'd love to write LoL-AI to try and compete against top-human teams... Hmmy, maybe I should contact riot-games about an AI-API to do exactly that and have an AI-championship of which the winner is allowed to compete against humans. That would be really, really cool! ^^