Improving the AI

I would say, one of the biggest problem of the AI is that it does not evaluate the situation.
A good example is the irrigation while under despotic rule. Another example is about road building. Have you ever noticed, how long it takes the AI to calculate when you build an additional piece of road somewhere?
Let's say, the current situation is as follows:
---_-W
With - being existing road, _ being road to be finished, W being water

Being in mid-game, the building of the one piece of road may easily cause some 10 - 20 seconds of calculation. I mean, come on! :mad:
There is nothing to calculate!

Instead, obviously the engine checks for the whole planet, what relations this one tile of road could have with all other nations, resources and so on. But, the only thing it should have to check is, what relations does the one road tile to the left provide, and what relations does the one road tile to the right provide. And I intentionally said "check" as this should be found in some kind of table.
Just another case is the route calculation. Did you ever notice, that the engine is pretty quick in finding it's path to a given point (if you send a unit or some of them to that point). Now, what is going to happen, if you finalise a road between the original location and the target tile?
Does the engine take notice and makes use of it? No, it doesn't! :mad:
Your units will follow the initially determined path, whatever has happened in the meantime.

So, sometimes there are certain values stored, and sometimes they aren't. The funny thing is that it seems to be almost in the wrong moment. When it would make sense to store a value, the engine has to calculate it. When it would make sense to calculate each turn, it follows stored values... :nuke:

My only hope is that in Civ4 they will make use of moduls, so that we can easily change them once and distribute.
On the other hand, based on my experiences with Civ3 I am not very confident about this. My fear is that we will find some kind of "spaghetti-Python" and then have to find out, how to improve it. :sad:
 
One thing, I forgot: Did you ever notice that the AI tries to avoid roads? If you send your units to a certain destination, and it can be reached in the same no. of turns, once by completely staying on roads, once by "using a shortcut" - it will do so.
Where the hell is the point in this? It only leads to the fact that reinforcements and protection troops might arrive late - or, if there are some exclusion due to terrain, they won't arrive ever! :mad:

This in no way is "good" programming - sometimes it just seems to be intentional to have the least understandable behaviour for units. :nuke:
 
cierdan said:
I wish they would make the AI as good as the AI in chessmaster or in poker academy. It seems like they only spend a couple weeks on the AI. Instead of making civ 4 they should just release civ 3 with better AI and no bugs :)

Cierdan,

Please don't compare the AI in chess to any commercial game. I do know chess ( I was an expert for a long time) and I was around when chess computers starting coming through the ranks.

The chess vs. human debate picked up steam when IM David Levy made a bet (I think it was 1968) that no chess computer could beat him (even once) in 10 years, and gave a stake of soomething like $1000.

I remember the computer guys I worked with laughing -- how could a human have so much hubris?

Of course, I think you all know the answer -- it was the computer programmers who ate humble pie. I still remember when one of them said, 'wow, I didn't realize chess players were that good!' :) Programmers made the old mistake of projecting strength in chess ratings, not recognizing that all strong players go through similar growth.

In the mid 70's, chess smachines were 1700 ish strength ( the equivalent of a Monarch or Emperor player here, I would say. I played against a computer team in The US Amateurs. They were getting stronger, as they got smarter.

The key to chess development, then, was taking the problem seriously. They recognized chess machines played opening terribly. They always took the same amount of time on every move. These were improved over YEARS (yes, years, not weeks or months).

Flash forward to the mid 1980's. In the early 80'sd, the stupid prognosticators said that a computer would be the next champion after Karpov.

By the mid 1980's, I went to a business related AI convention (not gaming, real AI applications). AI as a business wasn't doing well. I remember one of the speakers saying, 'The most important development for the future of AI would be to have aprogram that could beat Kasparov (wrold champion).

When the 90's came around, people like me who knew all along that SOME DAY computers would best all players was coming near. But, again, computers got smarter.

Instead of trying to emulate how humans played chess, they turned back to their roots and just tried to calcualte everything. Equally important, instead of having the AI play openings, they just TYPED the Encyclopedia of Chess Openings into the code!

IBM spend millions of dollars on Deep Thought. It built a computer that did nothing but played chess, had typed in openings, and powerful brute force.

Right now, the best computers are just about as good as Kasparov (who has split their famous series), although he isn't the player he used to be. They are probably better than anybody else. Yes, and your chessmaster on a good modern machine is grandmaster strength.


The conclusion -- people build great chess AI NOT because it was effective, or because it increased sales or profitability -- they built it because beating humans became a goal to itself. MILLIONS, and I mean millions, has been spent on it. This spending isn't gaming cost effective, it is part of the bragging rights of computer designers.

I don't want to take away their accomplishment. The great chess computers are marvels of engineering, but THAT is what they are. The Chessmaster, of course, used the great breakthroughs in chess AI design. But NO game company could possibly devote the resources that were spent on chess AI.

