 |
|  |
 |
|
MrBaggins
|
|
A while back I was considering different AI mechanisms, but went on sabatical waiting to see if they'd actually release the source code. Now that they have... maybe time to continue the discussion?
I thought about approaching the issue of problem solving from a data centric POV, but with a programatic twist.
For example, consider AI's chosing technology.
You could (and CtP2 does) use an ordered list (per personality in the case of CtP2).
An issue with this approach is that its not reactive to circumstances.
An approach I considered was a text file, that assigns "base values" to certain options, then allows for conditions within the file, to assign modifiers (multiplication, division, addition, subtraction) to those base values, based on game state information.
These values form the basis for simple probability based choice. As a simple example, consider that the result of this file produces the following options (out of available techs) for the "next technology" of a particular AI.
Seafaring 3
Iron Working 5
Ceremonial Burial 2
In my conceptual system, there is a 3/10 chance of Seafaring being chosen, 1/2 for Iron Working and 1/5 of Ceremonial Burial... thus it will likely be Iron Working, but will not be predictable to the human opponent.
Essentially the AI, will be slightly unpredictable, but will probably build approapriately.
Consider how the preceeding information might be generated with an extremely simplified file.
code: AI_TECH_GOALS.TXT
Base
{
TECH_SEAFARING =1
TECH_IRONWORKING =1
TECH_CEREMONIALBURIAL =1
TECH_CODEOFLAWS =1
}
IF MAPSTATE(HomeContinentSize) < 300 //Home continent smaller than 300 tiles
{
TECH_SEAFARING *3
}
IF GAMESTATE(MilitaryGrowthDelta,10) < -25 //Miltary growth 25% lower than average over 10 turns
{
TECH_IRONWORKING +4
}
IF GAMESTATE(GovernmentCityCap,0) - GAMESTATE(PlayerCities,0) <5 //Current Player is within 5 cities of the city cap
{
TECH_CEREMONIALBURIAL +1
TECH_CODEOFLAWS +1
}
Of course the file would be significantly more complex than this, but would allow for rapid development of AI strategy and intuitive understanding of changes.
Multiple layers of conditions simulate considering a complex system. The probability ensures non-predetirmined behavior.
You could introduce messaging between goal files to reduce redundant expensive gamestate calls, and to introduce "personality" ala CtP2 within a flat system.
There would be GOAL files for General empire settings, General production, city specific production, city specific worker assignment and technology.
Thoughts? comments?
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:29
|
|
Randomness is good because for map dependant criteria (seafaring for example), playing on a given map type will allow for more unpredictability.
|
|
|  |
 |
|
MrBaggins
|
|
Its a psuedo-fuzzy system. The conditional operands on the values definitely are fuzzifying, but its less granular than a real fuzzy system.
The advantage is that it is much more approachable in human terms, easily extendable, and...
Has a very simple defuzzification process... the output using the values as probabilities.
The main issue with CtP1 fuzzy AI, as I recall was the defuzzification.
|
|
|  |
 |
|
Kull

