Thread Tools
Old February 28, 2002, 09:19   #1
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 18:08
Local Date: October 31, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
How does the AI think?
Can anyone explain me what is priority, MaxEval and MaxExec? How those commands works? And how they interact with the Goals in Goals.txt?

Is There a formula? Or even a theory or thought of one?
Anything?

Thanks in advance.
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand
Pedrunn is offline  
Old February 28, 2002, 09:44   #2
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 23:08
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
This ought to keep you busy for a while. Let us know if you have any questions
__________________
Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery
Locutus is offline  
Old February 28, 2002, 14:34   #3
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 18:08
Local Date: October 31, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
Thanks Locutus,

Now it is hands at work to have fun.

Something is wrong with that sentence.
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand
Pedrunn is offline  
Old February 28, 2002, 17:31   #4
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 18:08
Local Date: October 31, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
I read the interview, although i did not went further in the thread.
It really is explanatory.

Still i have some question. But i am aware the simplicity of them. Any experienced AI modder can help.
So far only 2 of them.

1) Richard Explain some strategies like defense, careful and agressive start. Still what about the major 6: Default, Scientist, militaristic, Economic, Ecotopian and Diplomatic. When they are enacted? Seems self-explanatory, but it inst. First i thought it had something to do with the civ or the personality of the leaders. I looked over the files and nothing to connect!
So, Could someone explain me when those strategies are triggered?

2) Same thing about the STRATEGY_ATTACK, STRATEGY_SIEGE and STRATEGY_DEFEND. When are they triggered? They just complement specific parts of the major ones in specific situations?
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand

Last edited by Pedrunn; February 28, 2002 at 19:23.
Pedrunn is offline  
Old March 1, 2002, 03:37   #5
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 23:08
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Quote:
Originally posted by Pedrunn
I read the interview, although i did not went further in the thread.
It really is explanatory.
The rest of the thread contains some interesting stuff as well, when you have the time you should read that as well (if you weren't planning on doing so already).

Quote:
1) Richard Explain some strategies like defense, careful and agressive start. Still what about the major 6: Default, Scientist, militaristic, Economic, Ecotopian and Diplomatic. When they are enacted? Seems self-explanatory, but it inst. First i thought it had something to do with the civ or the personality of the leaders. I looked over the files and nothing to connect!
So, Could someone explain me when those strategies are triggered?
I'm afraid I don't know the details of this from the top of my head, but I'm fairly certain they're related to the personalities.txt file. Wes or Dave or someone might know more about this...

Quote:
2) Same thing about the STRATEGY_ATTACK, STRATEGY_SIEGE and STRATEGY_DEFEND. When are they triggered? They just complement specific parts of the major ones in specific situations?
We don't know exactly when they are triggered (yes, they complement the major strategies in specific situations). We've run some tests for the MedMod in the past but the results were inconclusive. Personally I'm in favor of disabling those strategies altogether and adding a bunch of new ones, which can be controlled from SLIC. This way we would know and understand exactly what is going on and thus make a much better AI. I don't have too much time to play around with it myself though...
__________________
Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery
Locutus is offline  
Old March 1, 2002, 14:53   #6
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 23:08
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originnally posted by Locutus
I'm afraid I don't know the details of this from the top of my head, but I'm fairly certain they're related to the personalities.txt file. Wes or Dave or someone might know more about this...
From the documaention available here at Apolyton about the personalities.txt I can quote this:

Quote:
Discovery - Sets the default state for the Strategies. Effect of these default states is defined in Strategies.txt Valid values: Scientist, Military, Economic, Ecotopian & Diplomatic.
So it looks that the part about the strategies is hard encoded.

For your second question Pedrunn: Peter got the suspicion that strategies like STRATEGY_ATTACK, STRATEGY_SIEGE and STRATEGY_DEFEND aren't used or only used seldom.

I found another interesting thing in this documentaion:

Quote:
ThreatFollowThrough - Percent chance to follow through on threats. Valid value: 0.0 - 1.0
So I think that would mean if the value is set to 0.9 the AI will accept my proposals in 90% of the cases after a thread.

That would explain why this strategy works as the values are between 0.7 and 0.9:

What about a map exchange? If not than war.

What about a peace treaty? If not than war. Although the AI will attack me some turns later anyway.

What about a trade treaty? If not than war.

What about an alliance? If not than war.

For me it looks that the threat response logic is also a little bit randomized. Although I have the feeling if I am weak my threats are rejected more often and the AI rejects also city demands, OK I got a city after a threat for a tech once, but it is to easy to make treaties this way.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old March 1, 2002, 20:44   #7
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 15:08
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
I agree with Peter regarding the Attack, Defend and Seige strategies. Either they are not used at all, or only for a few turns immediately after war is declared.
One good way to tell would be to alter the unit readiness levels. When I first started the Medpack II, I set the readiness levels to alert for the personality types, and to war for the 3 war strategies. If I remember correctly, I never did see the AIs at war readiness. I set the readiness settings to war for the personality types before long since they needed to be at war to fight barbarians in the early game. (There was a strategy setting in Ctp1 which only lasted for the first 100 or so turns, and had a default setting of war for everyone, along with increased expanison and exploration settings.)

In both games, the theory seemed to be to set up a "code structure", for lack of a better term, which contained code for all of the "neat ideas" that the designers wanted to try out. Then when they started play-testing, they altered, added to, or cut out pieces of this structure as they went along. Unfortunately, there does not seem to have been someone tasked with making sure that these changes did not conflict with or mess up other parts of the code.
In short, there was no Sid Miere or Brian Reynolds who built the game from the ground up as a labor of love and kept a picture of the overall game in his head (or on his desk).
So, in closing, just because the code is there does not mean it is used or that the AI will know how to deal with it should you activate it using slic. This is what worries me in activating the terraforming code that we are debating in another thread.
__________________
For Civ IV: The Medmod V v1.0.
For Medieval: Total War- The Medieval Mod IV v4.0.
The entire Medmod series is available at my Apolyton-hosted webpage.
WesW is offline  
Old March 1, 2002, 21:26   #8
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 21:08
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Hi, Pedrunn

Quote:
First i thought it had something to do with the civ or the personality of the leaders. I looked over the files and nothing to connect!
You were right first time. In civilisation.txt, each civ can have either a male or female leader and in both cases the leader is assigned a personality as in:

PHP Code:
GREEK    #2    
    