And if Firaxis, Atari, or other masters spent that much time and money, would we have an invincible machine? On even play, probably not. My guess is that they may still have trouble with the Sir Pleb's and the Arathorn's. I think CIV is a tougher game to make AI for than chess is, which is a game for which pure calculation, the computer's forte, is well suited.


So, be happy that your Chessmaster is that good. No company wanting to be in the game world as a business can ever spend like that on AI.

Also, I'm sorry if I sound pedantic -- but I've heard this 'why can't it be as good as chess' so often for Civ and other games that I wanted to set the record straight. The AI in CIV is really quite good.


Best wishes,

Breunor
 
@Breunor: :thumbsup:

@Bello: The pathfining routine of all things in Civ3 is absolutely flawless - if the AÍ seems to get lost on a shortcut instead of using the roadnet, you can be sure this road isn't open. Since you don't see through the FoW, a unit of another AI can block it.
AI pathfinding = GoTo.
Test it, you won't see problems.
 
Doc Tsiolkovski said:
[...]
@Bello: The pathfining routine of all things in Civ3 is absolutely flawless - if the AÍ seems to get lost on a shortcut instead of using the roadnet, you can be sure this road isn't open. Since you don't see through the FoW, a unit of another AI can block it.
AI pathfinding = GoTo.
Test it, you won't see problems.

Sorry Doc,
I have to disagree with you. Or better, there seems to be some kind of misunderstanding. I didn't say that the route calculation would be wrong or lead to longer distances - at the time of calculation, that is.

As I am currently playing RaR (great! :goodjob: - btw) the problem mentioned by me could become more significant due to the limited movement by road.

Anyway, the engine likes very much to deviate from the paved trail, if the total of turns needed doesn't change. Now, at first glance this doesn't seem to be a problem, no? But, as I indicated, in case the next to the road there are terrain types limiting certain units in their movement, this may very well become a problem.
I guess, the whole thing is caused by some kind of logic:
IF number_turns(road) eq number_turns(non_road)
GO (path_shortest)
ENDIF

Which, at first glance, seems to be a logical behaviour. Nevertheless, due to the impacts mentioned, this very well may cause trouble.

Additionally, it stands true that the engine doesn't adjust the pre-calculated route if circumstances change - as a road tile being built, an enemy showing up and so on.
 
Something that might be a little worse(than the irrigation thing) for the AI is
the effort they put into getting the early great wonders done. Sometimes as
soon as they build their second city then they will start the pyramids. They
would expand and grow a whole lot faster if they weren't building so many
wonders, but this of course can just be eliminated through the editor.
 
The poker AI in poker academy didn't take decades to develop.

I realize they can't invest as much into the AI as was invested into chess AI, but they should give it more than a couple weeks or however little time they spend tacked on after they already finish the rest of the game.
 
Cierdan,

Sorry, I don't know anything about Poker Academy so I can't make any comments here.


When you say a few weeks were spent on the AI, is this true? I don't think the AI is worked on at the end; it is usually worked on while the game is being developed. Although the games have changed, it was probably built over old CIV version AI time.

If you are correct that they spent a few weeks after the fact, I would agree that this would be unfortuante and disappointing. Do you know is how it was programmed?


Instead of comparing it to the best AI out there for simple and special situations, it may make sense to compare it to other large strategy games, especially turned based strategy games.

What do people think? Which AI's out there are better for similar complexity turned based strategy?


I put CIV 3 near the top. I think it is FAR better than its two sister games, Master of Orion and Master of Magic. MoM is my favorite, and that game is far more complex, but the AI is truly horrible.

HOMM 3 had pretty good AI -- about the same or better than Civ 3. Disciples and Disciples II I would say are worse.

The AH game Advanced Civilization had pretty good AI, but that is a simpler game by far and it was horrible at trading. I haven't played Age of Wonders.

EU II is an interesting case. Although theoretically a real-time game, it is effectively like a turn based game. This game is tremendously complicated, and its AI is its weak spot. I would probably prefeer it to CIV but I think the AI in Civ is much better. (I think Civ and EUII are two of the greatest games ever made).

Anyway, these are my subjective assessments and I why I view tha AI in Civ as quite good, if not excellent. I haven't played many others so maybe Civ compares badly to them.


Best wishes,

Breunor
 
Commander Bello said:
Anyway, the engine likes very much to deviate from the paved trail, if the total of turns needed doesn't change ... it stands true that the engine doesn't adjust the pre-calculated route if circumstances change - as a road tile being built, an enemy showing up and so on.

You are right CB and I've noticed it too, many times. I don't think it would be hard to run a check of the shortest route every turn, but that's just more stuff the computer has to process every turn; many people already experience long waits in-between turns.

