 |
|  |
 |
|
MrBaggins
|
|
I think that we can agree that one of the primary concerns for an improvement to CtP2 that we'd like is in an improvement of the intelligence of its AI.
While we look like we could have the source code necessary to make changes, its certainly not a simple task to make improvements, especially when what needs to be changed is undefined.
I thought it would be a good idea to start a dialogue on the more complex issues, so we could define and discuss problems and solutions in a structured way.
As a starting point, I think its important to say that the goal of any improvement to the AI code , is not to make it smart itself in ctp2.exe, but rather to allow the AI files more scope and through those to act in a more effective way. There may be necessarily improvements such as more complex mapping or so on, necessary, but without investigating what the problems are, how they could be approached, and how to implement them, we don't know.
---
The AI point I'd like to raise is AI city management.
In many ways, this is the foundation for the AI. Without effective city development and management, the AI doesn't have resources to compete. While it is possible to give artifical bonuses to the AI to counter this, I think its important to ensure that the AI does a more effective job with what it has.
In my view things that could be improved are:
-City Placement (and settler behavior in general)
-Terrain improvements (and terraforming considering how it can be subsequently improved)
-Dealing with happiness in individual cities, rather than civ wide as it does now
-Wasteful changes in building (changing from almost done wonders to build a warrior, for instance)
-Better, more flexible definitions of buildings, and real building queues for the AI
Does anyone have any comments? Any problems that you've consistently noticed that the AI has in city development? Any specific feature in the AI files that you wish you had?
|
|
|  |
 |
|
MrBaggins
|
|
The way the AI moves is important, but is really a different discussion... I have been developing strategic movement AI ideas for a while and stumbled across more material that can help. I'm working on optimization ideas for them, since they are pretty costly right now.
|
|
|  |
 |
|
Gilgamensch
|
|
France
Jun 2002 time: 06:29
|
|
Just couple of remarks from my side:
The AI never builds in a way, that it could easily defend it's cities, like having center cities, which are hard to reach.......
Out of this maybe having different building queues/priorities for certain cities, meaning having outer cities concentrate on units, inner ones on wonders/buildings.
Maybe having different queues according to current strategy, i.e. if hapiness < 74 use hapiness-list, should enable it do get rid of the civ wide mode........
Might come up with some more tomorrow.............
|
|
|  |
 |
|
MrBaggins
|
|
The AI has really no directional sense in general, and in particular in relation to its building cities. Its feasible my work on threat mapping (it was adapted from work in electrical engineering, if I recall correctly) could substantially improve the 'understanding' of the AI.
Once the AI understands where threats are, and what "close" and "far" are, with regards to its cities, it can act more intelligently.
As I've stated before, awareness of its own continent, and other continents are important considerations for the AI, which I'm unsure is taken into account now, while human players concentrate on continents, and do well because of it.
Last edited by MrBaggins on 30-07-2003 at 21:24
|
|
|  |
 |
|
MrBaggins
|
|
I'm not so sure about this.
I usually, and I'm sure most others do, play CTP2 at levels where the AI starts with significant advantages in an extra starting city, PW and gold.
I don't believe that you can adequately assess the capability of the AI when considering that it has a headstart.
Even so, if you play vs one other AI player, on a reasonably large game world, then you can reliably out perform and out produce the AI by 0 AD, repeatedly, even discounting serious military engagements, on Emperor or Impossible.
This says to me that some part of the AI's development strategy is flawed.
Even small improvements will stretch the AI's competitiveness into later into the game. We might as well forget about later in the tech tree otherwise.
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:29
|
|
Tile Improvements:
The AI has no sense for it what its cities need, or is everything else then usefull. In the current system it looks like the AI checks the boni of the terrain and improves the things on the terrain that is already very good there. For instance if a terrain produces, 10 gold, 20 production and 30 commerce, the AI improves the commerce with the improvement with the highest commerce bonus available. That's why you see in the default game deserts with trading posts and shopping malls, but not in Apolyton Pack for instance. This leads to the fact the AI builds on a terrain type only one type of improvement. Only a river can modify the AI TI building behaviour.
So the AI should check if a city needs a mine, a farm or a trading post, and asign to each a value what is needed and should select the one with the highest priority.
Also the pop assignment must be improved, the AI has to check if a city is unhappy how much is lost if it adds an entertainer in comparison to a global slider adjustment, of course it has to consider the fact that entertainers can be freed then. But entertainer usage has to be tied on the happiness level of a city. More difficuild is the usage of all the other specialists. But possible conditions could be a low level of food for the farmers for instance.
I don't think the current build list are such a good idea, maybe the only function can be what the AI should build, but it has to build a theater for instance if the happiness is low, gold improvements if the gold income from the city is low and so on, the AI should be allowed to change from a unit to a building immediatly, but it should be more difficuilt for wonders.
Stack composement is another story, the AI needs to know how a stack must be composed and should build accordingly new units.
Then something like a map is need for threat level of a certain tile or a certain region.
An invasion code is needed, so that the AI knows how to invade an enemy by land and by water.
Code for Aircrafts is needed the AI needs to know how far such a thing can fly with its fuel. And it needs to know that it shouldn't group land units and aircrafts within one stack.
Also land stacks with special units and civilians should be taken in consideration for attack, but the AI needs to know that civilians have to be removed from such stacks, if it should go into the battle.
-Martin
|
|
|  |
 |
|  |
 |
|
hexagonian
|
 |
Gnawing on your mind...
Jun 1999 time: 23:29
|
|
quote: Originally posted by MrBaggins
I usually, and I'm sure most others do, play CTP2 at levels where the AI starts with significant advantages in an extra starting city, PW and gold.
I don't believe that you can adequately assess the capability of the AI when considering that it has a headstart.
This says to me that some part of the AI's development strategy is flawed. |
I think it is impossible, on a totally level playing field, to tell the AI what to do, because it is hard to put a finger on what exactly is the best action in all situations, given that there are infinite opinions on possible strategies and priorities.
I mean, how do you tell the AI what it should be doing in 30 turns? Should it expand by military means, and thus build more units that will then attack a rival - or peacefully by building improvements and settling more cities? Should it trade more, or spend more on tile improvements? Will it see the preparations that I may be making now as a threat to itself 50 turns from now?
Should it focus on gold, food, or production - and when should it do that? Should it max out a slider at the expense of another? Or should it max out production to build some buildings that will give it more gold/food. How much should it devote to PW, and when should it put the production elsewhere?
All these decisions are subjective and are also tied into the need to take a global overview.
So programmers will give AI bonuses to aid the AI. Not a pretty solution, but IMO, an acceptable one, because it gives the AI a cushion in all areas - to reduce the need to think subjectively.
Again, I go back to my testing with early versions of Cradle. Even on the lower levels, and before the additional PW cheats that were added to my Mod, I was suprised that the AI did a pretty good job on infrastructure issues and city buildings. Not perfect, but much better than I expected.
What I do know about the the AI is that it cannot afford to stay small. Most Civ games are a game of numbers - bigger is better... (with the possible exception of EU2, which has built-in penalties for size.) CTP2 tries to do this with empire caps, but the AI does not recognize the cap as a threat to itself. In the default game, the AI usually stayed below the caps, to its eventual downfall. I would warrant that is the main reason why you out-perform the AI. Take a look at the number of cities you have in comparison to the number of cities each AI civ has. That is why you catch it
I'd like to see the AI have the ability to recognize the cap for what it is.
|
|
|  |
 |
|
MrBaggins
|
|
I think decision making for an AI in this case is difficult but not impossible.
If you think in terms of boolean logic, and try to invent rules, then, yes, the complexity of rules that would be necessary to form judgements would be overwhelming.
If you take a more "human" approach and define comparable values, then use comparisons and baseline values to make decisions then the system is somewhat simplified.
Civ3 uses this approach: it uses values in the bic file to make value judgements, combined with world data and logic.
I think in large part, the CTP2 AI is slavishly following the build lists, alternating between military and civil construction based on a formulaic 'need' for troops.
These lists are human derived and essentially fixed, making the AI strategy basically one dimensional.
Making a new valuation system and tying it into a strategic overview system is no small task. It might be worthwhile investigating if we can do it, however.
---
Having said all of this, city caps are more pressing, and the science paths civs take to get to the appropriate governments are vastly influential too.
I also concur with Martins comments entirely.
|
|
|  |
 |