{    
    
CIV_LEADER_NAME GREEK_LEADERM_NAME    
    CIV_LEADER_NAME_FEMALE GREEK_LEADERF_NAME    
    CIV_PERSONALITY_MALE 
"PERSONALITY_CEASAR"
    
CIV_PERSONALITY_FEMALE "PERSONALITY_TELLER" 

Suppose that the game has decided that the Greek leader is male so that it assigns him the CEASAR personality. It then constructs the strategy he's going to use based on the data in personalities.txt:

Quote:

PERSONALITY_CEASAR {
Exploration: Medium
Expansion: Maximum
Discovery: Military
Conquest: Agressive
Trustworthiness: Lawful
Alignment: Neutral
The last three flags are diplomacy things and about all we know about them is:

Quote:

// This describes the liklihood that the AI will attack. This can
// also be considered the disposition of the personality.
Conquest: Agressive, Neutral, Passive

// This describes how likely the AI will be to violate agreements
// and follow through on threats. It also specifies how the
// regard of an AI will be changed by the dishonest actions of
// others.
Trustworthiness : Chaotic, Neutral, Lawful

// This describes in general terms the methodology used by an AI
// to accomplish its goals and whether or not the AI cares if its
// actions cost the regard of other empires. Evil actions might
// include killing settlers, the use of slavery and the first
// strike launch of nuclear weapons. The regard consequences of
// an evil act will be less for an evil empire than a neutral or
// good one.
Alignment : Evil, Neutral, Good
The programmers had plans to expose more of the diplomacy system but the company dropped the game before they could do it.

The first three flags, though, link directly to strategies.txt. The Discovery one is basic: it means that the Greek leader will essentially pursue the MILITARIST_DEFAULT strategy. But that's not all, if this was all there was to it the AI would only have 5 strategies: STRATEGY_SCIENTIST_DEFAULT, STRATEGY_MILITARIST_DEFAULT, STRATEGY_ECONOMIC_DEFAULT, STRATEGY_ECOTOPIAN_DEFAULT, and STRATEGY_DIPLOMATIC_DEFAULT.

(BTW, STRATEGY_DEFAULT is the data that initializes the game for a human player. When you start the game the computer has to have some data to go by, this is where it comes from. It's also inherited by the Barbs.)

So the other two flags, Exploration and Conquest, are used to refine these 5 basic strategies. How? Well, a strategy is just a bunch of data and Locutus or Lou Wigman (who I believe has years of experience in DataBase Programming) can probably describe this better than me, but here goes.

As Richard explained,

Quote:
In the personalities.txt file (again) each personality has a Exploration: setting. If Exploration: Minimal is set, then
STRATEGY_EXPLORE_NEAR is used, Exploration: Medium loads STRATEGY_EXPLORE_FAR and STRATEGY_EXPLORE_WIDE is loaded by
Exploration: Wide.

If the Exploration: Wide or Maximum [? I think he meant Medium] are set, then STRATEGY_AGRESSIVE_START is used, otherwise STRATEGY_CAREFUL_START is loaded, btw.
In the above example, then, the game will initialize the Greeks with the MILITARIST_DEFAULT strategy and then load STRATEGY_EXPLORE_WIDE, STRATEGY_SETTLE_COMPACT, and STRATEGY_AGRESSIVE_START. The data in these strategies 'overwrite' (this is a metaphor, it's probably some sort of database union operation) the corresponding data in STRATEGY_MILITARIST_DEFAULT so that this latter overwritten data is in fact never used. After the overwriting, the resulting set of data constitutes the Greek's current strategic state.

The same applies to the other personalities. It seems to be a rather odd way of doing this (there's only 9 personalities, so they could have just had 9 default personality strategies) but it allows for some extensibility. In the Alex scenario, Tony Evans defined three new personalities:

PHP Code:
PERSONALITY_ALEXANDER1 {
  
ExplorationMinimal
  Expansion
Minimum
  Discovery
Military
  Conquest
Passive
  Trustworthiness
Lawful
  Alignment
Good

  StrongGreeting DIP_GREETING_FIRST_FOREIGN_1
  WeakGreeting DIP_GREETING_FIRST_FOREIGN_2

  Description PERSONALITY_CEASAR_DESCRIPTION

  ThreatFollowThrough 0.9
}

PERSONALITY_ALEXANDER2 {
  
ExplorationMinimal
  Expansion
Minimum
  Discovery
Military
  Conquest
Neutral
  Trustworthiness
Neutral
  Alignment
Neutral

  StrongGreeting DIP_GREETING_FIRST_FOREIGN_3
  WeakGreeting DIP_GREETING_FIRST_FOREIGN_3

  Description PERSONALITY_DEGAULLE_DESCRIPTION

  ThreatFollowThrough 0.7
}

PERSONALITY_ALEXANDER3 {
  
ExplorationMedium
  Expansion
Average
  Discovery
Military
  Conquest
Agressive
  Trustworthiness
Chaotic
  Alignment
Evil

  Description PERSONALITY_STALIN_DESCRIPTION

  StrongGreeting DIP_GREETING_FIRST_FOREIGN_4
  WeakGreeting DIP_GREETING_FIRST_FOREIGN_4

  ThreatFollowThrough 0.5

and then assigned them to the scenario's various AI players. (In a somewhat devious way: you have to go to the scenario's civ_str.txt to find out that, e.g., Australia is actually the Persian Empire.)


All the other strategies in strategies.txt are loaded in special situations where again they overwrite the data in the AI player's current strategic state and constitute a transition to a new strategic state. Unfortunately, as Locutus mentioned about the war strategies, we really don't have any idea of what triggers these transitions.

There is one comment that Richard made about the defense strategies:

Quote:
At the beginning of each turn, the Maximum Threat for an AI is computed, and as the threat increases, the minimum garrison in each city increases. Essentially this is a way to make sure the AI protects its cities with more units when things get more dangereous later in the game. If you add a new strategic state that is triggered every turn (with a priority > 1000 or so) which redefines the garrison counts, then you can use your own system. I forget the actual threat levels and don't have the code available right now to check when each level is invoked.
The problem here is that I don't think there's any SLIC function that returns this "Maximum Threat" so we'd have to write our own. Assuming we did this, we could then put whatever data we wanted into those defense strategies and put in a handler like:

Code:
HandleEvent(NextStrategicState) 'LoadDefenseStrategies' pre {

int_t MaxThreatVal;
       
    MaxThreatVal=GetThreatTo(player[0]);
    if (MaxThreatVal<100) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_NONE),1500);
    }
    elseif (MaxThreatVal<300) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_VERY_LOW),1500);
    }
    elseif (MaxThreatVal<500) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_LOW),1500);
    }
    elseif (MaxThreatVal<700) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_MEDIUM),1500);
    }
    elseif (MaxThreatVal<900) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_HIGH),1500);
    }
    else{
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_VERY_HIGH),1500);
    }
}
But we're not stuck with using the strategies that are already there in strategies.txt. Joe's document "AI Modification via SLIC" contains what is actually a good (although very condensed) description of how we can use SLIC to get the game to use our own strategies. I think Martin G and player1 did some stuff along these lines but I can't remember where.
Peter Triggs is offline  
Old March 2, 2002, 08:31   #9
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 18:08
Local Date: October 31, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
Quote:
Originally posted by WesW
I agree with Peter regarding the Attack, Defend and Seige strategies. Either they are not used at all, or only for a few turns immediately after war is declared.
This is good idea. The Ai must be more agressive after declared war. Too bad we are not certain about that and how long it last. Maybe a slic to control that would be good.

