Navigation

    TripleA Logo

    TripleA Forum

    • Register
    • Login
    • Search
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags

    AI Territory valuation visibility?

    AI
    7
    19
    1.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Trevan last edited by 9 Dec 2020, 03:48

      The AI calculates the value of territories to figure out where it should move units. I think this is mainly used during non-combat move, though I could be wrong. The code for this is in games.strategy.triplea.ai.pro.util.ProTerritoryValueUtils.

      This valuation is currently calculated on an as needed basis but I'm wondering if it would make sense to perform the calculation before the non-combat phase and then make it available for users to see the values on the map. This would then help debug the AI since you would be able to see how the AI is valuating the territories.

      For instance, the recent Warcraft Heroes bug where the AI units would stack. If the valuation was visible, it would have shown that the home capital had a high value because of the nearby territories that it couldn't reach.

      To make this change, the AI valuation code would have to be changed so that it happens all at once instead of as needed (this could be a performance increase or decrease) and some work would need to be done in the UI so that the AI can be paused so that the user can view the valuations overlayed on the map. It will also need to handle different valuations, since there is a sea valuation, land valuation, air valuation, and I think a few sub categories in each one.

      1 Reply Last reply Reply Quote 1
      • T
        Trevan last edited by 9 Dec 2020, 05:15

        This reminded me of some AI techniques that I had read years ago. I went looking for it and found it. It is called "Collaborative Diffusion". The paper on it can be found at https://www.cs.colorado.edu/~ralex/papers/PDF/OOPSLA06antiobjects.pdf.

        Basically, you give a weight to the goals on the map (such as enemy capitals/factories, high value territories, canal controllers, etc) and then you diffuse the weight of those goals through out the map. So the territories immediately next to the goals have a weight that is greater than 0 but less than the original weight. Territories next to those are even less. But territories that are near two goals are better than territories only near one goal.

        Then, the AI only has to send its units to the territories with the best weight and if it does that each turn, the units will reach the goal.

        In addition to having goals with weights, you can have "anti-objects" which negate weights or zero them out. Things like walls, canals, restricted territories, etc. Enemy units can also be considered an anti-object.

        B redrum 2 Replies Last reply 17 Dec 2020, 20:45 Reply Quote 3
        • B
          beelee @Trevan last edited by 9 Dec 2020, 05:47

          @Trevan isn't this how it's kinda setup right now ?

          1 Reply Last reply Reply Quote 0
          • TheDog
            TheDog last edited by 9 Dec 2020, 13:07

            Yes please display the weighting, but I think they are already displayed, but in a hard to understand format, does the bigger the number mean more attention/weight is required?

            As map designers can choose the order of delegates, then so too should the valuation of territories be done before each move delegate.

            I think the first step is to show the AI numbers and then we as players might have a chance to work out what might be happening.

            In the case Warcraft Heroes bug, it happens a lot on my Settlers: maps as well, I tried to work out what was happening.

            My unfounded conclusion is the weighting of the capital/factory is way too high when there is no threat, because the enemy cannot attack it within 3+ turns.

            Also there should be a big distinction between;

            • Air units that cannot capture the factory, as the counter is just Anti Air
            • Air units with paratroopers that can capture the factory
              .
            T 1 Reply Last reply 10 Dec 2020, 01:35 Reply Quote 0
            • T
              Trevan @TheDog last edited by 10 Dec 2020, 01:35

              @TheDog said in AI Territory valuation visibility?:

              Yes please display the weighting, but I think they are already displayed, but in a hard to understand format, does the bigger the number mean more attention/weight is required?

              Where are the weights displayed?

              @beelee said in AI Territory valuation visibility?:

              @Trevan isn't this how it's kinda setup right now ?

              My first comment is basically the current setup. But I'm not aware of seeing the weights in the UI so my proposal was to make them visible.

              My second comment (Collaborative Diffusion) isn't what the current engine uses. The current engine is closer to an A* pathfinder.

              B 1 Reply Last reply 10 Dec 2020, 01:51 Reply Quote 0
              • B
                beelee @Trevan last edited by 10 Dec 2020, 01:51

                @Trevan so would this be map specific then ? One could tell the AI to defend this territory more than that one. Have it target these units more than others type thing ?

                Or it would be the current one size fits all and you have to figure out how to make your map so it will react the way you want it ?

                Either way, any improvement, even if just more information on the current process, would be a plus I would think.

                T 1 Reply Last reply 10 Dec 2020, 02:28 Reply Quote 0
                • T
                  Trevan @beelee last edited by 10 Dec 2020, 02:28

                  @beelee The initial idea for making the valuation visible wouldn't really change the AI that much. It would just make it "easier" for players to figure out what it is thinking.

                  The idea for the diffusion could be map specific. The map maker could mark certain territories with a high value. But I would hope the diffusion to be able to find most of "good" territories automatically.

                  1 Reply Last reply Reply Quote 1
                  • TheDog
                    TheDog last edited by TheDog 10 Dec 2020, 09:24 10 Dec 2020, 09:18

                    @Trevan In the AI logs search for this heading

                    Prioritizing territories to try to defend

                    The AI log then lists the territories in the format below.

                    Removing territory=Semigallia, value=52.85, CanHold=true, isLandAndCanOnlyBeAttackedByAir=false, isNotFactoryAndShouldHold=false, canAlreadyBeHeld=true, isNotFactoryAndHasNoEnemyNeighbors=false, isNotFactoryAndOnlyAmphib=false, tuvSwing=-1.0, hasRemainingLandUnit=false, maxEnemyUnits=0

                    Above the value=52.85 I think is what you are after, this appears to be the weighting of the territory.

                    It would be good to rename the "value=" above to TerritoryWeight= or similar.

                    If you then search for that value in the AI logs you will find it is reused many times.

                    Also I think the above value is what I was talking about here;
                    https://forums.triplea-game.org/topic/2489/ai-and-over-stacking-of-defensive-units-on-capitals

                    1 Reply Last reply Reply Quote 1
                    • TheDog
                      TheDog last edited by 13 Dec 2020, 18:12

                      @Trevan
                      below is a link to one of my Settler maps, it has been customised for you,  I'm hoping it will give you a test AI map for over the winter break and will do the following things;

                      • More often than not it will have a stack of units piled up in a factory/town/city territory, usually in/near Russia.
                      • Gives economic victory in about 10 minutes
                      • Plays 2v2 on Hard AI
                      • Not World War 2
                      • Of note, there is no victoryCity as it is a random start map.

                      https://drive.google.com/drive/folders/18pc1M1-oqyHGgbmYU6R6F0MkLAaAmpXi?usp=sharing

                      Open folder "For Trevan only
                      Download it
                      Select Settlers: Trevan Age of Tribes
                      Load it and press Play

                      1 Reply Last reply Reply Quote 0
                      • TheDog
                        TheDog last edited by 14 Dec 2020, 17:46

                        You are probably doing this anyway but just in case, is it worth coding your calculations as positive integers?
                        Then we humans can easily read the values, as floating point with leading zeros is harder.
                        The AI will probably execute faster with whole numbers.

                        1 Reply Last reply Reply Quote 0
                        • T
                          Trevan last edited by 14 Dec 2020, 23:46

                          Yeah, I'll be using longs as much as possible. I'd actually like to be able to show the valuation on the map itself, using something like a heatmap. I think that would be easier to understand vs having to look at a chart of numbers/territories.

                          1 Reply Last reply Reply Quote 0
                          • TheDog
                            TheDog last edited by 16 Dec 2020, 10:59

                            Ambitious! I hope you can get it to work, you might have to put it on a white background as some maps are quite dark.

                            1 Reply Last reply Reply Quote 0
                            • redrum
                              redrum Admin @Trevan last edited by redrum 17 Dec 2020, 20:49 17 Dec 2020, 20:45

                              @Trevan Unless I'm misunderstanding you, the current Hard/Fast AI pretty much does exactly what you describe for determining territory value during non-combat move. It values things like factories/capitals/number of nearby territories and then diffuses this value to nearby territories so that units essentially move towards higher value territories. This could be improved to consider additional values like canals, objectives, etc.

                              https://github.com/triplea-game/triplea/blob/master/game-core/src/main/java/games/strategy/triplea/ai/pro/util/ProTerritoryValueUtils.java#L52

                              T 1 Reply Last reply 17 Dec 2020, 22:38 Reply Quote 0
                              • T
                                Trevan @redrum last edited by 17 Dec 2020, 22:38

                                @redrum yes, the existing AI does calculate value and diffuse it. But it doesn't appear to do the entire map. It looks like it grabs a list of territories and then grabs neighbors of those territories and then calculates the values.

                                My idea is also to not do battle simulations but instead try and incorporate that in the diffusion. That is one of the big unknowns on what I'm trying.

                                redrum 1 Reply Last reply 18 Dec 2020, 00:10 Reply Quote 0
                                • redrum
                                  redrum Admin @Trevan last edited by 18 Dec 2020, 00:10

                                  @Trevan Not sure what you mean. If I recall it first finds all the "objective territories" which right now is capitals and factories then loops through all territories to find the distance each territory is from each objective and assigns value based on distance from each one. It also adds in some value based on territory production values that are nearby (within a few hexes).

                                  1 Reply Last reply Reply Quote 0
                                  • T
                                    Trevan last edited by 18 Dec 2020, 04:10

                                    Screen Shot 2020-12-17 at 9.07.58 PM.png

                                    Here's an initial attempt to showing the values of the territories as a heatmap. This is World at War. It is from Russia's point of view. The bluer the territory is, the better it is. So most of the Russian territories are very red since the units shouldn't stay there.

                                    M 1 Reply Last reply 8 Jun 2022, 14:57 Reply Quote 1
                                    • M
                                      Myrd @Trevan last edited by 8 Jun 2022, 14:57

                                      @trevan I'm curious whether the code for the above coloring was ever landed and if so, how to enable it?

                                      LaFayette 1 Reply Last reply 8 Jun 2022, 17:09 Reply Quote 0
                                      • LaFayette
                                        LaFayette Admin @Myrd last edited by 8 Jun 2022, 17:09

                                        @myrd I think it did and is part of the 'flow' AI. I don't recall if we've removed the flow AI at this point or not. So it may still be there. It would have been part of the AI debug menu to turn it on, check engine settings for "enable beta features". You'll also need to download the latest 2.6 engine as well, I'm pretty sure this was all well after the 2.5 release.

                                        M 1 Reply Last reply 8 Jun 2022, 17:42 Reply Quote 0
                                        • M
                                          Myrd @LaFayette last edited by 8 Jun 2022, 17:42

                                          @lafayette Ah, I see it. I guess I was expecting to be available for the Hard AI, since the Flow AI doesn't do anything on some maps.

                                          1 Reply Last reply Reply Quote 0
                                          • 1 / 1
                                          10 out of 19
                                          • First post
                                            10/19
                                            Last post
                                          Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums