Thread Tools
Old January 18, 2002, 02:07   #1
WarLoard
Settler
 
Local Time: 05:31
Local Date: November 1, 2010
Join Date: Jan 2002
Location: Sydney
Posts: 4
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?
WarLoard is offline  
Old January 18, 2002, 05:15   #2
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81

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:
File Type: zip mm2_transform_012202.zip (13.7 KB, 38 views)

Last edited by sun_tzu_159; January 23, 2002 at 04:13.
sun_tzu_159 is offline  
Old January 18, 2002, 15:07   #3
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
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:
File Type: zip mm2_transform_012202.zip (13.7 KB, 23 views)

Last edited by sun_tzu_159; January 23, 2002 at 04:15.
sun_tzu_159 is offline  
Old January 18, 2002, 20:53   #4
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Hi, sun_tzu_159

Good to see someone with such a firm command of the game turn up. How are you on SLIC?
Peter Triggs is offline  
Old January 18, 2002, 22:52   #5
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 21:31
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
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
Locutus is offline  
Old January 19, 2002, 08:19   #6
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 20:31
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
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.
Immortal Wombat is offline  
Old January 19, 2002, 20:56   #7
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
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
sun_tzu_159 is offline  
Old January 20, 2002, 07:19   #8
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 16:31
Local Date: October 31, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
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?
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand

Last edited by Pedrunn; January 20, 2002 at 07:27.
Pedrunn is offline  
Old January 20, 2002, 20:38   #9
Cube
Warlord
 
Cube's Avatar
 
Local Time: 12:31
Local Date: October 31, 2010
Join Date: Nov 2000
Location: El Paso, Tx
Posts: 120
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.
Cube is offline  
Old January 21, 2002, 07:55   #10
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 21:31
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
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.

Quote:
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!"
Martin Gühmann is offline  
Old January 21, 2002, 20:50   #11
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
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:
File Type: zip mm2_transform_012202.zip (13.7 KB, 47 views)
sun_tzu_159 is offline  
Old January 23, 2002, 05:20   #12
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
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.
sun_tzu_159 is offline  
Old January 25, 2002, 14:03   #13
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 21:31
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
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!"
Martin Gühmann is offline  
Old January 28, 2002, 17:18   #14
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
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:
File Type: zip mm2_improvementlist_012802.zip (647 Bytes, 27 views)
sun_tzu_159 is offline  
Old January 28, 2002, 18:12   #15
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 20:31
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
Quote:
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.
Quote:
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...)
Immortal Wombat is offline  
Old January 29, 2002, 10:08   #16
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 21:31
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originally posted by
sun_tzu_159

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.
In GoodMod you can devide the goods into two parts. On the one hand the invisible part, the tile improvement that adds the boni to the tile and on the other hand the trade good, that is also in the original game. And it is the visible part of the Good.

So you want to recreate the entire good. You have to recreate the tile improvement. Note that the first argument must be the owner of the cell or the owner of an unit that has this location in its vision range. If the future owner does not own the location he can only build there tile improvements with fort like characteristics.

Maybe you should rather use the version of the goods restoration code:

PHP Code:
Event:CreateImprovement(CellOwner(location[0]), location[0], 520); 
Instead of the number for the third argument you can also use a funktion that returns the DB index of the improvment here is an example from BlueO:

PHP Code:
EventCreateImprovement(tmpCity.ownertmpLocTerrainImprovementDB(TILEIMP_ROAD), TerrainImprovementDB(TILEIMP_ROAD)); 
You notice that he used the fourth argument it requres an Int but I have also no idea what it does. From BlueO's example you might think this could the an option for a second improvment, but I think it does nothing it is just there. Otherwise my code would create a lot of advanced farms.

With this funktion you don't need to take so much care on your improvemnt database as you have to do it if you use the numbers.

If the the tile improvment is back on the map than it needs a certain time until it is finished. All good improvments have a contruction time of ten turns. As long as you don't use this function on the given location:

PHP Code:
FinishImprovements(MGUnitLoc); 
So the improvment will be finished but in your case the good would be still missing just the terrain boni would be back. So finally or at first you have to plant a good that is the funktion that will do the job:

PHP Code:
PlantGood(MGGoodLoc); 
But why do it in a so complecate way just prevent the AI and the mayors from terraforming the good. From your ImprovementsList.txt I know that you considered more terraforming options for the AI (I just use the grassland option), but that means that you have to modify my code that I gave above.

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_TERRAFORM_PLAINS))
              ||(
MG_tilimpcreate == TerrainImprovementDB(TILEIMP_TERRAFORM_JUNGLE))
              ||(
MG_tilimpcreate == TerrainImprovementDB(TILEIMP_TERRAFORM_FOREST))
              ||(
MG_tilimpcreate == TerrainImprovementDB(TILEIMP_TERRAFORM_SWAMP))) {
                return 
STOP;
            }
        }
    }

Another note about the improvment list the original file looks unfinished and the AI was able to improve its terrain. It uses also some of my good improvments. So I guess this file is there but completely useless.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old January 30, 2002, 15:09   #17
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
Dear all,

Immortal Wombat - thanks for the pointers, I think this function was made for something not fully implemented. I have tried many values for the last digit but no effect is seen.
Great suggestions - keep them coming. I have pasted below my slic file so far. It scans the whole map at the start of the turn and records the goods locations in the array JDGoodsHere. I have put Dales trumpets in just to prove that it correctly identifies all squares with goods on.


location_t JDGoodLoc; //where the search for goods is at
int_t JDCounter; //array location counter
location_t JDGoodsHere[]; //array to load with location of all goods at start of turn
int_t JDTerrainScore; //determine which terrain the new good is to be placed on
int_t CellOwner; //Returns value for player number

#include "tut2_terraina.slc" //TERRAIN_SCOREA array is here

// Load up array with location of squares with goods on them.

HandleEvent(BeginTurn) 'JRD_BeginTurn' pre {

//set up local variables for routine

int_t i; //array location counter
int_t j; //array location counter

JDCounter=0;
for (i=0; i<=GetMapWidth()-1; i=i+1) {
for (j=0; j<=GetMapHeight()-1 ; j=j+1) {
MakeLocation(JDGoodLoc, i, j);
if (HasGood(JDGoodLoc) > -1) {
JDCounter=JDCounter+1;
JDGoodsHere[JDCounter]=JDGoodLoc;
}
}
}
}

//################################################## ###############################################
//################################################## ###############################################

//Next bit attempts to stop tile improvement being placed on trade good.

HandleEvent(CreateImprovement) 'JRD_CreateImprovement' pre {

//set up local variables for routine

int_t m; //array location counter

for(m=0;m JDGoodLoc=JDGoodsHere[m];
JDTerrainScore=TERRAIN_SCOREA[TerrainType(JDGoodLoc)];
if (HasGood(JDGoodLoc)>-1){
AddEffect(JDGoodLoc, "SPECEFFECT_DIPLOMATIC", "SOUND_ID_EXPEL");
return STOP;
}
}
}

//################################################## ###############################################
//################################################## ###############################################


Somehow the AI gets round the return STOP whether pre or post createimprovement and transforms the land and deletes the trade goods.

So I have tried putting the trade goods back but don't know an instruction to do this. The following piece of code checks the array of goods set up prior to the terrainimprovement and compares it to the current map. Where goods are missing they should be replaced. But I do not know the numbers to put in to replace trade goods.


//Next bit runs every turn to check if any goods have disappeared
//if they have then they are replaced on the map with the appropriate good for the transformed tile
//Check done by checking terrain score to see what type of terrain

