Announcement

Collapse
No announcement yet.

AI : Army Movement

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

  • #31
    Here is the other savegame, both files together are clth above the byte limit and because I didn't noticed an annoucement of Markos that the upload service is fixed, I assume that it still doesn't work. So two posts.

    By the way I wasn't able to restart that game whenever I tryed that I found myself on a totally different map.

    -Martin
    Attached Files
    Civ2 military advisor: "No complaints, Sir!"

    Comment


    • #32
      Originally posted by calvitix
      3. If such tiles are found, set them as avoid tiles and try to find nother path.
      I found the reason for this problem, and I will try to fix it. And I will address another problem, the problem that the AI does not build ocean roads.

      Looks like the path finding routine returns ASTAR_BLOCKED if a position is water. And it uses the move cost instead the PW costs for the according tile improvement.

      -Martin
      Civ2 military advisor: "No complaints, Sir!"

      Comment


      • #33
        Originally posted by Martin Gühmann
        Note that I used the cheat editor to switch to the Barbs in order to let the AI play, so both games are saved as Barbs.

        -Martin
        I'll look at the savegames...

        Hint :

        If you don't know, you can let any player play as AI, by
        using the '/attach numplayer' (where numplayer is the player you want to play as AI). (in message box)

        same command to disable AI : '/detach numplayer'

        You can also play turns automatically with '/rnd numofturns'

        Comment


        • #34
          Originally posted by calvitix
          If you don't know, you can let any player play as AI, by
          using the '/attach numplayer' (where numplayer is the player you want to play as AI). (in message box)

          same command to disable AI : '/detach numplayer'
          Actual I tried it in a GoodMod game, and I got the suspicion that the civ didn't act like an AI, at least it was buggy sometimes it did but not always. Not moving the units not filling the build queues, etc. Actual this is a good way in my opinion to monitor the game. One thing that is currently bothering me is the fact that no Barbs pop out of goody huts, even if the diff level says Barbs only from huts.

          For the path finding I think it is not a good idea to let it search five times for a good path for instance, if you want to avoid pollution on the way, you should modify the EntryCost function, actual you have a lot more to consider then pollution, is all of the territory owned, can a road build on every tile, avoid enemy terrain, but don't avoid allied terrain. Actual it is very simple forbidden tiles get a high cost and allowed tiles a low cost.

          Code:
          sint32 CityAstar::EntryCost(const MapPoint &prev, const MapPoint &pos,                           
                                      float &cost, BOOL &is_zoc, ASTAR_ENTRY_TYPE &entry) 
          
          {
          	if(m_pathRoad){
          		
          		const TerrainImprovementRecord *rec = terrainutil_GetBestRoad(m_owner, pos);
          		if(g_player[m_owner]->IsExplored(pos) == FALSE 
          		||(g_theWorld->AccessCell(pos)->GetOwner() >= 0
          		&&(g_theWorld->AccessCell(pos)->GetOwner() != m_owner
          		&& !AgreementMatrix::s_agreements.HasAgreement(m_owner, g_theWorld->AccessCell(pos)->GetOwner(), PROPOSAL_TREATY_ALLIANCE)))
          		|| !rec
          		){ 
          			cost = k_ASTAR_BIG; 
          			entry = ASTAR_BLOCKED; 
          			return FALSE;
          		}
          		
          		const TerrainImprovementRecord::Effect *effect = terrainutil_GetTerrainEffect(rec, pos);
          		if(!effect){
          			cost = k_ASTAR_BIG; 
          			entry = ASTAR_BLOCKED; 
          			return FALSE;
          		}
          
                  cost = float(g_theWorld->GetMoveCost(pos) * effect->GetProductionCost());
          		if(g_theWorld->AccessCell(pos)->GetOwner() == -1){
          			cost *= 10000;
          		}
          
          		entry = ASTAR_CAN_ENTER;
          		return TRUE;
          	}
          	else{
          		return TRUE;
          	}
          }
          That does a lot I wanted to see in and it should also bypass polluted tiles, because road improvements cannot be build on dead tiles, therefore terrainutil_GetTerrainEffect returns NULL and a dead tile is avoided.

          -Martin
          Civ2 military advisor: "No complaints, Sir!"

          Comment


          • #35
            And for illustration a picture of the results of the above code. I used the mayors to generate the path, used the cheat editor to make the city big and to give all advances to that civ so that they can build all tile improvements. What you sea is that the maglevs go around the polluted area, without finding five path and with a longer line of polluted area the same result is achieved namly that the poluuted area is bypassed. And another thing you can see on this picture is that the mayors use undersea tunnels as well.

            -Martin
            Attached Files
            Civ2 military advisor: "No complaints, Sir!"

            Comment


            • #36
              OK, I'll try with it... it seems effectively quite better... (I just applied what I'have done for units, it was less appropriate for roads)

              Comment


              • #37
                Are you guys integrating some of the modded AI stuff too? I could see frenzy AI suitable for some personalities or if your reputation drops.
                Formerly known as "E" on Apolyton

                See me at Civfanatics.com

                Comment


                • #38
                  Originally posted by E
                  Are you guys integrating some of the modded AI stuff too? I could see frenzy AI suitable for some personalities or if your reputation drops.
                  Why should we integrate frenzy AI into the game, it is actual just a bit of slic code, that is actual not very effective. I think the current AI is already better then Frenzy AI, maybe we need bigger stacks, but if you share with an AI the continent then you should get some decent attacks. Maybe the stack size has to be increased. But I think the main goal should be that the AI can coquer other AIs, even on different continents. So if an AI cannot conquer another AI how should it being able to conquer a human civ.

                  Originally posted by E
                  OK, I'll try with it... it seems effectively quite better... (I just applied what I'have done for units, it was less appropriate for roads)
                  Overall I think I have the road part done. For the blocked part, I think the EntryCost function is the appropiate place to do it, but for the dangerious tile part we have to wonder whether this is the best place, because increasing the costs here means to return a wrong number of needed turns, for the human player. Alternativly the additional coasts are only given if the player is an AI.

                  -Martin

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment


                  • #39
                    I have another annoying uestion regarding AI.

                    Is there anything in the code that changes the AIs attack behavior depending on the Human or other AIs strength.

                    Specifically, If a player develops nuclear weapons the AI should:
                    1) increase the use of spies and try to steal nuke technology
                    2) once it has nukes of its own threaten a mutually assured destruction scenario
                    3) when both have nukes the AI should use more Special/stealth units (almost Frenzy like) against the player to avoid a full on war but still try to achieve objectives through covert means.

                    I'm not advocatin scripting a whole new AI but I'm hoping there is something there that changes behavior depending on the situation.

                    I do think making the threat of nuclear annihilation from the Ai plausible could change the tedium of the late game also make the conquest victory less likely since its easier to do it with modern units, but the nuclear check would prevent that.
                    Formerly known as "E" on Apolyton

                    See me at Civfanatics.com

                    Comment


                    • #40
                      Originally posted by E
                      I have another annoying uestion regarding AI.

                      Is there anything in the code that changes the AIs attack behavior depending on the Human or other AIs strength.
                      There are bonuses for each goals that are applied :
                      PowerBonus
                      EnemyValueBonus
                      AlliedValueBonus

                      So Ais behavior will change depending on others strength, but AI don't have a real strategy :

                      It has several goals (defined in 'goals.txt'), and it affects units foe each goals. It has not global strategy, each army is working for itself. No massive attack, or invasion are planed. It happens several times (And with my latest tests Ais is able to invade another 10 cities civilization), but its only a succession of SEIGE goals).


                      Originally posted by E


                      Specifically, If a player develops nuclear weapons the AI should:
                      1) increase the use of spies and try to steal nuke technology
                      2) once it has nukes of its own threaten a mutually assured destruction scenario
                      3) when both have nukes the AI should use more Special/stealth units (almost Frenzy like) against the player to avoid a full on war but still try to achieve objectives through covert means.

                      I'm not advocatin scripting a whole new AI but I'm hoping there is something there that changes behavior depending on the situation.

                      I do think making the threat of nuclear annihilation from the Ai plausible could change the tedium of the late game also make the conquest victory less likely since its easier to do it with modern units, but the nuclear check would prevent that.
                      As I said, AI don't have global strategy... I didn't find anithing about AI changing its strategy during the game. It's always the same strategy, but the goals become available with advances.
                      It would be a great job to introduce special AI comportments (depending on situation), but also lot of works...

                      For the moment, we are working to enhance the existing AI by giving it the possibility to achieve thei goals (too many units are blocked (no path, no transport,...)). maybe when it 'd be done, we will concentrate in that objecive.

                      Now I'm back, I'll post reports and new modifications ASAP...

                      Comment


                      • #41
                        I think we should re-examine the way that armies are implemented.

                        There's always been a problem with having planes and land units in the same army. For one thing it's
                        (arguably) unrealistic and for another it messes up the AI.

                        Also, it's always struck me as being a bit silly that when you attack a coastal city you can find your
                        land units fighting sea units.

                        So, I propose that we keep land, sea, and air units in separate armies. In both Civ3 and RoN they keep
                        planes separate from land units but I don't really like either of the ways they've implemented the
                        separation.

                        This is going to entail a lot of work and I'm not at all sure of how we should begin. Each cell has a
                        CellUnitList *m_unit_army. Perhaps, we can start by adding two more such lists to the cell: m_unit_sea
                        and m_unit_air. Notice that this would mean that in a coastal city you could have up to 36 units present.
                        Also, it would mean that we have to change the UI so that you can toggle between which unit list you want
                        to see and manage.

                        Anyway, if we were to implement a system like this it would mean that we could rewrite some of the AI
                        code and, I think, make it more effective.

                        Comment


                        • #42
                          Also, it's always struck me as being a bit silly that when you attack a coastal city you can find your
                          land units fighting sea units.
                          I like the idea of splitting them to help the AI but what would happen if say 12 tanks attacked a coastal city with 12 marines, 12 fighters and 12 battleships inside? Would the 12 attacking tanks only engage the 12 marines in battle? and if so what happens to the battleships and fighters? The fighters and battleships could take a free shot at the tanks before the tank v marine battle begins, and if the tanks still win, then the fighters and battleships would have to scramble outside the city, which is a bit weird.
                          Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
                          CtP2 AE Wiki & Modding Reference
                          One way to compile the CtP2 Source Code.

                          Comment


                          • #43
                            Originally posted by Peter Triggs
                            Also, it's always struck me as being a bit silly that when you attack a coastal city you can find your land units fighting sea units.
                            With modern ships you can bombard land units, so under some circumstances it does make sense.

                            So, I propose that we keep land, sea, and air units in separate armies. In both Civ3 and RoN they keep planes separate from land units but I don't really like either of the ways they've implemented the separation.

                            This is going to entail a lot of work and I'm not at all sure of how we should begin. Each cell has a CellUnitList *m_unit_army. Perhaps, we can start by adding two more such lists to the cell: m_unit_sea and m_unit_air. Notice that this would mean that in a coastal city you could have up to 36 units present. Also, it would mean that we have to change the UI so that you can toggle between which unit list you want to see and manage.[/QUOTE]

                            I would rather introduce group classes something like the bit flags CanSee. So this flag would be then:

                            CanGroupWith: SmallLand
                            CanGroupWith: MediumLand
                            CanGroupWith: SmallAir
                            CanGroupWith: MediumWater

                            And so on.

                            That would allow every modder to change it, and we would have a wider flexibility and less changes are necessary. And the 12 unit limit isn't violated.

                            -Martin
                            Civ2 military advisor: "No complaints, Sir!"

                            Comment


                            • #44
                              ArmyMovement Update 1.2

                              Hi, I posted on 'altered sources' a new update to my Army movement patch (1.2)

                              This time, I think the AI armies movement is quite better on ground, with grouping, seiges,...

                              I mostly fixed some cases were units were blocked during the 'rally' phasis, and integrated the check methods in UnitaStar into the entrycost method.


                              Agressive AI are now able to win the game
                              (as the example here : English wins by conquest in 1980, (small map with continents, with 5 civs, moderate) !

                              I'll now work on transport and AI behavior with sea and air units.

                              Perhaps it will be time to post a new playtest ?



                              About separating armies by movement type, I agree with Martin, we have to respect the 12 max limit, and we'll restricted the units that can be grouped together.
                              Attached Files

                              Comment


                              • #45
                                calvitix,

                                Did you see any AI stuff that may make the AI seek out goods and defend good tiles or even try to take them from other players?
                                Formerly known as "E" on Apolyton

                                See me at Civfanatics.com

                                Comment

                                Working...
                                X