|
|
El Paso, TX USA
Mar 1999 time: 22:29
|
|
Some proposals for a different approach to the CTP2 AI:
1) What if "civilization type" actually meant a different AI strategy? For example, some civs would just find war completely abhorent and would focus their attention on trade, science, or exploration. Others could be aggressive and miltaristic, with a set of strategies tuned toward that goal. On the surface this might sound even more diffcult than programming a "single" AI, but in reality it's easier - after all, it simply narrows the list of options that each AI mode has to choose from (as opposed to "one strategy fits all" programming which tries to mimic the human ability to handle every eventuality). Some additional features of this kind of system could include:
- hard coded (but preferably "moddable") advantages such as lower unit or building costs, faster research times, and/or greater movement allowances depending on the AI "focus".
- strategies that change. For example, continued warfare against a trading civ could "flip" them to militaristic.
- similar civs types would be more likely to ally (or even merge!)
- AI mode could be tied to government type (another way in which they might alter over time).
2) Speaking of "one strategy fits all", that wasn't true in human history, so why is it always a feature of civ games? Sure there are minor cultural tweaks, but in the end it's all about building cities, researching techs, and building an army large enough to dominate the planet. But not all cultures chose this path, and the fact that it's the current winner doesn't mean that no other options should be available at the start. One interesting alternative would be two or three "nomad" civs that roam around a defined area (such as was true in the north american plains or the russian steppe) that generate gold and units directly from the terrain (no city/building interface) and which have the ability to explode into vast conquering hordes from time to time. Another alternative would be a piratical "city sacker" civ akin to the Dark Ages Vikings or the Sea Peoples of the Late Bronze Age. The common thread here is a narrowly focused AI that adds an air of extreme unpredicability to the early and middle stages of the game.
3) Not specifically an AI issue, but I'd think real hard about whether techs should even be AVAILABLE for trade. Casting an eye back on history, let's face it - Civilizations DID NOT TRADE OR SELL KNOWLEDGE! Did it spread out beyond the originating civ? Sure. But this was usually a result of conquest or as a side benefit from trade or a common religion (or - espcially in the modern world - via spies). But kings flat out didn't trade techs and maybe it's time we thought about eliminating this utterly ahistorical feature of the civ genre. Personally, I think it would greatly enhance game play. One of the neat features of the Cradle mod is that it's almost impossible to trade for techs, and as a result you HAVE to pay attention to research (by contrast, what's going on in Civ3 is an abomination). I'm not saying it should be impossible to acquire techs from other civs, but please consider restricting it to "real life" methods. (And maybe include a toggle button for those who simply can't imagine life without the ability to trade or purchase technologies!)
|
|
|  |
 |
|
cue
|
|
Sorry to just jump in like this.
But i think this sounds very good.
If you conduct trade you get substantial financial gain, but technology/science should "leak" between the trading civilizations. This could help keep the game at a balance.
(Maybe this should be in another thread, Feel free to move this).
quote: Originally posted by Dale
Some sort of "tech through trading" should be available though.
A lot of spies were traders who went into other nations, looked at the technology that nation had, then took the info back to their own nation. On the way they did honest trading as well. |
|
|
|  |
 |
