Announcement

Collapse
No announcement yet.

Strategies and Goals

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strategies and Goals

    a small analysis on the goals.txt and the strategies.txt from an answer of Azmel to a mail of mine


    For every goal type record in Goals.txt, there is a corresponding entry in one or more of the strategy records in strategies.txt. Each GoalElement specifies (for that particular strategy) what the priority is for performing a particular goal relative to other goals. The priority is sometimes also refered to as the raw priority. Before any units are assigned to a goal, all goals of a particular type are sorted based on their raw_priority modified by any positive or negative bonuses for that goal type from it's Goals.txt record. Only the top "MaxEval" number of goals are ever matched to units. The MaxEval number can be absolute (ie. the best three goals) or relative (ie. two per city, or best four goals if we have two cities). If you increase the MaxEval attribute, you increase the pool of goals that the AI will consider, and usually improve intelligence at the expense of processing speed. If MaxEval is set to 0, then no goals of this type will be performed. The MaxExec field limits the number of a particular goal type that will be performed. This lets you consider the 10 best seige goals, but only actually seige the best two cities so that your troops don't get too spread out.

    In general, goals execute from highest to lowest priority. The defense goal type usually has the highest priority so that units will be assigned to defend cities first, and then assigned to seige cities and perform other goals. For example, if the GoalElement for GOAL_ATTACK has a higher priority than for GOAL_SEIGE, then AI units will first try to attack enemy armies, and then with any remaining unassigned units, try to seige enemy cities. However, if two goals have very close raw priorities, then the match priority becomes more important. The match priority is computed based on how good a match a particular army is for a specific goal. In general, the closer an army is to a goal, the better it's match. That way even when seige goals have a higher raw priority, an army right next to an enemy unit will attack it rather than move 20 cells to seige a city.

    Hope this brief explaination helps. Although it's a complicated system, with a little work it should be possible for anyone interested enough to tweak and customize.


    Wes, forget the units and wonders, get into these two files!!

  • #2

    I've tried modifying some of these goal priorities. Even set the GOAL_SEIGE to like a million or so. It didn't help one bit.

    perhaps, the 2nd aspect of azmel's comment, i.e. the match priority over-riding the raw priority might be skewing the AI into not attacking cities (which is what we want).

    In that case, seems like we need to have the AI have ready stacks of tons of offensive units.

    Comment


    • #3

      Mark,

      Can you also ask him how to improve the transportion of units, and the other AI problems we've mentioned?

      You seem to have his ear

      Comment


      • #4
        Thanks, Mark. I will try and sort this out, but I am sure there are many people here who can do as well or better than I can at deciphering the code.
        Below I have posted the code pertaining to the most important goals. I believe I understand the part about MaxExec and MaxEval, and the assigning of units and the strategies.txt part, so that leaves the goals.txt part to nail down.

        What I would really like is if someone would go through each flag, and explain 'exactly' what it pertains to and does, and how the negative sign affects the AI's decision. 90% of the time, these are pretty self-evident, but it's that other 10% that always seems to be the crucial part.

        GOAL_DEFEND {
        ExecuteIncrementally
        NoTransport

        SquadClass:CanAttack
        SquadClass:CanDefend

        TargetType:City
        TargetOwner:Self

        Execute ORDER_MOVE

        ThreatBonus 1000
        EnemyValueBonus 0
        AlliedValueBonus 1000
        PowerBonus -100
        DistanceToHomeBonus 0
        DistanceToEnemyBonus 0
        ChokePointBonus 250
        UnexploredBonus -999999
        ObsoleteArmyBonus -500
        TreaspassingArmyBonus 0

        ThreatenType:None
        ThreatenBonus 0

        ForceMatch efensive
        }

        GOAL_SEIGE {
        RallyFirst

        SquadClass:CanAttack
        SquadClass:CanDefend
        SquadClass:HasZoc
        SquadClass:CanCaptureCity

        TargetType:City
        TargetOwner:HotEnemy

        Execute ORDER_ATTACK

        ThreatBonus 500
        EnemyValueBonus -250
        AlliedValueBonus 1000
        PowerBonus 500
        DistanceToHomeBonus 0
        DistanceToEnemyBonus 0
        ChokePointBonus 500
        UnexploredBonus -999999
        ObsoleteArmyBonus 100
        TreaspassingArmyBonus 0

        ThreatenType estroyCity
        ThreatenBonus 5000

        ForceMatch:Offensive

        TargetProtectionWonder WONDER_THE_FORBIDDEN_CITY
        }

        GOAL_ATTACK {
        RallyFirst

        SquadClass:CanAttack

        TargetType:AttackUnit
        TargetType:SpecialUnit
        TargetOwner:HotEnemy

        Execute ORDER_ATTACK

        ThreatBonus 100
        EnemyValueBonus -250
        AlliedValueBonus 1500
        PowerBonus 500
        DistanceToHomeBonus 0
        DistanceToEnemyBonus 0
        ChokePointBonus 50
        UnexploredBonus -999999
        ObsoleteArmyBonus 100
        TreaspassingArmyBonus 0

        ThreatenType estroyCity
        ThreatenBonus 5000

        ForceMatch:Offensive

        TargetProtectionWonder WONDER_THE_FORBIDDEN_CITY
        }

        GOAL_SALLY {
        IsSally
        NoTransport

        SquadClass:CanAttack

        TargetType:AttackUnit
        TargetOwner:HotEnemy

        Execute ORDER_ATTACK

        ThreatBonus 0
        EnemyValueBonus 0
        AlliedValueBonus 0
        PowerBonus 100
        DistanceToHomeBonus 0
        DistanceToEnemyBonus 0
        ChokePointBonus 100
        UnexploredBonus -999999
        ObsoleteArmyBonus 0
        TreaspassingArmyBonus 0

        ThreatenType:None
        ThreatenBonus 0

        ForceMatch:Offensive
        }

        GOAL_ESTABLISH_EMBASSY {
        NeedsEscort

        SquadClass:Special

        TargetType:City
        TargetOwner:Ally
        TargetOwner:Neutral
        TargetOwner:NoContact

        Execute ORDER_ESTABLISH_EMBASSY

        // just want to establish embassy at closest city.
        ThreatBonus 0
        EnemyValueBonus 0
        AlliedValueBonus 0
        PowerBonus 0
        DistanceToHomeBonus -1
        DistanceToEnemyBonus 1
        ChokePointBonus 0
        UnexploredBonus -1500
        ObsoleteArmyBonus 0
        TreaspassingArmyBonus 0

        ThreatenType:None
        ThreatenBonus 0

        ForceMatch:Special
        }

        Comment


        • #5
          So that's what they've done with those incomprehensible priorities from the old AIP files. It looks a lot clearer.

          The game is not yet out in the UK so I won't be able to get it for another week or two. I'd really appreciate it if someone would e-mail me the most important AI files; this looks very interesting.

          Thanks,

          Peter

          BTW: Colorme, is it possible that you've just got the AI trying to evaluate GOAL_SEIGE's, rather than trying to execute them?

          Comment


          • #6
            WesW and other Mod-Maker,

            I have no idea if that is a well known fact or not so forgive me if it is but to increase the performance and the combat capacity of the AI the first thing on you're todo list should be to increase the Production, Gold and Science bonuses it gets.

            As it is the AI gets 0 (that's right ZERO) bonus on those 3 things onless it's already 25% weaker than the human player (which means that it's already dead aniway).

            The production bonus is particularly important because the AI can do much less than a human with the same ressources and it doesn't have much left to build an offensive army with.

            Why as Activision shipped the game with those difficulty settings is beyond me, at first i tought the AI was very bad but once the settings are correctly set it's...still bad but much better.

            Also what I would call the Gold Bug (the player end up with so much that it's hard to spend it all) is partly because of game balance and partly because they didn't set the Wages Right, medium wages is 4 instead of 12 and maximum wages is 6 gold instead of 20, as it is you should always pay you're peoples maximum wages because it cost almost nothing and it gives you extra happiness.

            I am looking forward to playing the Med mod.

            Comment


            • #7

              Peter,

              I left MaxEval unchanged at 25 or so, and played around with MaxExec (10,5,3, etc.).
              Didn't seem to help.

              Comment


              • #8
                In Ctp2, they took the route of handicapping the human, rather than gifting the AI. Here are the lines from the DIffDB that do that. Production is not included in this, but production was actually the thing the AIs did best in Ctp1, where they were handicapped vs. the human in the initial settings.

                MAX_HUMAN_ADVANCES--------3
                MAX_AI_ADVANCES ----------6
                HUMAN_SCIENCE_BONUS--------0.4 # % amount to add to advance cost for the player
                HUMAN_FOOD_BONUS-------- -0.2 # % amount to add to food collected for the player

                Btw, I have seen a couple of players comment on the gold slider being wrong. Please tell me what you saw that revealed this, so that I can try and set it to what it should be.

                Comment


                • #9
                  I figured out the slider settings in the const.txt, and now they work as they should. We will have to see if this is proper, or if the Actigrammers changed them on purpose.
                  Getting back on topic...
                  Can someone explain what "squadclass" refers to in the goals.txt

                  Comment


                  • #10
                    The lines that control the Wages are in gamedata\const.txt

                    -----------------------------------------------------
                    UNIT_WAGES 1.0 # what does 1 notch mean
                    BASE_WAGES 4.0 # gold per person when slider is zero
                    -----------------------------------------------------

                    Wich means that the Wages at the middle of the slider is 4 gold and that each tick on one side or the other is worth 1 gold and for example

                    UNIT_WAGES 4.0 # what does 1 notch mean
                    BASE_WAGES 12.0 # gold per person when slider is zero

                    would gives possible wages of 4, 8, 12, 16 and 20.

                    I am not sure I understand you're comments about handicapping the AI, i can tell you that personnaly i hate it when the AI start with a lot of stuff because i feel it unbalance the early game and everything becomes a catch-up race BUT i think bonusses through out the game are good and necessary.

                    In my experience nothing as as much impact as a Production bonus, I think you can't go without one. I got to run my wife is angry and my kid is shouting , next time i will list the bonusses i gave and i hope you will not go without some, the one in the game are seriously wrong.

                    Comment


                    • #11
                      COmpletely unrelated, but it's pretty funny that "Destroy city" the D turns into a
                      When you laugh, the world laughs with you.
                      When you cry, the world laughs at you.

                      Comment


                      • #12

                        SO I was experimenting with adding some military AI code of my own (using SLIC2). But, I cannot figure out how to keep the AI from over-riding "my AI code".

                        e.g. I wrote some SLIC code to select the biggest army the AI (of one of the civs) has, and to make it move to a particular location. The selecting part works (I put in an appropriate message to indicate that), but the moving part of this doesn't work.

                        Does anyone know how this is done in SLIC1 (or better still in SLIC2)?

                        Comment


                        • #13
                          colorme,

                          I haven't messed too much with this yet, so I could well be way off, but I think that if you want to override the AI completely, you'll have to work very, very thoroughly. Don't just send the AI to it's final destination, send it to an adjacent square first. If it has movement points left, send it to the next square, and then to the next, etc. That will probably work better. Also, there are a lot of ways to move the AI (much be like 5-10 events that are movement related), so trying a different event might help.

                          If you get stuck, send me what you've got and I'll have a look at it, I'm currently working on a more or less similar thing for a scenario anyway (restricting movement to a certain 'zone' to be more precise, not quite as complicated but still similar), so together we might be able to work it out.

                          BTW, in SLIC1 you couldn't tell the AI to do anything, not moving and not anything else either, so we're working on ground-breaking territory here
                          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                          Comment


                          • #14

                            Locutus,

                            Thanks for the tip. I'll try what you said. BTW, I do this in my spare time, and that's getting a little too spare I guess the same holds for you too ...

                            Comment

                            Working...
                            X