|
MrBaggins
|
|
quote: Originally posted by Solver
Ahh, MrBaggins, there is a good reason why AI programming is a whole separate part of programming. While I could draw up formulas to determine how good a unit is (its comparative value), with a different fromula being used for different states (defensive war, offensive war), making the AI see all those values as something part of a bigger whole AND making those into a strategic overview of the entire map... that's something very hard.
Anyone here ever programmed any AIs? |
Measurements at a strategic level produce 'needs' or tasks at a lower (tactical or operational) level; modifiers(multipliers actually) to the comparitive values.
While it would be nice to have a seasoned AI programmer available to us, those are pretty thin on the ground... and most likely involved in commercial projects.
I think if we are serious about making CtP2 significantly better, we have to experiment with conceptual ideas based on existing AI concepts, like fuzzy logic engines, or whatever we have available in the CtP2 engine, and adapt them to our needs.
I'm not suggesting that we need to invent a genetic AI, or adaptive AI or anything quite so blue sky.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:29
|
|
quote: Mr Baggins:
Its feasible my work on threat mapping (it was adapted from work in electrical engineering, if I recall correctly) could substantially improve the 'understanding' of the AI.
Once the AI understands where threats are, and what "close" and "far" are, with regards to its cities, it can act more intelligently.
|
I'd be interested in seeing this. I'm almost positive there are threat maps generated by the executable and I've sort of simulated one (a target map actually) in CTC_New_Tactics.slc.
quote: Mr Baggins:
I usually, and I'm sure most others do, play CTP2 at levels where the AI starts with significant advantages in an extra starting city, PW and gold.
I don't believe that you can adequately assess the capability of the AI when considering that it has a headstart.
|
quote: Solver:
Ahh, but obvious cheating removes the fun for many. If the AI has its cities grow way faster, starts with an extra one (HUGE advantage), then it's hardly that fun anymore, is it?
|
IMO, giving the AI big start advantages is a very poor way to proceed. For one thing it just postpones the inevitable: once the human catches up with the AI, the game becomes tedious. In Call to Conquest, if you chose the QuickStart option you start with 5 settlers and the AI starts with 5 or 6 settlers: not nearly so big a relative advantage.
quote: Martin:
Also the pop assignment must be improved, the AI has to check if a city is unhappy how much is lost if it adds an entertainer in comparison to a global slider adjustment, of course it has to consider the fact that entertainers can be freed then. But entertainer usage has to be tied on the happiness level of a city. More difficuild is the usage of all the other specialists. But possible conditions could be a low level of food for the farmers for instance.
|
Yes the pop assignment system seems to be very coarse. This is something we'll really have to look at.
quote: Martin:
I don't think the current build list are such a good idea, maybe the only function can be what the AI should build, but it has to build a theater for instance if the happiness is low, gold improvements if the gold income from the city is low and so on, the AI should be allowed to change from a unit to a building immediatly, but it should be more difficuilt for wonders.
|
I've developed my own system for units: see CTC_unit_building_system.slc. It's set up so that later in the game the AI will build proportionately more Tanks, Planes, Cruise Missiles and so on. With a little work it can be adapted to any mod.
quote: Martin:
An invasion code is needed, so that the AI knows how to invade an enemy by land and by water.
|
Yes :groan: . This is going to be difficult :groan:
quote: Martin:
Code for Aircrafts is needed the AI needs to know how far such a thing can fly with its fuel. And it needs to know that it shouldn't group land units and aircrafts within one stack.
Also land stacks with special units and civilians should be taken in consideration for attack, but the AI needs to know that civilians have to be removed from such stacks, if it should go into the battle.
|
See SaveThePlanes.slc for some of this. If we could tell how much fuel a plane has left, it would be a lot easier.
@ Hexagonian:
IIRC, you more than once complained that the AI was ok until you got a science lead, at which point it was game over. I think I may have recently put my finger on why this is happening. Consider the following:
code:
AI_MAX_BEHIND_TECHNOLOGY_COST 0.5 0.5 0.7 0.7 0.9
AI_MAX_AHEAD_TECHNOLOGY_COST 1.3 1.3 1.2 1.2 1.1
As the game progresses these sequences converge to 1.0: by the end of the game the AI is getting no significant science bonuses or penalties regardless of it's relative strength. This is going into the next patch for CTC:
code:
AI_MAX_BEHIND_TECHNOLOGY_COST 0.5 0.5 0.4 0.4 0.3 ## should decrease through time
Here if the human is running away with the game, the AI gets more help to catch up rather than less.
For more about CTC See this post
BTW: I'm pretty sure that we don't have to worry about fuzzy logic. It was in CTP1 (.fli = fuzzy logic inferencing) but was dropped from the visable CTP2 files. I read someplace that Steve Mariotti (CTP1's lead programmer) was heavily into fuzzy logic but I think they dropped it when he left.
|
|
|  |
 |
|
Solver
|
|
Apolyton Duke Of Something
|
 |
Latvia, Riga
Sep 2000 time: 07:29
|
|
Yes, Civ 3 AI does a very good job of colonizing land. Sometimes it's foolish (a 3-tile island 50 tiles away from closest land), but most of the time, it's good. With CtP2, I happen to get a lot of uncolonized land, especially after burning some AI cities...
So, maybe add the concept of "rebuilding" to the AI, where it, after the war is over, tries to somehow restore itself to pre-war status, rather than living with the decreased capabilities.
|
|
|  |
 |
|
st_swithin
|
|
10069
Nov 2002 time: 05:29
|
|
I'd like to see the entire AI system rewritten from the ground up.
CTP1 had a fuzzy logic system that, in THEORY, might've worked if there had been a defuzzifying method and about 99.999% less obfuscation.
CTP2 had a literal logic system which didn't allow for much fuzziness.
I know nothing of fuzzy logic, nor of how to defuzzify, but I'm sure someone out there can think of something.
"Put on your fuzzy logic thinking caps." -MrFrodo
|
|
|  |
 |
|  |
 |
|
hexagonian
|
 |
Gnawing on your mind...
Jun 1999 time: 23:29
|
|
quote: Originally posted by Peter Triggs @ Hexagonian:
IIRC, you more than once complained that the AI was ok until you got a science lead, at which point it was game over. I think I may have recently put my finger on why this is happening. Consider the following:
code:
AI_MAX_BEHIND_TECHNOLOGY_COST 0.5 0.5 0.7 0.7 0.9
AI_MAX_AHEAD_TECHNOLOGY_COST 1.3 1.3 1.2 1.2 1.1
As the game progresses these sequences converge to 1.0: by the end of the game the AI is getting no significant science bonuses or penalties regardless of it's relative strength. This is going into the next patch for CTC:
code:
AI_MAX_BEHIND_TECHNOLOGY_COST 0.5 0.5 0.4 0.4 0.3 ## should decrease through time
Here if the human is running away with the game, the AI gets more help to catch up rather than less. |
Actually, this is the way I had it set up in Cradle - there was a lot of this type of help (production, gold, food) for the AI civ languishing at the bottom in my CRA_Diff.DB file.
The problem was still tied into the sizes of the empires. By mid-game, when I was at the caps for the government I was in (30-40) I'd still see the small civs (4-8 cities) falling behind technologically. So' I'd like to see more civs close to the caps, because it would make the overall toughness of the game greater. I did give the AI a higher priority to build cities in Cradle 1.34-1.35, but that ended up opening another can of worms where civs would end up exceeding the cap.
Using the caps is a two-edged sword. It's supposed to be an equalizer, because it places a limit on expansionistic human players. Cradle has a SLIC file that allows captured cities to be disbanded, and allowing the cap to be avoided - but when I played single-player Cradle, I had a house rule not to disband cities. It made for a more interesting game, IMO.
But since the AI doesn't recognize it, the AI either stays well below it or expands beyond it with no regard to the unhappiness penalties that occur. The end result in that situation is a bunch of rioting AI cities that do the AI civ no good. And make the unhappiness penalties too small and the cap means nothing to the expansionistic human player.
This problem is compounded on gigantic maps because of the amount of land for settling. I tended to play Cradle on smaller maps, so I did not run into the revolt problems in my games.
This is why, out of all the issues regarding the AI, city cap management is the most critical for me. If we can nail this one down, I think you will see a greatly improved AI ...
Even if it means giving the AI the ability to raze unneeded cities.
And I would also like to hear if the Activision programmers ever played any of the Mods.
|
|
|  |
 |
|
Solver
|
|
Apolyton Duke Of Something
|
 |
Latvia, Riga
Sep 2000 time: 07:29
|
|
quote: Using the caps is a two-edged sword. It's supposed to be an equalizer, because it places a limit on expansionistic human players. Cradle has a SLIC file that allows captured cities to be disbanded, and allowing the cap to be avoided - but when I played single-player Cradle, I had a house rule not to disband cities. It made for a more interesting game, IMO.
But since the AI doesn't recognize it, the AI either stays well below it or expands beyond it with no regard to the unhappiness penalties that occur. The end result in that situation is a bunch of rioting AI cities that do the AI civ no good. And make the unhappiness penalties too small and the cap means nothing to the expansionistic human player.
|
I increased the cap somewhat myself, I found it otherwise that I have way too few cities for my satisfaction...
But point is, yes, AI is either an 8-city puke or a 30-city monster with 65 happiness at them. But, with the source, we can give the AI, say, a 0.2 multiplier for unhappiness bonuses...
|
|
|  |
 |
|
MrBaggins
|
|
My initial discussion on threat mapping was here:
http://apolyton.net/forums/showthre...326#post1713326
then I found some text on influence mapping:
here and here
The method I've been working on to 'process' the influence map, is to add influence to a map for each army, iteratively in all directions, for a multiple of its move, decaying the move by a terrain value, and using a flag to avoid reprocessing a square. The 'influence' is the strength of the army, and the multiple is the amount of turns you wish to predict.
I've been working on optimization, and trying to see if an abstract system just using distances will approximate the same thing, far computationally cheaper.
|
|
|  |
 |
|
MrBaggins
|
|
I thought the AI_MAX_BEHIND_ and AI_MAX_AHEAD_ options were based on a combination of factors... not just science/gold... and hence far less useful:
If the AI builds tons of obsolete units, for instance, but is falling behind in science and general economy, that doesn't show up on the power graph until far too late.
My thought as to a better solution to the science problem, is an "elastic lead" or "knowledge spread".
Consider if there were 8 players in a particular game. Civilization 1 researches a particular tech. All other civs researching that tech gain 1/7 of the total necessary points to research the goal. If another civ starts to research it, they gain a bonus at the start of research equal to (x/7) of the goal, where x is the number of civs already having researched the technology.
|
|
|  |
 |
|
MrBaggins
|
|
Peter:
I've seen and have been very impressed by the great work you've done on your mod. I can't help but feel however, that SLIC is the wrong place to implement good basic AI. Whatever you can do in interpretted code, you can do quicker (usually much quicker) in native code.
I feel that SLIC should have more "informational helpers" available to it, so most of what we wish to achieve could be done through simple conditions and strategy changes, rather than reams of code.
I think one of the fatal flaws in the system as it stands, is that it treats units as one of a very few types and doesn't have special handling for ships, transports/carriers and planes. I also feel that settlers plus an escort should be a special case, with specific definition.
I personally was a big fan of the army descriptors in CtP1 .fli's and thought they were a good solution to the problem, even if the rest of AI wasn't necessarily great.
|
|
|  |
 |
|
Dale
|
 |
Sir! Why do you keep clicking on me?
Dec 2000 time: 15:29
|
|
quote: Originally posted by MrBaggins
The method I've been working on to 'process' the influence map, is to add influence to a map for each army, iteratively in all directions, for a multiple of its move, decaying the move by a terrain value, and using a flag to avoid reprocessing a square. The 'influence' is the strength of the army, and the multiple is the amount of turns you wish to predict.
I've been working on optimization, and trying to see if an abstract system just using distances will approximate the same thing, far computationally cheaper. |
MrBaggins:
If you combine pathing using A* on your movement influence map, you can do the right thing, very quickly and very well. Also avoids "reprocessing a square". I've got my influence map putting neg influences on mountains/strong enemies/etc, and positive influences on roads/target/etc. Then through the pathing at it with a start and end co-ord. Quite simply you get the best path (from the A*) while avioding any obsticles (using the influence map). Very efficient. 
BTW, works fantastic for laying roads too. 
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:29. Apolyton Time is 00:29. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|