Announcement

Collapse
No announcement yet.

A Pseudo Intelligent Ai Defence

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

  • A Pseudo Intelligent Ai Defence

    In what follows, I will be using Captain Nemo's Red Front 1.4 and Werd100's WWII Europa as examples because they best illustrate the point that I'm trying to make.


    BACKGROUND

    In WWII Europa, the Axis start with ~1360 units and all of their 166 cities are building units. However, by turn 8, no more units are under construction. All production has switched to city improvements. Subsequently, when there are no more improvements left to build, the AI switches to Capitalization, rather than resuming unit production. That continues until the Axis have been worn down to ~200 units. Only at that point does the AI resume building units.

    This behaviour is typical of scens that involve 2 major civs, human and AI, plus possibly some minor ones that exist only for historical accuracy. I first saw this type of AI behaviour when playtesting Colwyn's Red Front 1.5. In the discussion that ensued at the time, it was concluded that this is hard wired in the .exe but no one was sure at what point unit production resumes except that it is not a very high number.

    The problem with this is that the AI does not respond, until it is much too late, to the situation where the human civ slowly gains the upper hand and begins to capture AI cities. AI cities do not get reinforced and are still garrisoned by the same units that were in them at the start of the scen.

    For players, once they have gained the upper hand, scens like Red Front and WWII Europa become mere campaigns to capture enemy cities against predictably weak opposition. I think that there may be a way to liven things up and better depict the desperate opposition that a losing civ will put up. However, for the AI to display an IQ > 0, we need to consider how best to model both its initial offensive phase and the subsequent switch to defense.

    Unfortunately, what follows will only work in TOT because of its much richer EVENTS language and larger EVENTS files.




    THE AI OFFENSIVE PHASE


    The best example of how to fuel an AI attack can be found in Red Front. Here, Nemo fuels the irresistible German advance in 1941 by spawning replacements for destroyed German units. Depending on the type of unit destroyed, 1 to 5 replacements are spawned, in many cases not of the same type as the destroyed unit.

    IMHO, his approach runs into difficulties because:

    1. Germany starts with more than 1000 units, which often leads to "Too many units". Many of the units are superfluous because they are so slow that they never get involved in the fighting but their existence prevents Germany from building new units.

    2. The Civ 2 events language lacks 3 key commands
    . . . . @IF A @AND @IF B @THEN C
    . . . . COUNT =
    . . . . RANDOMIZE


    I would suggest that the AI start with perhaps 700 units and, initially, have events replace any offensive units that are killed with 2 new ones (Phase 1). Subsequently, the replacement rate would drop to 1 for 1 (Phase 2), followed by no replacements. The scen designer would have to decide on the duration of each phase.

    If the AI has the non-researchable Phase 1 and Phase 2 techs at the start, each phase can be ended by taking away the relevant tech. If the scen requires that the AI fight on 2 fronts, the spawning locations for replacement units can be keyed to who killed the AI unit.

    It is critical that scen be balanced so that there are maximal empty unit slots when the human civ goes on the offensive and begins to capture or recapture cities.



    THE AI ON THE DEFENSIVE


    This is continued in the next post. Evidently it is not possible to insert an image into the middle of a post. Meanwhile, enjoy the pretty map, derived from the world map in Werd100's WWII Europa.
    Attached Files
    Excerpts from the Manual of the Civilization Fanatic :

    Money can buy happiness, just raise the luxury rate to 50%.
    Money is not the root of all evil, it is the root of great empires.

  • #2

    THE AI ON THE DEFENSIVE . . . . . . . . CONTINUED


    The basic outline for a slightly less than idiotically dumb and inactive AI defence is shown on the map. Russia is presumed to be the human civ and Germany is AI controlled, and it is assumed that, despite the increased number of Russian units, there is still lots of room in the units table.

    The idea is simple. If the Russians capture a 'trigger' city, German reinforcements are immediately spawned in nearby cities. This is where the COUNT = and RANDOMIZE commands, available only in TOT, are invaluable because a single event can reinforce many cities.

    For simplicity, the map shows a really dumb version of a reactive defence. There is no reason why reinforcements cannot be spawned all around a trigger city and in nearby trigger cities rather than mainly behind it. The 3 'zones' of German defences are also strictly illustrative. No consideration has been given to how topography and roads will channel human attacks towards certain cities, making them ideal as triggers.

    The loss of a trigger city is some indication of where the human civ is attacking. Therefore, loss of a trigger city can be used to generate the units needed for an immediate AI counterattack. A civ on the defensive can do amazing things, such as the Ardennes offensive less than 5 months before Germany surrendered.

    If the focus of a scen is on the war in the west, all channel ports would need to be trigger cities and more would be needed in cities not far from the coast.
    Last edited by AGRICOLA; April 11, 2007, 22:38.
    Excerpts from the Manual of the Civilization Fanatic :

    Money can buy happiness, just raise the luxury rate to 50%.
    Money is not the root of all evil, it is the root of great empires.

    Comment


    • #3
      Its like you and me are on the same wavelength on this one. I have been planning something very similar for the ToT version.
      I wanted the AI Axis to recieve large counterattacking forces in response to the capture of such cities as Calais/Caen and Syracuse/Naples etc... (COUNT= is a godsend!)

      Using the COUNT= will also save space for events like the Warsaw Uprising and would make such things as the German invasion of Crete etc a real possibility without using up half of the events space. I will also use this to create U-Boat Wolfpacks (10+ units) to keep the Allied Navies on their toes!

      One tactic I used in V1 of Europa was to create units every X amount of turns in Axis cities so they were actually producing something in the way of units. To conserve events space I used fallback grid references.
      An example would be:
      Every 3 turns a German Armoured Unit is spawned in Bardia. If Bardia is lost then the next grid ref would be Benghazi, then Mareth, then Tunis, then Messena and so on. This way one repeating event can carry on in different locations for the whole game (if Berlin was the last grid ref). This would work as well in MGE as it would in ToT.
      SCENARIO LEAGUE FORUM
      SCENARIO LEAGUE WIKI SITE
      SL INFORMATION THREAD
      CIV WEBRING MULTIPLAYER FORUM

      Comment


      • #4
        This is very useful for me at the moment! Thanks.

        I've seen some players (I won't say who, but the initials are Agricola) lay waste to garrisons but not capture empty cities to avoid triggering these reinforcements. To counter this, you'll need to try a couple of tricks, such as: placing WoW's of immediate value in trigger cities (i.e. bait); using the same cities to trigger events that benefit the human as well as the AI; employing triggers other than CityTaken.

        RANDOMIZE can yield some funny results, which necessitates plenty of alpha testing. I've seen it generate units in the same square (out of a choice of 10) for several triggers in a row. Randomization can also occur in time (i.e. with Delay) rather than space, but this comes at a slight cost in stack space. Randomize can be coupled with BestowImprovement of a production improvement to make a high shield city for the AI. The exact city is chosen from a fixed list of the top ten contenders.

        For simplicity, the map shows a really dumb version of a reactive defence....No consideration has been given to how topography and roads will channel human AI attacks towards certain cities, making them ideal as triggers.
        These statements on geography underscore how vital it is. If the human is not forced by terrain or lack of sealift to predictable channels, the designer's challenge is insurmountable.
        El Aurens v2 Beta!

        Comment


        • #5
          Glad to be helpful rather than a royal pain in the neck.
          Excerpts from the Manual of the Civilization Fanatic :

          Money can buy happiness, just raise the luxury rate to 50%.
          Money is not the root of all evil, it is the root of great empires.

          Comment


          • #6
            Something you should consider when using the Count parameter and the Randomize modifier with CreateUnit: if a unit cannot be created, due to the presence of another tribe's unit/city or impassable/ocean terrain, the event action will abort at the first hurdle. For example, say you have a CreateUnit event where Count = 2, and the first 8 locations are vacant land squares and the last 2 are occupied by another tribe. There is a 20% chance that no units will be created at all and a 16% chance of just one spawning - you'd expect 4% and 32%, respectively, if things were working properly. If the Count value is large, you could put a significant dent in the AI's reinforcements by capturing only a few of its spawn cities.

            An alternative method for simulating an offensive would be to avoid the randomize modifier and rank the spawn locations by their distance from the front line. In the attached image the dots represent cities. The blue AI tribe is launching an offensive against red. The numbered cities mark the order of locations in a CreateUnit event. If a location is unavailable, the next in the list is chosen. AI units will always be piling on at the front line. You may need a number of these events along perpendiculars to the front line. I guess if you wanted to simulate logistics problems at various stages of an offensive, you could stagger the choice of spawn cities.

            Something else: although macro.txt states that the maximum value for Count is 255, it's actually 127 - although I can't imagine anyone using such huge numbers.

            Originally posted by AGRICOLA
            If the AI has the non-researchable Phase 1 and Phase 2 techs at the start, each phase can be ended by taking away the relevant tech.
            You can do this type of thing using binary flags - after all, that's what they're there for.
            Attached Files
            Catfish's Cave - Resources for Civ2: Test of Time | Test of Time FAQ | War of the Ring scenario

            Comment


            • #7
              Interesting idea. I might try it with my US Civil War 2013 scenario when/if I resume work on it.

              Though, it seems like the very basic idea (taking one city spawns reinforcements in surrounding cities) could be done in MGE, given that the if citytaken then spawnunits event could be done on said platform.

              Though it seems like the events would work best for an AI civ, as they would seem to give a human-played civ an unfair advantage.

              This could be worked out, for course, by having multiple events files, one for each civ the human can play (and perhaps one for MP). I know 2194 Days of War and Barron's Earth 3000 had numerous event files like that (to cite some really old examples.)
              The Ghost of the Disco is ... your mastermind, your mastermind!
              2013: A Union Divided|John III Sobieski|Red Storm

              Comment


              • #8
                Originally posted by Catfish

                An alternative method for simulating an offensive would be to avoid the randomize modifier and rank the spawn locations by their distance from the front line. In the attached image the dots represent cities. The blue AI tribe is launching an offensive against red. The numbered cities mark the order of locations in a CreateUnit event. If a location is unavailable, the next in the list is chosen. AI units will always be piling on at the front line. You may need a number of these events along perpendiculars to the front line. I guess if you wanted to simulate logistics problems at various stages of an offensive, you could stagger the choice of spawn cities.

                You can do this type of thing using binary flags - after all, that's what they're there for.
                Actually that's the way its being done using MGE events.

                From the opposite point of view, when I do AI spawning, I make it a point not to

                A. spawn in the city which is being attacked - which basically makes that city invincible.

                B. spawn unlimited units - which leads to the 'too many units' problem eventually.

                Let me elaborate a bit. In my current scenario, the Mordor Allies have two basic infantry, Haradrim and Rhun Soldiers. I start with all the Haradrim in the south and all the Rhun Soldiers in the North. Now if a Haradrim gets killed, a Rhun is spawned in the North and if a Rhun is killed, a Haradrim is spawned in the South. So if you go on the offensive in the South, the AI counterattacks in the North and vice versa. The number of AI units is stable and the mutual reinforcement system persists until you ge to the spawning source.

                That was an example of a small closed chain. Another method I use is a long open chain where unit A killed spawns unit B, which when killed spawns unit C and so on. This way, when the AI builds one unit, it is tantamount to building multiple units. Again, as the chain is not infinite, the number of AI units will not grow uncontrollably.

                If you combine both methods, then the AI units grow exponentially. This is useful sometimes if you have a quest in mind, which will change the spawning spots to ocean to stop the build up before it is too late.

                One other very important thing is to give the AI Leonardo's workshop and do the obselesence properly. You can link new techs to events to make this work nicely. e.g. city falls or at a certain turn, all half tracks become PZ IV
                .
                This is a link to...The Civilization II Scenario League and this is a link to...My Food Blog

                Comment


                • #9
                  Originally posted by kobayashi
                  Actually that's the way its being done using MGE events.
                  Well you can do it in any version of Civ2 that sports events, but it's less economical in earlier versions because you don't have the Count parameter.

                  One method used in my War of the Ring scenario to circumvent the Count/Randomize problem was to create pockets on one of the secondary maps, surrounded by impassable terrain and have units spawn in those. The pockets were at least 2x2 tiles in size to prevent units from fortifying, had unique land mass indices (hex editing) and one-way transport sites leading to the primary map. This way spawning units can't be blocked. Transport site destinations on the primary map can be blocked, but that won't mess with the CreateUnit event.
                  Catfish's Cave - Resources for Civ2: Test of Time | Test of Time FAQ | War of the Ring scenario

                  Comment


                  • #10
                    Very clever workaround.

                    Did you spawn on the transporters or on one of the other squares? Did all the spawned units use the transporters as soon as they could, or did some remain for a variable length of time on the map where they were spawned? If they reliably used the transporters no matter on which of the 4 squares they spawned, there might be a way to try to ensure that certain cities get more units, despite randomize.

                    Assume that there are 7 cities [A - G] that need reinforcements, and each spawning 'pocket' has 4 squares labelled A1- A4, B1- B4, etc. Also, cities A and B need more reinforcements than the rest. In that case, the following spawning coords whould tend to bias results so that A gets the most units, with B next, and the rest with whatever randomize produces.

                    A1
                    A2
                    A3
                    B1
                    B2
                    C1
                    D1
                    E1
                    F1
                    G1

                    This is obviously not foolproof but might help a single event to spawn units where they were most needed.

                    EDIT:
                    Would the following sequence achieve the same result?

                    A1
                    A1
                    A1
                    B1
                    B1
                    C1
                    D1
                    E1
                    F1
                    G1
                    Last edited by AGRICOLA; April 10, 2007, 06:57.
                    Excerpts from the Manual of the Civilization Fanatic :

                    Money can buy happiness, just raise the luxury rate to 50%.
                    Money is not the root of all evil, it is the root of great empires.

                    Comment


                    • #11
                      I can tell you what doesn't teleport reliably. The Sanussis in EAv2 are quite happy to mill around on a secondary map. A few will hop maps, but most meander. Perhaps the spawning continent is too large.
                      El Aurens v2 Beta!

                      Comment


                      • #12
                        Originally posted by AGRICOLA
                        Did you spawn on the transporters or on one of the other squares?
                        On the transport sites, but adjacent to seems good enough - some pockets have more than one transport site. I cover the pockets with railways, but that's probably not required.

                        Originally posted by AGRICOLA
                        Did all the spawned units use the transporters as soon as they could, or did some remain for a variable length of time on the map where they were spawned?
                        I'd say virtually all leave in the AI's next turn. Stragglers last a few turns at the most - and these tend to be in the larger pockets. I've got no serious problems with units getting stuck. It's important that the spawning pockets have unique land mass indices to prevent units from targeting inaccessible areas on the same map. This is especially true if you have more than one tribe on the secondary map. It solved problems I had early on in the scenario's development. One thing I noticed is that newly emerged units were often issued with fortify orders. They never actually carried them out, moving off in the following turn.

                        Originally posted by AGRICOLA
                        Would the following sequence achieve the same result?
                        Yes, adding weight to locations by including them in the list more than once works fine. I used it to good effect in WotR. Your first method would work, too - but of course it's redundant.

                        Originally posted by Boco
                        I can tell you what doesn't teleport reliably. The Sanussis in EAv2 are quite happy to mill around on a secondary map. A few will hop maps, but most meander. Perhaps the spawning continent is too large.
                        That could be your problem. Large continents seem to put the AI in explore mode. When they're down to 2x2 it doesn't leave them with many choices. Can you carve up some of your continents or do you have too many already? Are there any other tribes on the same continent? You don't want that. Do the units have any orders?
                        Last edited by Catfish; April 11, 2007, 22:17.
                        Catfish's Cave - Resources for Civ2: Test of Time | Test of Time FAQ | War of the Ring scenario

                        Comment


                        • #13
                          If I understand correctly, the 2-map approach gets around the problems with RANDOMIZE that you describe in your first post on this thread. If so, you certainly have done some amazing work on how to reliably deliver reinforcements as well as nasty surprises.

                          Originally posted by Case
                          Transport site destinations on the primary map can be blocked, but that won't mess with the CreateUnit event.
                          And multiple transport site in a pocket on the secondary map will reduce the chances of a unit being blocked when using a transporter.

                          As a corollary, if there is a single transporter unit for a pocket, and if a blocking unit should eventually move or be destroyed, a horde of hostiles may suddenly appear. Alternately, with multiple transporters, a unit sent to block one may well get zapped by a hostile unit that appears right next to it. Of course, with RR's on the secondary map, all units that pop up on the primary will have their full movement, be at full strength and absolutely spoiling for a fight. How fiendishly nasty. Much better than the immobilized units that are created by CREATEUNIT on the primary map because your spawned units can strike without warning.

                          Oy vey! One more source of migraines and nightmares for players.

                          I saw some of this in Boco's El Aurens. However, Boco is a true gentleman and has placed the transporters some distance from where a player was likely to have units. I expect that he has done so because he is fully aware of how difficult the scen is.
                          Excerpts from the Manual of the Civilization Fanatic :

                          Money can buy happiness, just raise the luxury rate to 50%.
                          Money is not the root of all evil, it is the root of great empires.

                          Comment


                          • #14
                            Originally posted by AGRICOLA
                            If I understand correctly, the 2-map approach gets around the problems with RANDOMIZE that you describe in your first post on this thread. If so, you certainly have done some amazing work on how to reliably deliver reinforcements as well as nasty surprises.
                            I discovered the bug part way through the development of the scenario and it was yet another one of those WTF? moments in Civ2. At least there's a work around.

                            Originally posted by AGRICOLA
                            And multiple transport site in a pocket on the secondary map will reduce the chances of a unit being blocked when using a transporter.
                            Alternately, with multiple transporters, a unit sent to block one may well get zapped by a hostile unit that appears right next to it.
                            They were my main reasons for using them. I've got some single transport site pockets in WotR; they are typically located in dangerous or remote areas, and some are clustered. When resources are stretched, it's not really worth your while trying to cover all the bases with valuable units that could be put to better use elsewhere. You'd either have to cheat or have played the scenario several times to know where they were anyway. But, there's no harm in creating some additional transport sites. By magic, it's done! Also, being one-way, they can't be pillaged from the destination map.

                            Originally posted by AGRICOLA
                            Much better than the immobilized units that are created by CREATEUNIT on the primary map because your spawned units can strike without warning.
                            That spawned units appear immobilised on their first turn depends on the order of movement and the type of trigger used in the event. For example, a CheckFlag or Turn trigger, without a second trigger like UnitKilled, would create units at the very beginning of a turn. If they belong to Tribe 0 (Edit: make that barbarians), then they'll get the opportunity to move before anyone else. Obviously, units created by UnitKilled triggers in an opponent's turn won't be able to move until it's their turn.

                            In using spawn pockets on the secondary maps, you're right, you won't be able to spawn frag new units, but there's still an opportunity to get a free swing. In my last post I mentioned that AI units were issued with fortify orders at the end of the turn in which they transported. They don't attack until the following turn. I just checked the Midgard scenario and they're doing it there as well. On closer inspection it seems that all AI units are doing it after transporting. There's always something, isn't there? Fortunately in WotR the opportunities to take advantage of this are limited. Damn you, you're making me look at this stuff again.
                            Last edited by Catfish; April 13, 2007, 05:22.
                            Catfish's Cave - Resources for Civ2: Test of Time | Test of Time FAQ | War of the Ring scenario

                            Comment


                            • #15
                              One way transport sites? Are such things possible?
                              Tecumseh's Village, Home of Fine Civilization Scenarios

                              www.tecumseh.150m.com

                              Comment

                              Working...
                              X