HandleEvent(ImprovementComplete) 'JRD_ImprovementComplete' post {

//set up local variables for routine

int_t m; //array location counter

for(m=0;m JDTerrainScore=TERRAIN_SCOREA[TerrainType(JDGoodsHere[m])];
JDGoodLoc=JDGoodsHere[m];
AddEffect(JDGoodLoc, "SPECEFFECT_DIPLOMATIC", "SOUND_ID_EXPEL");
if (HasGood(JDGoodLoc)<0){//Replace Goods Here
AddEffect(JDGoodLoc, "SPECEFFECT_DIPLOMATIC", "SOUND_ID_EXPEL");
Event:CreateImprovement(player[CellOwner], JDGoodLoc, 49, 0);



I have observed that the scenario (cheat) editor quite happily transforms land without deleting goods and adds/removes trade goods without a problem. There must be a code linked to pressing the add goods buttons 1-4 on this menu that can be used in this SLIC. Does anyone know what the code is or where it is?

Martin I will try out with PlantGood function mentioned - thanks for the suggestion. I will post a working SLIC as soon as I have one but it will be MedMod because there are less goods and easier checking. The code will be easily expanded though.

I agree that the original improvement file was hopeless - the AI could only build a very few improvements.

I am sorry if the code is a bit clumsy but this is my first attempt at writing a complete script code from scratch.

Waiting for any more input.

Regards
AOW.
sun_tzu_159 is offline  
Old January 30, 2002, 17:10   #18
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
Hi all,
Back again, and so soon. Please find attached file which works by scanning all the map prior to the start of the turn and loads all the locations of the trade goods into an array. As I said before this is based on MedMod but may well work with any mod.
The second part runs after the terrainimprovements are done and checks that no values on the map are different to the start of the turn for those locations where goods existed. If they are different the trade good is replaced and will reappear but only as trade good 1.
Could there be a way to get the good replaced with the number of good prior to transformation.
I cannot see any reason why this would not work with any Mod.

Regards
AOW
Attached Files:
File Type: zip mm2_terrainmod_013002.zip (1.0 KB, 28 views)
sun_tzu_159 is offline  
Old January 31, 2002, 15:06   #19
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Hi, sun_tzu

I don't think it's a good idea to search the whole map at the beginning of *every* turn: not all of us have supercomputers like Martin's and even his might find it difficult.

I'm not at all sure what you guys are on about here, but I'm assuming that what you want to do is to stop the AI from terraforming tiles that have trade goods on them. In this case, what Martin suggested should work. In his GoodMod he had to use the MakeLocation function to assign a value to MGGoodLoc but here we can recover the location we want from the CreateImprovement event. In fact, we can recover the database value of the terrain improvement from this event too, so you don't even have to define any variables (unless you want to). Try this:

Code:
HandleEvent (CreateImprovement)'MG_ImpOnGoodStop' pre {
  
    if (GetCurrentRound () > 1) {//don't conflict with GoodMod
        if (HasGood(location[0])>-1 && !IsHumanPlayer(player[0])) {
	   //if the location has a good and it's the AI trying to:
                   //terraform it into grassland
            if (( value[0] == TerrainImprovementDB(TILEIMP_TERRAFORM_GRASSLAND))  
              ||( value[0] == TerrainImprovementDB(TILEIMP_TERRAFORM_PLAINS))     // ditto plains
              ||( value[0] == TerrainImprovementDB(TILEIMP_TERRAFORM_JUNGLE))     // and so on
              ||( value[0] == TerrainImprovementDB(TILEIMP_TERRAFORM_FOREST))
              ||( value[0] == TerrainImprovementDB(TILEIMP_TERRAFORM_SWAMP))) {
                return STOP; // don't let it do it
            }
        }
    }
}
This is basically what Martin wrote, I just added the condition "&& !IsHumanPlayer(player[0])" so that the human player can do any (maybe stupid) thing he wants. To test it, omit this clause; the handler should then prevent you from terraforming, e.g., any grassland tile that has a good on it.

BTW, if you use 'code' and '/code', both in square brackets, at the beginning and end of your code it won't get left justified like that. The same thing works with 'quote' and '/quote'. It took me about a year of frustrating posts before I asked Locutus and he explained these things to me.
Peter Triggs is offline  
Old February 1, 2002, 07:45   #20
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 21:31
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originally posted by Peter Triggs
I don't think it's a good idea to search the whole map at the beginning of *every* turn: not all of us have supercomputers like Martin's and even his might find it difficult.
I aggree therefore I suggested the code above. Maybe I should rewrite the Commerce Improvement For AI's code, so I could also speed up my games. But the delay that my good improving code cause it is not so long that the goody hut delay caused by the militia code. And of course it is much smaller than the delay caused by the original code.

Quote:
Originally posted by Peter Triggs
This is basically what Martin wrote, I just added the condition "&& !IsHumanPlayer(player[0])" so that the human player can do any (maybe stupid) thing he wants. To test it, omit this clause; the handler should then prevent you from terraforming, e.g., any grassland tile that has a good on it.
Actually I skipped that this small condition on purpose just to prevent human mayors to terraform goods.

Quote:
Originally posted by Peter Triggs
BTW, if you use 'code' and '/code', both in square brackets, at the beginning and end of your code it won't get left justified like that. The same thing works with 'quote' and '/quote'. It took me about a year of frustrating posts before I asked Locutus and he explained these things to me.
'PHP' and '/PHP' in square brackets will also work, it gives you this nice color effect and if you want to post some code from the Great Library it will display the code probably.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old February 1, 2002, 16:16   #21
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
Hi all,
I have been away off the net with modem problems but all is now right again.

quote:

Originally posted by Peter Triggs
I don't think it's a good idea to search the whole map at the beginning of *every* turn: not all of us have supercomputers like Martin's and even his might find it difficult.

I do not have a supercomputer - I have a 233MHz PII for my CTP2 testing. Even as it is the routine is taking about 0.75 seconds per turn on a 144x72 map.

The point of scanning the map on each turn is so that the goods are put back on the map at the end of each turn when the terrain terraform is completed - so you don't have to prevent terraforming by anyone.

If the data held in the array was preserved when the game is saved then it is static data from the first turn and the whole map scan only has to be done once.

If someone with a little more experience than me could put a Disable Trigger in the code after the first turn then the second part only checks the squares with goods on each turn - which on a V. large map is about 300 squares max. This cannot take alot of processor power.

Any thoughts on a slight mod of the code I posted. I can test any suggestions put forward.

Thanks for your input
AOW
sun_tzu_159 is offline  
Old February 3, 2002, 20:01   #22
sun_tzu_159
Chieftain
 
sun_tzu_159's Avatar
 
Local Time: 19:31
Local Date: October 31, 2010
Join Date: Jan 2002
Location: Cheshire
Posts: 81
Hi all,
I have been experimenting with the settings for AI to terraform and the file I posted earlier - mm2_terrainmod.zip - does work for all trade goods so my comment about only putting back trade goods type 1 was wrong.
The problem I have now is that the human player can use any available transformation immediately. e.g. from hill to grassland while the AI is forced by my terraform settings in tileimp.txt to go from hill to plains to grassland. This is because the human player is only restricted by the simple test as to whether or not the transform from hill and to grassland are available in terrain.txt and the AI uses tileimp.txt. Does anyone have any suggestions of a starting point for a SLIC code to control the human terraform.
Did anyone follow up earlier comments about the AI not building undersea tunnels? Has anyone seen the AI construct undersea tunnels? When and where if they did?
I have tried the following without success.
1) Reducing the cost to miniscule amount of gold
2) Increasing the movement rate per turn so that troops can move faster even than on MagLevs.
3) Replacing the undersea tunnels with Maglevs to see if maglevs could be built in water.

