Announcement

Collapse
No announcement yet.

How to make AI convert their terrain?

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

  • How to make AI convert their terrain?

    I am in game (CTP2 + patch 1.11 + apolyton pack 1.02) turn 250, and AI has technology like "conservation" etc, with 200,000 points in public works and quarter million dollars too, but they never convert their terrain even there are obvious reasons to do so.
    It seems it's not AI unwilling to do that, but they just can't. So is it a bug we are talking here?

  • #2

    hi WarLoard,
    I am entirely new to this but see attached files. Terrain.Txt and Tileimp.txt. They force the AI to transform through a tree structure from one terrain to another. Just unzip into Medpack Crusade. The human can cheat however by going straight to an available terrain.

    It is a bug that prevents the Ai from doing correctly. Take an example.

    Plain + trading post = 25 pts
    Plain = 20 pts
    Grassland = 25 pts

    The attached files fool the AI into thinking the tile improvement will be better than the existing terrain + best improvement possible. i.e. higher than putting plain+farm = grassland.

    the bug is that the AI considers the terrain + improvement (e.g. farm) rather than the base terrain on its own.

    please try files (I have modified terrain and improvement values also).

    Regards
    Art of War
    Attached Files
    Last edited by sun_tzu_159; January 23, 2002, 04:13.
    Lady Astor : "If I were your wife I would put poison in your drink"
    Churchill : "If I were your husband I would gladly drink it"
    Unclear words can wipe out all human life on earth if used improperly

    Comment


    • #3
      hi warloard,
      my last post has not appeared yet. It wasn't a very good explanation anyway.

      There is a bug somewhere in the transform programming.
      The AI does the sums as follows,

      Plains + Farm = 25 say
      Grassland (transform) = 22 say

      Line 1 > Line 2 therefore build farm - will not transform land.

      In order to transform the AI should compare the value of Grassland + Farm.

      In order to fool the AI you have to set the values in the Tileimp file to the best improvement available. I have pasted a section here for grassland from the Tileimp file attached. The important part is the use of BonusFood etc. where this is added to the current tile.

      This says that you will get a food bonus of 30 for transforming plain into grassland. It is of course a trick. When the improvement is built the tile value will be for grassland only and a farm will then be added as a building improvement. The rest of the structure is to make sure that only plains can be converted to grassland.

      TILEIMP_TERRAFORM_GRASSLAND {
      Icon ICON_TERRAIN_GRASSLANDS
      Tooltip TOOLTIP_TILEIMP_SELECT_GRASSLND_BUTTON
      Statusbar STATUSBAR_TILEIMP_SELECT_GRASSLND_BUTTON
      TerraformTerrain TERRAIN_GRASSLAND
      Level 1
      Column 0
      Class:Terraform
      GLHidden

      ConstructionTiles 1
      ConstructionTiles 1
      ConstructionTiles 1

      CantBuildOn TERRAIN_WATER_BEACH
      CantBuildOn TERRAIN_WATER_DEEP
      CantBuildOn TERRAIN_WATER_KELP
      CantBuildOn TERRAIN_WATER_REEF
      CantBuildOn TERRAIN_WATER_RIFT
      CantBuildOn TERRAIN_WATER_SHALLOW
      CantBuildOn TERRAIN_WATER_SHELF
      CantBuildOn TERRAIN_WATER_TRENCH
      CantBuildOn TERRAIN_WATER_VOLCANO
      CantBuildOn TERRAIN_BROWN_HILL
      CantBuildOn TERRAIN_BROWN_MOUNTAIN
      CantBuildOn TERRAIN_DESERT
      CantBuildOn TERRAIN_FOREST
      CantBuildOn TERRAIN_GLACIER
      CantBuildOn TERRAIN_GRASSLAND
      CantBuildOn TERRAIN_HILL
      CantBuildOn TERRAIN_JUNGLE
      CantBuildOn TERRAIN_MOUNTAIN
      CantBuildOn TERRAIN_SWAMP
      CantBuildOn TERRAIN_TUNDRA
      CantBuildOn TERRAIN_WHITE_HILL
      CantBuildOn TERRAIN_WHITE_MOUNTAIN


      Excludes:Structure2
      Excludes:Structure1
      Excludes:OceanMine
      Excludes:OceanFarm
      Excludes:OceanDetector
      Excludes:OceanATM
      Excludes:Mine
      Excludes:LandDetector
      Excludes:Farm
      Excludes:ATM

      TerrainEffect {
      Terrain TERRAIN_PLAINS

      BonusFood 30
      BonusProduction 15
      BonusGold 5
      EnableAdvance ADVANCE_AGRICULTURE
      ProductionCost 600
      ProductionTime 2
      TilesetIndex 1
      }
      }

      ## Tile production bonus is Grassland + Hydroponic Farm

      The Production cost is ignored in this class terraform and the cost is taken from the terrain.txt file. The production time is taken from above and ?multiplied by the value in the corresponding entry in terrain.txt called time, I have pasted below.


      TERRAIN_GRASSLAND {
      TilesetIndex 4
      Icon ICON_TERRAIN_GRASSLANDS
      InternalType: Grassland
      CanDie

      AddAdvance ADVANCE_AGRICULTURE
      TransformAdd {
      Time 1 // from 6
      Materials 350
      }

      RemoveAdvance ADVANCE_AGRICULTURE
      TransformRemove {
      Time 1 // from 3
      Materials 175
      }

      EnvBase {
      Score 84
      Food 24
      Shield 12
      Gold 10
      Defense 0
      Movement 100
      Freight 100
      DeadFood 0
      DeadShield 0
      DeadGold 0
      }

      EnvCity {
      Score 0
      Food 24
      Shield 12
      Gold 8
      Movement 50
      Freight 50
      }

      EnvRiver {
      Score 22
      Food 7
      Shield 2
      Gold 4
      Movement 50
      Freight 50
      }

      Resources TERRAIN_GRASSLAND_GOOD_TWO
      Resources TERRAIN_GRASSLAND_GOOD_ONE

      MovementType: Air
      MovementType: Land

      }


      Essentially thats it - You can pick out the others from the attached files.

      In its present form the AI is forced to go through the following route.

      Mountain to Hill to Plains to Grassland
      (Tundra or Jungle) to Swamp to Plains to Grassland
      Forest to Plains to Grassland
      and a few other paths.
      At the end it is programmed to change back Grassland and plains to jungle and Forest as conservation becomes fashionable.

      Cheers for question.
      Attached Files
      Last edited by sun_tzu_159; January 23, 2002, 04:15.
      Lady Astor : "If I were your wife I would put poison in your drink"
      Churchill : "If I were your husband I would gladly drink it"
      Unclear words can wipe out all human life on earth if used improperly

      Comment


      • #4
        Hi, sun_tzu_159

        Good to see someone with such a firm command of the game turn up. How are you on SLIC?

        Comment


        • #5
          Good stuff. Took me a while to figure out what exactly you were saying but if this works it's brilliant (I wanted to try it tonight but unfortunately didn't have the time)

          Oh, and welcome onboard, we can use more people like you!
          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

          Comment


          • #6
            That's brilliant

            And just what I needed to get the stupid AI to terraform Mars rather than sit there in a barren deserted wasteland complaining about no good city sites.
            Concrete, Abstract, or Squoingy?
            "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

            Comment


            • #7
              Hi,
              I'm glad someone picked the transform thing up. As you can see from the date on the files I did this a while ago. I was going to register but it all died off on CTP2 (still the best) for a while then I noticed Wes had another mod posted.

              I have no experience of the SLIC codes but can figure out what they do. My line was more into using what they and the .exe already did and adjust the data in the .txt to suit. Fortunately it worked as alot of work has gone into the AI on transform but is not used except by these updated files.

              If you have already tried it you will notice that the human can cheat by upgrading the terrain in one go. e.g. forest to grassland whereas the AI is forced to go through the tree structure.
              As far as I can see the programmers gave up trying to sort out the .exe to stop human cheating. The .exe is capable of handling the transform in exactly the same way as tile improvements.The fact that they left code in to treat terrain as a building or terrain improvement means they were working on this. The programmer has stripped out all clues from terrain.txt that this could be done and mirrored the human control in terrain.txt (using add and remove) with the trimmed AI control in the original tileimp.txt.

              I don't know if you can write SLIC handling of the human transform to mirror the .exe handling of the AI transform? Or an expert in the .exe can investigate why the human side of transform doesn't go through the same part of .exe as the AI transform?

              The values of all things has been increased to allow extra income for the AI and human to do the transforming. I played a game against the AI and one of the AI (Arabia) absoloutely knocked me off the map. The AI is very good at placing the improvements to maximum benefit without not producing units etc. (another reason for suspecting they did alot of work on this before abandoning it).

              Oh yes - I have tried desperately to get the AI to build undersea tunnels but it just won't do it.

              Have to sign off now.

              Regards
              AOW
              Lady Astor : "If I were your wife I would put poison in your drink"
              Churchill : "If I were your husband I would gladly drink it"
              Unclear words can wipe out all human life on earth if used improperly

              Comment


              • #8
                That is amazing i took hours to figure ou what you did but i filnally got it. Cant even imaging how you figure out this on your own. Cant wait to try this. Plus one victory over the AIs problems.

                I have no idea about the AI not building tunnel. I just heard about it. But i am going to give a kick in the dark on how to fix it.
                I was fusing the commerce improvmets to the food/prouction ones. Since the AI Does not build them and only builds one of the list at the time. When i found another problem.
                How to make the AI build Undersea mine without giving up the land ones?
                Here what i did. took the Undersea mine out of the improvement list. Only the land mines were in the list.
                The idea was to make the land mines buidables in the water. yet when they were build the tileindex would change for an Undersea mine. I did not delete all the Undersea mines they were still there for the human to build in the conventional. But the AI would build as a land mine. Here is a sample from my tileimp.txt.

                Code:
                TILEIMP_MEGA_MINES {
                   Icon ICON_TILEIMP_MEGA_MINES
                   Tooltip TOOLTIP_TILEIMP_SELECT_ATM2_BUTTON
                   Statusbar STATUSBAR_TILEIMP_SELECT_MINE3_BUTTON
                   
                   Level 3
                   Class:Mine
                
                   ConstructionTiles 1
                   ConstructionTiles 18
                   ConstructionTiles 19
                
                   CantBuildOn TERRAIN_WATER_BEACH
                   CantBuildOn TERRAIN_WATER_SHALLOW
                   CantBuildOn TERRAIN_WATER_SHELF
                   CantBuildOn TERRAIN_WATER_TRENCH
                
                   Excludes:ATM
                   Excludes:Farm
                   Excludes:LandDetector
                   Excludes:Mine
                   Excludes:OceanFarm
                   Excludes:OceanDetector
                   Excludes:OceanATM
                   Excludes:Structure1
                   Excludes:Structure2
                   Excludes:OceanMine
                
                   TerrainEffect {
                      Terrain TERRAIN_DESERT
                      Terrain TERRAIN_GRASSLAND
                      Terrain TERRAIN_PLAINS
                
                      BonusProduction 40
                      BonusGold 30
                      EnableAdvance ADVANCE_ULTRAPRESSURE_MACHINERY
                      ProductionCost 1800
                      ProductionTime 2
                      TilesetIndex 20
                   }
                
                   TerrainEffect {
                      Terrain TERRAIN_BROWN_HILL
                      Terrain TERRAIN_HILL
                      Terrain TERRAIN_WHITE_HILL
                
                      BonusProduction 50
                      BonusGold 30
                      EnableAdvance ADVANCE_ULTRAPRESSURE_MACHINERY
                      ProductionCost 1800
                      ProductionTime 3
                      TilesetIndex 20
                   }
                
                   TerrainEffect {
                      Terrain TERRAIN_BROWN_MOUNTAIN
                      Terrain TERRAIN_MOUNTAIN
                      Terrain TERRAIN_WHITE_MOUNTAIN
                
                      BonusProduction 60
                      BonusGold 30
                      EnableAdvance ADVANCE_ULTRAPRESSURE_MACHINERY
                      ProductionCost 1800
                      ProductionTime 5
                      TilesetIndex 20
                   }
                
                   TerrainEffect {
                      Terrain TERRAIN_WATER_DEEP
                
                      BonusProduction 40
                      BonusGold 30
                      EnableAdvance ADVANCE_LIQUID_BREATHING_APPARATUS
                      ProductionCost 1800
                      ProductionTime 2
                      TilesetIndex 60
                   }
                
                   TerrainEffect {
                      Terrain TERRAIN_WATER_RIFT
                
                      BonusProduction 60
                      BonusGold 30
                      EnableAdvance ADVANCE_LIQUID_BREATHING_APPARATUS
                      ProductionCost 1800
                      ProductionTime 3
                      TilesetIndex 60
                   }
                
                   TerrainEffect {
                      Terrain TERRAIN_WATER_VOLCANO
                
                      BonusProduction 80
                      BonusGold 30
                      EnableAdvance ADVANCE_LIQUID_BREATHING_APPARATUS
                      ProductionCost 1800
                      ProductionTime 5
                      TilesetIndex 60
                   }
                }
                As you can see the three last terrainEffects are direct cut from the Undersea Mines and pasted here. Unfortunetly i am not that far in the game to test the AI attitude towar the changes (the changes worked though) and lazy enough not to test it through the cheat mode. Still is a suitable alternative to make the AI build undersea mines without leting to build the Land ones.

                So after all this explanation, what i am aiming is to make the Maglevs tunnels buidable in water with the tileindex of the Undersea tunnel. Do you think it will work?
                Last edited by Pedrunn; January 20, 2002, 07:27.
                "Kill a man and you are a murder.
                Kill thousands and you are a conquer.
                Kill all and you are a God!"
                -Jean Rostand

                Comment


                • #9
                  wrong files attached

                  I just downloaded the file and saw that the wrong files are attached. the tileimp.txt file doesn't have any of the stuff mentioned in your post, and the terain.tx file doesn't have it either.

                  Comment


                  • #10
                    Originally posted by Pedrunn
                    That is amazing i took hours to figure ou what you did but i filnally got it. Cant even imaging how you figure out this on your own. Cant wait to try this. Plus one victory over the AIs problems.
                    Actally it is a very simple sollution but very effictive. It is just cheating the AI so it will think that it build a food Improvment on a hil or mountain or in the tundra. And than the surpridse surprise the land was been terraformed. I think I had to find a way to make the AI to not build certain food improvements that I overlooked it.

                    Originally posted by Pedrunn
                    I have no idea about the AI not building tunnel. I just heard about it. But i am going to give a kick in the dark on how to fix it.
                    I was fusing the commerce improvmets to the food/prouction ones. Since the AI Does not build them and only builds one of the list at the time. When i found another problem.
                    How to make the AI build Undersea mine without giving up the land ones?
                    Here what i did. took the Undersea mine out of the improvement list. Only the land mines were in the list.
                    The idea was to make the land mines buidables in the water. yet when they were build the tileindex would change for an Undersea mine. I did not delete all the Undersea mines they were still there for the human to build in the conventional. But the AI would build as a land mine. Here is a sample from my tileimp.txt.
                    I can't tell you anything about it, the AI was never so far in my games that it was able to build undersea cities and tunnels. So you must be shure that the AI has the advances to build that stuff.

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

                    Comment


                    • #11
                      Hi all,
                      Thanks to Cube - OOps, I attached the original med mod files. Please download the new zip file attached which has the two completed files starting ZJRD. My apologies for that incorrect attached file.
                      Pedrunn thanks for the tip. I tried it before posting these files and could not get it to work on building undersea maglevs. I also switched the whole thing round and it happily built undersea tunnels on land!! - so its something to do with the values for Shelf etc.
                      Please post back any bugs you find - I will have a look for a solution.

                      Thanks for your patience

                      AOW
                      Attached Files
                      Lady Astor : "If I were your wife I would put poison in your drink"
                      Churchill : "If I were your husband I would gladly drink it"
                      Unclear words can wipe out all human life on earth if used improperly

                      Comment


                      • #12
                        Hi all,
                        I have edited all posts so that correct files are in download sections. If you are new to this load the ZJRD files into the directory and change the gamefile entries to point at these.

                        There is a new problem with the transforming of land as the AI including humans mayors will convert all land and this removes the trade goods from the map. Of course the human player without mayors can see the trade goods and avoid transforming land under them.

                        The values of the terrain and improvements have been increased to allow enough credit of PW and GOLD in the system. Is the AI generating enough to keep going? - The AI keeps well ahead in the games I have played.

                        Martin, the AI has all necessary advances for building tunnels, and I can place the undersea tunnel from the normal menu. Has anyone else had a try at this part yet?

                        I have had the error MONARCHY, DEMOCRACY etc. not found in AdvanceDB!!. It stopped the game loading. The error was in the tut2_main.slc so I have taken out the following section with //

                        //any govt adv discd
                        //
                        //HandleEvent(GrantAdvance) 'TNewGovt' post {
                        // if(IsHumanPlayer(player[0])) {
                        // advance[0] = value[0];
                        // if(advance[0].type == AdvanceDB(ADVANCE_MONARCHY)
                        // || advance[0].type == AdvanceDB(ADVANCE_THEOLOGY)
                        // || advance[0].type == AdvanceDB(ADVANCE_BUREAUCRACY)
                        // || advance[0].type == AdvanceDB(ADVANCE_DEMOCRACY)
                        // || advance[0].type == AdvanceDB(ADVANCE_COMMUNISM)
                        // || advance[0].type == AdvanceDB(ADVANCE_FASCISM)
                        // || advance[0].type == AdvanceDB(ADVANCE_ECOTOPIA)
                        // || advance[0].type == AdvanceDB(ADVANCE_CORPORATE_REPUBLIC)
                        // || advance[0].type == AdvanceDB(ADVANCE_TECHNOCRACY)
                        // || advance[0].type == AdvanceDB(ADVANCE_VIRTUAL_DEMOCRACY)) {
                        // Message(player[0], 'TMNewGovt');
                        // DisableTrigger('TNewGovt');
                        // }
                        // }
                        //}


                        Sorry if all the lines don't display properly.
                        It has had no effect on the game taking this out. Is there another fault somewhere which causes this section to crash?

                        Peter I am an enthusiastic amateur in the programming side and have had a closer look at the SLIC codings - it seems pretty straight forward on the surface but I will need a bit of practice in getting to grips with the command set and syntax.

                        Pedrunn I am further into game now and the Americans have built many sea colonies. The mines for undersea are only building on rifts. When searching to place sea colonies the AI just seems to find a space - I checked the tut2_terrain.slc and all undersea values are 0!! - I will see if I can adjust this for land and sea, it says it doesn't work in rem comment but we shall see.I will post new file if it is anything useful.

                        Please give feed back on posted files - thanks AOW.
                        Lady Astor : "If I were your wife I would put poison in your drink"
                        Churchill : "If I were your husband I would gladly drink it"
                        Unclear words can wipe out all human life on earth if used improperly

                        Comment


                        • #13
                          Originally posted by sun_tzu_159
                          There is a new problem with the transforming of land as the AI including humans mayors will convert all land and this removes the trade goods from the map. Of course the human player without mayors can see the trade goods and avoid transforming land under them.
                          You should try this code it is written for GoodMod therefore it isn't possible to construct the processor tower on goods either:

                          PHP Code:
                          HandleEvent (CreateImprovement)'MG_ImpOnGoodStop' pre {
                          int_t MG_tilimpcreate;
                          MG_tilimpcreate value[0];
                          improvement[0] = MG_tilimpcreate;
                              if (
                          GetCurrentRound () > 1) {
                                  if (
                          HasGood(MGGoodLoc)>-1) {
                                      if ((
                          MG_tilimpcreate == TerrainImprovementDB(TILEIMP_TERRAFORM_GRASSLAND))
                                        ||(
                          MG_tilimpcreate == TerrainImprovementDB(TILEIMP_PROCESSING_TOWER))) {
                                          return 
                          STOP;
                                      }
                                  }
                              }

                          Disclaimer: Untested, untried, no guarantee, but I will test it as soon as possible.

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

                          Comment


                          • #14
                            Martin,
                            I am trying another approach.
                            To scan the map at the start of the turn for the location of all goods and compile a list.
                            At the end of the turn you scan the map again for any locations where the goods have disappeared. I have written a SLIC code based on your CRA_GoodsMod.slc but do not understand how this command works.

                            Event:CreateImprovement(0,JDGoodLoc, 45,0 );

                            What are the three numeric parameters and what do they refer to?

                            The SLIC completes its checking loop correctly but does not put the good back on the square it came from with the above command - any ideas.

                            I have attached another file here which is the ImprovementsList.txt to drive the AI into converting terrain more quickly. I have put the terraform into categories.

                            Sorry I didn't post earlier but I couldn't get Apolyton site at the weekend.

                            Regards
                            AOW
                            Attached Files
                            Lady Astor : "If I were your wife I would put poison in your drink"
                            Churchill : "If I were your husband I would gladly drink it"
                            Unclear words can wipe out all human life on earth if used improperly

                            Comment


                            • #15
                              Originally posted by sun_tzu_159
                              Event:CreateImprovement(0,JDGoodLoc, 45,0 );

                              What are the three numeric parameters and what do they refer to?
                              The first is the owner, in this case the barbarians. The location is next, then the second number is the improvement's database reference - 45. The last is um... something else. Put it to 0, and it won't do any harm. Could be distance from the location as in CreateUnit.
                              The SLIC completes its checking loop correctly but does not put the good back on the square it came from with the above command - any ideas.
                              Damn I hate this function...
                              It will work if:
                              The barbarians have enough PW to lay it
                              They can see the tile (I don't think they have to own it)
                              There is no validity errors with the tile (its not water etc...)
                              Concrete, Abstract, or Squoingy?
                              "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                              Comment

                              Working...
                              X