Quote:
Originally posted by Peter Triggs
Suppose that the game has decided that the Greek leader is male so that it assigns him the CEASAR personality. It then constructs the strategy he's going to use based on the data in personalities.txt:
I got that from Martins explanation. But can i add new personalities? and remove old ones? If so, do we have to do somethimg before besides change the CIV_PERSONALITY in civilisation.txt.

Quote:
Originally posted by Peter Triggs
The programmers had plans to expose more of the diplomacy system but the company dropped the game before they could do it.

Quote:
Originally posted by Peter Triggs
(BTW, STRATEGY_DEFAULT is the data that initializes the game for a human player. When you start the game the computer has to have some data to go by, this is where it comes from. It's also inherited by the Barbs.
You mean the Barbs change Strategy over the time?



Quote:
Originally posted by Peter Triggs
Code:
HandleEvent(NextStrategicState) 'LoadDefenseStrategies' pre {

int_t MaxThreatVal;
       
    MaxThreatVal=GetThreatTo(player[0]);
    if (MaxThreatVal<100) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_NONE),1500);
    }
    elseif (MaxThreatVal<300) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_VERY_LOW),1500);
    }
    elseif (MaxThreatVal<500) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_LOW),1500);
    }
    elseif (MaxThreatVal<700) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_MEDIUM),1500);
    }
    elseif (MaxThreatVal<900) {
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_HIGH),1500);
    }
    else{
	ConsiderStrategicState(player[0],StrategyDB(STRATEGY_DEFENSE_VERY_HIGH),1500);
    }
}
And what about the hard-coded defense change. It became unusefulwith thiscode. As i compare it from Richard Meyer Explanation, they both work exacly the same.

Quote:
Originally posted by Peter Triggs
But we're not stuck with using the strategies that are already there in strategies.txt. . I think Martin G and player1 did some stuff along these lines but I can't remember where.
I have seen those threads

Quote:
Originally posted by Locutus
Personally I'm in favor of disabling those strategies altogether and adding a bunch of new ones, which can be controlled from SLIC. This way we would know and understand exactly what is going on and thus make a much better AI. I don't have too much time to play around with it myself though...
Agreed. But only by disabling what was written by the programs we can achive that.
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand
Pedrunn is offline  
Old March 2, 2002, 18:25   #10
player1
Emperor
 
player1's Avatar
 
Local Time: 23:08
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Hi, just one qick info about strategies.

As far as I know, while AI is in peace it doesn't use any of them, while when it is in war is uses ONLY SEIGE startegy.

But, sometimes it looks like it goes back to normal start. while in war.


Personally I think that having a trigger wich activates 2 or 3 starteigies
randomly every turn:
-one turn: Bombard with planes
-second tuen: attack with Tanks-
-etc...

I think sombody did this for WW2 scenario.



P.S.
All this mystic is exsisting because Activison REMOVED FLI files (CTP1) which controlled AI stratgy activation sequence.

Why did they removed that?
player1 is offline  
Old March 4, 2002, 09:30   #11
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 18:08
Local Date: October 31, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
I am making some modmaking but i have bumped into a problem.
The AI isnt building enough caravans and has negative gold imput!!!

How can i change the AIs atitude towards trade?

And can someone please write a code for me?
I want to change the the AIs strategy to something like STRATEGY_GOLD_RUSH everytime the gold imput is negative or (if not possible) when AI gold reserve reachs zero.
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand

Last edited by Pedrunn; March 4, 2002 at 09:36.
Pedrunn is offline  
Old March 4, 2002, 10:17   #12
player1
Emperor
 
player1's Avatar
 
Local Time: 23:08
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Quote:
Originally posted by Pedrunn
I am making some modmaking but i have bumped into a problem.
The AI isnt building enough caravans and has negative gold imput!!!

How can i change the AIs atitude towards trade?

And can someone please write a code for me?
I want to change the the AIs strategy to something like STRATEGY_GOLD_RUSH everytime the gold imput is negative or (if not possible) when AI gold reserve reachs zero.
Maybe give higher priority to caravans in build_list? (closer to top)
Don't remebemr what I used in my MOD (so long time has pased from last time playing&MODing CTP2).

Check build lists in MedMOD, Cradle, Apolyton and (of courese) my own mod (MyMod v0.99, can be found in these threads).
player1 is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 17:08.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team