Announcement

Collapse
No announcement yet.

How does the AI think?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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

    Comment


    • #3
      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

      Comment


      • #4
        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?
        Last edited by Pedrunn; February 28, 2002, 19:23.
        "Kill a man and you are a murder.
        Kill thousands and you are a conquer.
        Kill all and you are a God!"
        -Jean Rostand

        Comment


        • #5
          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).

          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...

          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

          Comment


          • #6
            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:

            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:

            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!"

            Comment


            • #7
              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.

              Comment


              • #8
                Hi, Pedrunn

                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:


                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:


                // 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,

                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:

                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.

                Comment


                • #9
                  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.

                  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.

                  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.

                  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?



                  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.

                  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

                  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

                  Comment


                  • #10
                    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?

                    Comment


                    • #11
                      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.
                      Last edited by Pedrunn; March 4, 2002, 09:36.
                      "Kill a man and you are a murder.
                      Kill thousands and you are a conquer.
                      Kill all and you are a God!"
                      -Jean Rostand

                      Comment


                      • #12
                        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).

                        Comment

                        Working...
                        X