Perhaps a SLIC code along the lines of Cradles which forces the building of forts. Can I have some pointers and I will pick up suggestions and try them.

Cheers
AOW
sun_tzu_159 is offline  
Old February 27, 2002, 04:18   #23
WesW
Apolytoners Hall of Fame
 
WesW's Avatar
 
Local Time: 13:31
Local Date: October 31, 2010
Join Date: Mar 2007
Location: Florence, Al., USA
Posts: 1,554
I would like to include this code in my upcoming update for the Medpack, but I am confused as to whose code works the best.
Please paste in the code in with your new post.

Also, how intelligently does the AI use its terraforming ability? I mean, you only want to terraform Jungles to Plains and Plains to Grassland if the city is short on food. You also usually only need to terraform a few tiles per city. Does the AI keep terraforming simply because it can?
Also, the AIs need to be able and willing plant forests as well as clear them. How is it set up to do this?

This code can be a crucial improvement to the AI, since it only builds mines on plains and farms on grassland. Changing a few tiles from one to the other can have a huge effect on balancing a city's output.

Edit: I had Wouter send me copies of the files Sun Tzu posted here, and there are problems. First, the originals he used are now out-dated, and then he made his own modifications to the improvement effects. Thus, I don't know if the lines which fool the AI will work properly if pasted into standard versions of the MM2 tileimp.txt.
__________________
For Civ IV: The Medmod V v1.0.
For Medieval: Total War- The Medieval Mod IV v4.0.
The entire Medmod series is available at my Apolyton-hosted webpage.