Of course, it probably already does this now for the AI players, so adding the human player's Go-to units wouldn't be adding much. It may have been a tradeoff on a lot of these issues, or it may have been time constraints, or something else. And then, there may be no good reason a lot of them weren't anticipated and "fixed".
 
Brain said:
Alright, I will give some thoughts on the subjects that have been brought so far.

First of all, yes, I concede that there are simple improvements that could be done to make the AI better. However, I will play devil's advocate for a moment to show that it isn't as bad as what some say.

On the point of worker tasks. It doesn't really matter whether the AI completes a unit because it is cheaper to produce or because it has maximized its tile usage. The bottom line is how many turns it takes for the AI to build that unit. In fact, the same thing could be said about the use of the luxury slider. In order for the AI to get a good science output you could make the AI utilize its citizens optimally, or just give it a research advantage. In the end, it's only the number of turns to complete a tech that matters. Here I think the programmers were just lazy, rather than incompetent.

About roads and railroads. I agree that AI workers could have a concept of connected cities, but I think the main problem is one of implementation. Connecting a resource is relatively easy because you are just connecting one resource to the nearest city. On the other hand connecting N cities to N-1 other cities is a much more complicated problem. In fact, it is similar to a well known problem in computer science called the Travelling Salesman Problem (TSP). But you see, this problem is very, very CPU expensive. Solving the TSP for more than a few dozen nodes usually requires super-computers to do in an acceptable amount of time. And "acceptable" means something different to a computer scientist than to a gamer. ;)

On the other points mentionned I think it would be hard from a programming perspective to make some of those improvements. In order for the AI to lower its science slider or switch governments or plan coordinated attacks you would need to have some kind of strategic plan, which the current AI lacks completely. The AI doesn't switch governments because of a strategic choice. It only does so because it is programmed to favor some government type over another. It doesn't plan its attacks. It only reacts to state changes, looks at what units it has available, and attacks the weakest target within a certain allowable range. My point is that in order to introduce the changes suggested the AI would have to be significantly re-designed. It may seem simple to a human player, but the work to do behind the scenes is quite involved.

It is true that some things could be done that wouldn't require large changes. Suicide galleys are one of them, I think. However, I still feel that it's not so bad. In other so called "strategy" games there is always a "Silver Bullet" strategy that works every time. It's not that way in Civ. In this game you have to be creative. Even years after the release of the game, people are still inventing new strategies that have never been tried. Just for this I think you ought to give the AI programmers some merit.


Just felt like bargin in here.
We need to connect the nodes so they are all roaded to each other, not find a cycle through them (except if you have a warrior that wants to tour your cities?).
This is NOT TSP, its called minimal spanning tree, and can be solved VERY efficiently, as opposed to TSP...

Now about the thread.
I agree with some here that some other underestimate how hard it is to make a good AI on the strategic level, and civ 3 is among the best games on the market for this.
Some ppl obviously werent around the first few weeks when veteran civ 2 players were being brutally out rexed by warlord and regent AIs.
But then hundred of players studied the game and the AI, found out all its weaknesses over many years and today good player rip the AI apart...
But look at new players who come on CFC for the first time, they are usually stuck at regent and monarch, which means the AI cant be that bad...

NOW I agree that there are some small points on which the AI does crapastacular which could have been EASILY improved upon : usage of armies , but there are other many other examples....
 
tR1cKy said:
Did you mean "N cities with N-1 nodes" ?!?
Supposing the answer is "yes", that's exactly the TSP problem, with some extra goodies that don't impact complexity (only because it's already hard enough :()
However, an algorythm pooping a near-optimal solution, or even a decent one, could have been easily implemented, if some lazy programmers would have spent more time programming and less time surfing for net p0rn...

Read my previous post.
Thats not TSP at all, since we dont mind if many cities are connected to the same city, say in a star pattern...
(extra goodies, I assume you mean since we have something like an Euclidean TSP, if it were a TSP)
 
Checked. I was mistaken. Connecting N cities with N-1 nodes is not the TSP. I confused things.
However...
LulThyme said:
This is NOT TSP, its called minimal spanning tree, and can be solved VERY efficiently, as opposed to TSP...
Only if we're considering railroads. If roads are involved the matter is quite different. We need a graph in which for every couple of cities the path connecting them is the best possible.
 
tR1cKy said:
Checked. I was mistaken. Connecting N cities with N-1 nodes is not the TSP. I confused things.
However...

Only if we're considering railroads. If roads are involved the matter is quite different. We need a graph in which for every couple of cities the path connecting them is the best possible.


Thats actually not a good strategy though... (connect every pair by possible path), thats not how you would do it is it? or good players?
Thats a very unefficient way of using workers...
(in terms of just unit movement, not considering the fact that you will eventually road almost every tile, for commerce purpose)..
 
Back
Top Bottom