|
MrBaggins
|
|
quote: Originally posted by Kull
Some proposals for a different approach to the CTP2 AI:
1) What if "civilization type" actually meant a different AI strategy? For example, some civs would just find war completely abhorent and would focus their attention on trade, science, or exploration. Others could be aggressive and miltaristic, with a set of strategies tuned toward that goal. On the surface this might sound even more diffcult than programming a "single" AI, but in reality it's easier - after all, it simply narrows the list of options that each AI mode has to choose from (as opposed to "one strategy fits all" programming which tries to mimic the human ability to handle every eventuality). Some additional features of this kind of system could include:
- hard coded (but preferably "moddable") advantages such as lower unit or building costs, faster research times, and/or greater movement allowances depending on the AI "focus".
- strategies that change. For example, continued warfare against a trading civ could "flip" them to militaristic.
- similar civs types would be more likely to ally (or even merge!)
- AI mode could be tied to government type (another way in which they might alter over time).
2) Speaking of "one strategy fits all", that wasn't true in human history, so why is it always a feature of civ games? Sure there are minor cultural tweaks, but in the end it's all about building cities, researching techs, and building an army large enough to dominate the planet. But not all cultures chose this path, and the fact that it's the current winner doesn't mean that no other options should be available at the start. One interesting alternative would be two or three "nomad" civs that roam around a defined area (such as was true in the north american plains or the russian steppe) that generate gold and units directly from the terrain (no city/building interface) and which have the ability to explode into vast conquering hordes from time to time. Another alternative would be a piratical "city sacker" civ akin to the Dark Ages Vikings or the Sea Peoples of the Late Bronze Age. The common thread here is a narrowly focused AI that adds an air of extreme unpredicability to the early and middle stages of the game.
3) Not specifically an AI issue, but I'd think real hard about whether techs should even be AVAILABLE for trade. Casting an eye back on history, let's face it - Civilizations DID NOT TRADE OR SELL KNOWLEDGE! Did it spread out beyond the originating civ? Sure. But this was usually a result of conquest or as a side benefit from trade or a common religion (or - espcially in the modern world - via spies). But kings flat out didn't trade techs and maybe it's time we thought about eliminating this utterly ahistorical feature of the civ genre. Personally, I think it would greatly enhance game play. One of the neat features of the Cradle mod is that it's almost impossible to trade for techs, and as a result you HAVE to pay attention to research (by contrast, what's going on in Civ3 is an abomination). I'm not saying it should be impossible to acquire techs from other civs, but please consider restricting it to "real life" methods. (And maybe include a toggle button for those who simply can't imagine life without the ability to trade or purchase technologies!) |
A lot of 1 & 2 is already represented in the CtP2 AI, in the form of personalities. These are a good idea. The problem is that the behaviors aren't different enough. You don't want to give different civs different bonuses. Thats illogical... all civ's are basically the same, their differences come in different resources, and behaviors.
The problem with radically different behaviors, is that to include them in the game, they have to be viable.
An economic approach. A resource approach (like communism, but successful.) A diplomatic approach. A military approach. A scientific approach.
We have to consider ways of ensuring that there isn't just 2 ways to play CtP2. Expansionist/Science Victory and Expansionist/Military Victory.
I considered the problem a long while back, and came upon an idea based on OCC challenge. Make a government with extremely limited empire size, and punitive distance penalties. Give them superb city bonuses. Of course, it will need to be balanced, but could simulate countries that either have very limited space or are naturally insular.
3. I agree. Insta-advance is dumb. Including trade as a factor in tech spread would simulate what needed to be simulated, well. The fact that the AI's are mostly behind tech wise in CtP means that tech trading is almost never worthwhile. Usually the AI's are pissed at the human too... of course. Civ3 is the obvious lesson why easy diplomatic tech trading=bad thing.
|
|
|  |
 |
|
MrBaggins
|
|
Juicy deals are a problem though. Having easy tech trading devalues human research, and focuses the game on economics and military issues.
This leads us to consider making tech trading very difficult. If its difficult enough, to rarely happen, though... why not just scrap it, and include a better mechanism?
|
|
|  |
 |
|
centrifuge
|
|
Kind of along those lines, it is too easy to get a diplomatic victory with CTP2, simply by threatening war against the AI in order to make it sign peace treaties and alliances after the first meeting with them.
This is certainly something for the future, after other bugs have been worked out, but it needs to be addressed in order to make the game play more robust and challenging.
|
|
|  |
 |