Last edited by WesW; February 27, 2002 at 04:58.
WesW is offline  
Old February 27, 2002, 08:13   #24
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 21:31
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
I wouldn't use all his modifications, as the PW costs in terraform section are probably ignored, too. Sun Tzu thought that the costs are also set in the tileimp, too. But actual you have only consider the material costs of the add and remove section in the terrain.txt. For instance in the original terrain.txt it costs 2000 PW to remove a mountain and it costs 8000 to add an artic mountain, so terraforming from grey to white mountain costs in the original game 10000 PW. The production time is obviously taken from the terrain.txt, too. Another problem with his settings I think is that he made the AI terraform like the Civ2 human and AI players had to do it through the settler system. I made now for every terrain an own terrain block, to let the AI know when it can use the terraform option and gave every terrain effect block a food bonus value. You can find my code below I only modified the grassland option as I don't want to make the AI build forrest, but you could modify the forest section, too, although I think that will cause some more difficuilties. Unfortunatly I only played early games so far and the AI will only put a terrain improvement on a tile without an improvement as I saw that the Good tiles are usually without an additional tile improvement. So I would have to go into the late game when the AI can terraform tundra and mountains.

-Martin


PHP Code:
## 28 ##########################################################

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

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

   TerrainEffect 
{
      
Terrain TERRAIN_BROWN_HILL
      BonusFood 30 
      EnableAdvance ADVANCE_EXPLOSIVES
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_BROWN_MOUNTAIN
      BonusFood 30 
      EnableAdvance ADVANCE_FUSION
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_DESERT
      BonusFood 30 
      EnableAdvance ADVANCE_AGRICULTURAL_REVOLUTION
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_FOREST
      BonusFood 30 
      EnableAdvance ADVANCE_AGRICULTURAL_REVOLUTION
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_GLACIER
      BonusFood 30 
      EnableAdvance ADVANCE_ADVANCED_COMPOSITES
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_HILL
      BonusFood 30 
      EnableAdvance ADVANCE_EXPLOSIVES
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_JUNGLE
      BonusFood 30 
      EnableAdvance ADVANCE_AGRICULTURAL_REVOLUTION
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_MOUNTAIN
      BonusFood 30 
      EnableAdvance ADVANCE_FUSION
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_PLAINS
      BonusFood 5 
      EnableAdvance ADVANCE_TOOLMAKING
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_SWAMP
      BonusFood 30 
      EnableAdvance ADVANCE_INDUSTRIAL_REVOLUTION
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_TUNDRA
      BonusFood 30 
      EnableAdvance ADVANCE_ADVANCED_COMPOSITES
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_WHITE_HILL
      BonusFood 30 
      EnableAdvance ADVANCE_EXPLOSIVES
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_WHITE_MOUNTAIN
      BonusFood 30 
      EnableAdvance ADVANCE_FUSION
      TilesetIndex 1
   
}
   
TerrainEffect {
      
Terrain TERRAIN_DEAD
      BonusFood 300 
      EnableAdvance ADVANCE_CONSERVATION
      TilesetIndex 1
   
}

__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 15:31.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team