Announcement

Collapse
No announcement yet.

Military/econ user interface and the ai

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

  • Military/econ user interface and the ai

    I didn't really know in which thread this would belong best, so here goes:
    I'm writing the code needed to allow the ai to decide what to build. Now I finally found how to do it, it all seems clear, and I think the player can benefit from it too, in terms of user interface.

    Currently, ai and players say which kind of unit they want and how much production they want to put in each. This is fine, but maybe what they want is to have that proportion of armies, and when you get your legions killed but not the archers, you have to micromanage to get more legions produced than archers to keep the good proportions. Additionally, there's the fact that archers are listed before legions, so they get produced before.
    Now, the player can change production orders when they like. The ai can too, but you must script it in the scenario file, which makes it not very responsive in general, unless you want to code all the ai in xml.

    So what I am doing is writing an object that maps to a certain distribution of units. For the player, that would be pretty simple, he says I want 40% legion, 60% dreadnoughts, and how much globally the econ should spend on units, and voilá.
    This, however, would require some econ changes, as I'd add an econ order like 'overall military spendings', whose production/kapital/food ratios vary depending on the player's input. I can always bypass this in a first coding attempt as there will be some waste (the same problem exists for walls, which share a single wall-building category).

    And then there is the ai. I can also tell the ai to build units in proportion, so it will always have combined arms TFs rather than having mostly archers in an archer/legion case.
    Last edited by LDiCesare; May 25, 2003, 06:27.
    Clash of Civilization team member
    (a civ-like game whose goal is low micromanagement and good AI)
    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

  • #2
    Obviously, building units that are needed instead of yet another archer is a good thing for the ai, but how does it know it should build a new unit when one becomes available? Particularly, when such a unit doesn't obsolete a previous unit, but is something new (like cavalry when you didn't have any, or airplanes or ships...)?

    I define for the ai use a set of unit abilities:
    Right now, I picked:
    Attack, defense, breach, cost, support, movement.
    This defines a set of abilities which the ai will want.
    For instance, you may say you want:
    60% legion, 30% archers, 10% siege engines.
    But you may also state it thus:
    60% attack, 30% support, 10% breach.

    These are not categories, however. I don't like categories a lot, because if you label an army as 'defender', ai's like civ2 use it as defender when they would sometimes make excellent attackers.
    Additionnally, I put movement and cost in because you may want a mix of these. For instance, I may want a set of fast cheap units to use as scouts, a few strong attack units, even if they are slow and expensive, and a lot of relatively cheap attack units which can move a bit.
    So I have categories, with weights in each category:
    For example I could represent scouts/strong attackers/cheap fast attackers this way:

    Scouts: Movement 10. Cost 1.
    Strong attackers: Attack 1.
    Cheap fast attckers: Attack 10. Movement 3. Cost 1.

    The ai would then scan the available units, classify each available unit in each category, and decide which unit is best to build. If the system works well, humans could also use it (for instance, I will use it because I have to tune the ai).

    Mapping of units to abilities would vary a bit:
    Breaching is a yes/no ability, so it is not hard to find out when you want siege weapons. There are more extreme cases, like being an airplane or a ship, where you don't even have the breach strength value available.
    Attack, defense... are numbers, so there will be a number crunching equation I haven't devised yet to find out how much a unit fits a certain role.

    So this approach is to define a set of categories that the ai can use, categories which can be defined on the fly if needed (like I realize I need breachers to get through the wall of city XXX). What do you think of the approach for the ai? Should the player be able to use it too? Would you use such an interface as a player?
    Last edited by LDiCesare; May 25, 2003, 06:33.
    Clash of Civilization team member
    (a civ-like game whose goal is low micromanagement and good AI)
    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

    Comment


    • #3
      Hi Laurent:

      Just to give you some quick feedback, your approach sounds reasonable to me. And I would certainly be interested in using a flexible system to set army levels like the one you propose. However, I can't say I have given the specifics of your proposal deep thought. I'll let you know if upon reflection I have any good ideas in regard to your proposal. Its certainly a step in the the right direction, and if it needs modifications, I don't think they'll be major.
      Project Lead for The Clash of Civilizations
      A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
      Check it out at the Clash Web Site and Forum right here at Apolyton!

      Comment


      • #4
        All the infrastructure is coded. So now, the ai gets orders like this in the xml file (one of the following):

        <AI>
          <buildOrders>
            <militaryProduction> 0.8 </militaryProduction>
            <unitsProfile>
            <production>
              <order> Phalanx</order>
              <level> 10 </level>
            </production>
            <production>
              <order> Bowmen</order>
              <level> 8 </level>
            </production>
            <production>
              <order> Elephant</order>
              <level> 1 </level>
            </production>
            </unitsProfile>
          </buildOrders>
        </AI>

        This one tells the ai to spend 80% of its income on military, in order to get proportions of 10$ of phalanx for 8$ of bowmen and 1$ worth of elephants at all times in its armies.

        <AI>
          <buildOrders>
            <militaryProduction> 0.8 </militaryProduction>
            <abilityProfile>
              <production>
                <ability>
                  <attack> 1 </attack>
                  <cost> 1 </cost>
                </ability>
                <level> 2.0 </level>
              </production>
              <production>
                <ability>
                  <support> 1 </support>
                  </ability>
                <level> 1.0 </level>
              </production>
            </abilityProfile>
          </buildOrders>
        </AI>

        This one is funnier, as it orders to have low cost strong attack and strong (fire)support units. This currently results in siege weapons and light cavalry for carthaginians in Delenda scenario. The ai can use this and adapt itself, picking the best available unit as new units become buildable.
        (Although I must tune the choice function because it's a bit bugged right now).

        The ability objects can be named too, so I hope I can put something nice into a user interface when all the internals work fine:
        I'd let the player choose to
        -choose units per name (as now)
        -choose units per abilities, where you could create and name your own set of abilities, and then the UI would tell you what's the unit that matches this profile best, and build it. When a better unit becomes available, it would switch production automatically, but you could still build the old unit if you liked through the econ orders UI.
        Clash of Civilization team member
        (a civ-like game whose goal is low micromanagement and good AI)
        web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

        Comment


        • #5
          Hi Laurent:

          That looks outstanding! Can't wait to see it in action once you have the bugs kicked out!
          Project Lead for The Clash of Civilizations
          A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
          Check it out at the Clash Web Site and Forum right here at Apolyton!

          Comment


          • #6
            Laurent, it's wonderful to see you using tags that start with a lowercase letter!

            Cheers

            Comment


            • #7
              To my limited knowledge of programming, that system sounds interesting.
              Everything changes, but nothing is truly lost.

              Comment


              • #8
                Hi Gary, great to 'see' you on the forum again! Hope all's well with you and yours!

                Mark
                Project Lead for The Clash of Civilizations
                A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                Check it out at the Clash Web Site and Forum right here at Apolyton!

                Comment


                • #9
                  I appreciate the kind word, but I think you might have me confused with someone else. My name is Dave.
                  Everything changes, but nothing is truly lost.

                  Comment


                  • #10
                    Laurent, it's wonderful to see you using tags that start with a lowercase letter!
                    Glad you like it!
                    Clash of Civilization team member
                    (a civ-like game whose goal is low micromanagement and good AI)
                    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                    Comment


                    • #11
                      Here are (hopefully) screenshots of the UI.
                      Note it is not very good because:
                      - it is not exactly the correct type of window (should probably be dialogs instead of frames...)
                      - it lacks an edit function after you created the category
                      - it is not fully functional for it is based only on civ-wide orders and not province-only for example
                      - there are bugs (strange as it may sound):
                      Attached Files
                      Clash of Civilization team member
                      (a civ-like game whose goal is low micromanagement and good AI)
                      web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                      Comment


                      • #12
                        Here is the edit category panel.
                        Note that this allowed me to see that chariots are vastly overpowered in the Carthago scenario.
                        Using attack only, romans will build chariots, if you choose attack = 1 and cost = 1, they'll build legions (weaker but more cost-effective).
                        This screenshot is not sexy, so I think probably the figures should be replaced by sliders, as big values will screw my computations anyway so it'd be better to limit the possible values to 0/0.5/1/1.5/2 with a slider.
                        Attached Files
                        Clash of Civilization team member
                        (a civ-like game whose goal is low micromanagement and good AI)
                        web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                        Comment


                        • #13
                          This is great stuff Laurent - I am really looking forward to trying it out.

                          Has anything been done about naval combat in my absence?

                          Cheers

                          Comment


                          • #14
                            I answered about naval combat in the other thread. Shortly: yes, but there is no model beneath.

                            The screenshots are of functional windows, except there is a conflict with the econ UI somewhere. I mostly coded the UI to test the underlying classes gave correct results for the ai to use.
                            Clash of Civilization team member
                            (a civ-like game whose goal is low micromanagement and good AI)
                            web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                            Comment


                            • #15
                              Lookin' good Laurent, sorry I neglected to respond earlier! I'm looking forward to playing with the new gui stuff when its ready.
                              Project Lead for The Clash of Civilizations
                              A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                              Check it out at the Clash Web Site and Forum right here at Apolyton!

                              Comment

                              Working...
                              X