|
MrBaggins
|
|
An issue with CtP2 AI, is, among other things, a problem dealing with naval invasions, and problems utilizing specific units like missiles, and to a certain degree airpower in general.
Part of the issue is a very flat design in definition of how armies, navies and airwings are constructed.
Units are catagorized in flat catagories. The catagories are hard coded.
Improving army behavior and coordination is important, but also important is flexible definition. Thoughtful, reactive and flexible construction of armies is important.
Army construction is obvious to seasoned CTP2 vets...
For instance, to defend, mix good defensive units, like phalanxes, with ranged units like archers. Movement rate is unimportant for a garrison, although troop types should be evenly distributed across these catagories. You might consider some counter bombard artillery if you know your enemy will field artillery.
With an attacking force you may wish to have strong flanking units, and siege units are a consideration too, but you might, as a human player, chose to build fast (without bombard) and slow (with flanking) stacks, for different purposes.
Adding in special units, and considering settler escort, and so on and so forth add much complexity.
That doesn't begin to address varied naval tasks such as Strike/Bombard groups, Sub hunters, Transport Convoys, and Carrier groups, or air wings.
CtP1 went a long way in introducing flexible and intuitive ways to define how armies get constructed (and CtP2 is a step backwards,) but we have the opportunity to improve on even that system.
The following is an example of how an example army definition might be made.
code:
{garrison_early}
SIZE_MIN 1
SIZE_MIN_REC 2
SIZE_REC 4
SIZE_MAX 4
1:8:UNIT_LEGION
1:6:UNIT_PHALANX
1:4:UNIT_WARRIOR
1:2:UNIT_ARCHER
2:8:UNIT_ARCHER
2:6:UNIT_LEGION
2:4:UNIT_PHALANX
2:2:UNIT_WARRIOR
3:8:UNIT_LEGION
3:6:UNIT_PHALANX
3:4:UNIT_WARRIOR
3:2:UNIT_ARCHER
4:8:UNIT_ARCHER
4:6:UNIT_LEGION
4:4:UNIT_PHALANX
4:2:UNIT_WARRIOR
{end}
The first line describes the identifier of the definition, then the SIZE lines define the absolute minimum and maximum, recommended minimum and optimum size of the unit. The other lines are the actual definition of the units that should be used.
The first number is the "troop number". All the "1's" define the how the first troop should be chosen, then the "2's" the second, and so on, til the max is reached.
The second figure, after the ":" is the priority. A higher number is a higher priority.
Lastly, there is a unit identifier after the next ":".
In the example, an early garrison is defined, with a minimum of 1 and maximum of 4 units specified. 2 is a recommended minimum number of units and 4 is an optimum.
The first unit is preferrably a defensive units, with reducing priority for less capable units. Lastly, if no substitute is available, an archer is specified.
The second unit is reversed, with preferrably a ranged unit, then a defensive unit, in reducing priority.
Thus you can specify both best case and less optimal solutions for army definitions, with limits too.
---
thoughts? comments?
|
|
|  |
 |
|
Gilgamensch
|
|
France
Jun 2002 time: 06:29
|
|
MrBaggins,
sounds like a nice idea , BUT
1.) What about inland cities? They shall have a lower priority, so the priority itself should be more a variable, which could/would be changeable according to location/needs.
2.) Do we want to include 'automatic' upgrades to never units?
3.) Depending how the enemy, espacially the human attacks, this should be taken into consideration as well. Like archer's don't help a lot against catapults, as they can bombard.
And just a thought, shall we not be able to introduce it as a one-liner, just kind of a table:
| Unittype | Warrior | Archer | continue |
| Warrior | 1 | 2 |
| Archer | 1 | 2 |
I hope you understand my idea. This we actually could put in a txt file, making it easier to mod...........
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:29
|
|
When the AI is tasking it's units, it prepares a big list where it matches it's armies against possible goals. It then does a number of passes through this list, depending on the difficulty level that's been chosen, and executes some of those matches. Here's where this is done:
code:
cycle++;
sint32 diff_cycles = 0;
if (g_theGameSettings->GetDifficulty() == (LEVELS_OF_DIFFICULTY - 1))
diff_cycles = 2;
if ( cycle < Scheduler::s_max_match_list_cycles + diff_cycles)
{
g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_ProcessMatches,
GEA_Player, playerId,
GEA_Int, cycle,
GEA_End);
}
Both LEVELS_OF_DIFFICULTY and s_max_match_list_cycles are set at 6 elsewhere. By increasing the number of passes that the AI makes through its list, we can make it do more things. Azmel2 once remarked that he wished that he'd exposed this possibility. Well, now we've got the chance. Any suggestions?
Last edited by Peter Triggs on 04-11-2003 at 20:53
|
|
|  |
 |
|
Gilgamensch
|
|
France
Jun 2002 time: 06:29
|
|
Peter,
I would need more information before being able to comment further. I haven't got anything installed of it, so don't know what is reffering to what .....sorry........
|
|
|  |
 |
|
MrBaggins
|
|
Gilgamensch>
The principal I was explaining wasn't the entirety of how the AI constructs its armies. Its the way that an AI designer hints how the types of armies he uses should be constructed.
Another AI file would describe and give different preferences for different "missions" or "tasks" that get created. City garrioning is an obvious and necessary mission. I'd contend that you should be able to conditionally specify different Army defintions to different tasks, based on game state information, such as state of diplomacy, general threat levels, geographic situation, or myriad other issues.
As far as upgrades, I don't think they will drastically effect the system: units can be upgraded, but their essential capability; ranged attack, good defense or so on, shouldn't be destroyed in the process. How the army is initially constructed is important, in my mind, and it would only be improved by upgrades, so the AI wouldn't me crippled by the process.
Peter> Obviously we have to start by playing around with the existing AI.
The exact point you made about the hard coded bidding iterations, was in the back of my mind. Perhaps we should make it an exposed constant. Play testers could muck around with it, and report?
|
|
|  |
 |
|
Gilgamensch
|
|
France
Jun 2002 time: 06:29
|
|
quote: Originally posted by MrBaggins
Gilgamensch>
The principal I was explaining wasn't the entirety of how the AI constructs its armies. Its the way that an AI designer hints how the types of armies he uses should be constructed.
Another AI file would describe and give different preferences for different "missions" or "tasks" that get created. City garrioning is an obvious and necessary mission. I'd contend that you should be able to conditionally specify different Army defintions to different tasks, based on game state information, such as state of diplomacy, general threat levels, geographic situation, or myriad other issues.
As far as upgrades, I don't think they will drastically effect the system: units can be upgraded, but their essential capability; ranged attack, good defense or so on, shouldn't be destroyed in the process. How the army is initially constructed is important, in my mind, and it would only be improved by upgrades, so the AI wouldn't me crippled by the process.
|
MrBaggins,
don't disagree with it. My idea was mainly like yours, but slightly changed.
Instead of being hardcoded, I was thinking of using a txt-file with the stack infomormation in it. This would offer (for me) 2 advantages: 1.) You could change it easily later (like for mod's scenarios) 2.) it would be far more flexible.
And all what I suggested, was to put it in this txt-file, in kind of a table, comma-telimited. that was all. So the computer could read it, which units to stack and which ones not. I was a bit lazy to complete the table..........
So it should like this in the txt-file:
UNIT_WARRIOR,1,2,3,4,0,0,(continue as needed for all units),12,1,6,6,X,X,......(max in stack)
UNIT_HOPLITE,1,2,3,3,0,0,0,0,0 (........),12,12,6,6,X,X,.....(....)
This would mean:
for WARRIOR:
Take Warrior (1) if nothing else available or existing.
Take Hoplite (2) if available or existing.
Take Archer (3) if available or existing.
Take Catapult (4) if available or existing.
If the value is 0, this would mean, don't use it together with this unit. This might also be a good way to 'teach' the AI, what to stack and what not to stack..........
The numbers would also specify the base priority of what to use.
The numbers behind the first bracket, would indicate the maximum number to be used against the unit.
So 12 Warrior maximum if only Warrior available.
Maximum of 6 Warriors together with Hoplite.
Again maximum of 6 Warriors together with Archer and so on......
But as the first part would describe the priority to build for stacking, we shall never really have anymore Warriors after Hoplite......
For production-queues:
We might be able to use this information as well. Check the stacks, what is missing and choose according to the priority.
let me know what you think (I hope I did it clear enough )
|
|
|  |
 |
|
MrBaggins
|
|
You should note, Gilgamensh, that ANY change I'm considering, if it isn't process, but is data, or condition, will be in a human readable, and modifiable text file. This is the only way to ensure the ultimate modifiability of the AI engine. Important since there will be play testing plus changing needed to get a new system to work optimally.
|
|
|  |
 |
|
MrBaggins
|
|
There are some limitations to the system as is. Not least being its largely hard coded nature. I'd really don't see any technical reason why it can't be something better, ultimately.
Having said that, its a long term project, and I'd be happy with just tweaking the existing AI that we have to start with.
|
|
|  |
 |
|
MrBaggins
|
|
Well.. until I have a viable compilable source, I can only theorize, but I haven't forgotten any of the prior discussion on AI.
The AI needs to deal better with happiness on a more city level than it is. Those entertainers are life savers. It needs to do that, AND optimize the balance of happiness/production at the empire level.
|
|
|  |
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
|
|
|
|
|
|