[MAPSCRIPT] Always missing specific resources for small maps (islands/custom continents)

sk0rpi0n

Chieftain
Joined
Mar 31, 2009
Messages
15
Hi everybody,
I noticed that on the small maps, particularly in "islands" and in "custom continents", there are always (or almost always) these missing resources:

- Stone
- Incense
- Wine
* EDIT - I forgot Sugar, never ever present!

In some maps goes worse and I cannot find a single resource of Horse!
Missing Horse is a very bad occurrence, but most of the times is available on the map.
Incense and Wine are "only" (...) luxury resource, but image how frustrating can be for an Industrious leader the total lack of Stone!

First I have to say that I'm everything but a novice with Civ4; from the launching of the game in 2005 I experimented really thousands of hours of play, both in singleplayer and in multiplayer, and I tried almost everything with this game!

Here is my typical configuration when playing Civ4:

- Of course latest version of BtS patched with Better BAT AI mod, that is necessary to advancing games I do (and BlueMarble to enhance terrain graphics)
- I usually play 18 Civs included mine at Deity; many times I also play in multiplayer via LAN with a couple of friends (very very funny games!!)
- I don't think the problem is due to the Better BAT AI mod because it use the standard map generator
- Also with different map generators (Full of Resources v3.11 and Planet Generator v0.68) the problem persists (no Stone, Incense and Wine at all on 95% of maps)
- These map generators are however based on the standard xml file of the original map generator included in Civ4, that is "Civ4BonusInfos.xml" in the folder "\Civilization_4_installation_path\Warlords\Assets\XML\Terrain" (I know, even if I play BtS the map script generator for the resources is always taken from the Warlords folder!)

I reloaded many many times, with the options "Lock Modified Assets" deactivated to see with the options "Enter WorldBuilder" the resources deployed, and it's always the same story.

The strange thing is that the Marble resources are good and always placed in all the maps! And looking in the "Civ4BonusInfos.xml" file i noticed that in the scripts the options for Marble are exaclty the same for Stone!
So, it's not a question of settings I think, the only differences between Marble and Stone placement are the terrain types.

I tried some tricks to increase the Stone resources in the xml file, according with the editing guide:

http://modiki.civfanatics.com/index.php?title=Civ4BonusInfos

- Tried increasing the <iPlayer>50</iPlayer> value, but also setting that to 200 nothing seems to happen
- Tried increasing the <iTilesPer>0</iTilesPer> value, also setting higher values no results
- Tries same trick with <iConstAppearance>100</iConstAppearance>, no results
- If I set <iPlacementOrder>3</iPlacementOrder> at a value fo 2 the map is generating with too much resources of Stone

Regarding the terrain types where Stone could be available (Hills, Plains and Deserts), in the generated map there are plenty of free tiles with no resources on it, so I don't think (but maybe I'm wrong) the problem is due to the terrain types difference with Marble.
And about the placement order I thought that maybe "Stone" is generated after "Marble" due to alphabetical order (even if <iPlacementOrder> is 3 for both), so when Marble is placed remains no "free tiles" for Stone.

So, the question is: anyone of the modders here has idea of why of that situation?
Thank you so much, any help is appreciated!

P.S. If someone asks why small maps with 18 Civs: have you ever tried playing Deity and win with 18 Civs? One of the crucial things is not to leave AIs expand too much... otherwise you are dead because 3 of their cities produces commerce/science as 8 of mine cities! So i have to "limit" other Civs expansion while I'm trying to expand myself! :p
 
Last edited:
Based on your analysis, my idea would be to reduce iUnique for BONUSCLASS_WONDER in Civ4BonusClassInfos.xml (in the Vanilla Civ 4 files). As far as I can tell, iUnique=8 prevents Stone and Marble from getting placed on the same landmass within a distance of 8 tiles. And then perhaps to increase the iUnique values of Stone and Marble in Civ4BonusInfos.xml to avert clumps of Stone and clumps of Marble.

On overcrowded maps, I would've expected that it's the extra copies of strategic resources placed per player (iPlayer percentage in Civ4BonusInfos.xml) that make non-strategic resources like Wine scarce. However, this can't explain (or is contradicted by) the scarcity of Horses on your maps. :undecide:
 
I found a "solution" only for the Stone: both in Stone and Marble the <iPlayer> value are set to 50, and increasing the value for Stone didn't change the results.
However, I noticed that decreasing it for Marble at a value i.e. of 30, the quarry resources generated are almost the same both for Stone and Marble, maintaining the overall amount of quarry resources the same.
Now I have the exact problem for other resourcer like stone that seems never been generater on small maps (remember, I use islands/continents), that are like I said Incense, Wine and I forgot also Dye (most of the times) and above all Sugar, that is never present!
I will try editing the <iPlayer> value for these other resources and for all the others with <iPlacementOrder> of 5 (Dye, Fur, Gems, Gold, Incense, Ivory, Silk, Silver, Spices, Sugar, Wine), then I will post the results!
f1rpo, I take a look at the file you said but the strange thing is that in many maps I see Marble and Stone in a distance LESS than 8 tiles!

P.S. Sure you're from Germany? Your avatar is not new to me at all... I'm from Italy! ;)
 
One solution, which only works with BtS (Beyond the Sword) is to use the “Full of Resources” map script, which I will attach here. To install:
  • Open up the zip file
  • Place the .py file in your PublicMaps folder; such as “/Users/Yourname/Documents/My Games/Beyond the Sword/PublicMaps/”
  • Look for “full_of_resources” in the list of map scripts after selecting single player → custom game
  • This script can play a number of different map scripts, but with much more extensive customization of resources and other elements of the maps
While there is a discussion thread for this map script, it has not been posted to for years.
 

Attachments

  • full_of_resources_3_11.zip
    162.1 KB · Views: 135
Hi vktj,
as I said in the firts post, 90% of the times I generate a new map I already use Full of Resources; this both in single player and in multiplayer.
Honestly the first thing I tried to do is to change the Full of Resources settings, but there is not much... i.e. I can multiply the strategic resurces, but this is not what I want to obtain; I can also add a Stone resource in the neighborhood of the starting points (of the human player and/or of the A.I.), but this is not fair and also this option create a Stone resource not using the settings of the original XML (i.e. have you ever seen a Stone resource in the forest or in the grassland? :p )
So the solution of the problem must be found upstream, in the XML.
Today I will try to edit the <iPlayer> value for the resources with <iPlacementOrder> of 5... however it's really strange that in every maps I generate (not only with the mods but also with the standard Civ4 BtS version) some kind of resources are missing, and among these the Stone, that is one of the strategic ones and so very important!
 
OK, if Full of resources doesn’t work, try Perfect world or my own Totestra variant of Perfect World. Perfect World has code where it tries very hard to make sure each resource gets placed on the map at least once. And, yes, it also tries hard to put resources on the appropriate terrain.

Note that, by default, Perfect World has a somewhat annoying way of putting different resources on separate continents, but my Totestra variant has an option, “Map resources” (one may have to scroll down to see it), which can disable that annoying behavior, and even has a “Full of resources” mode which puts more resources on the map. There is also an option in Totestra to give the player more resources near their starting location.

Adapting Perfect World’s very complicated resource (“Bonus”) placement code in to a more standard map script is left as an exercise to the reader.
 

Attachments

  • TotestraRG32.zip
    55.5 KB · Views: 145
Ok, I'll take a look today to your mod, thank you!

@f1rpo In the Civ4BonusClassInfos.xml file I understood how it works iUnique for BONUSCLASS_WONDER (8 means 8 tiles).

What about the other values? I don't understand the meaning of:

<Type>BONUSCLASS_GENERAL</Type> (...general...?!)
<Type>BONUSCLASS_GRAIN</Type> (maybe Corn/Wheat/Rice?)
<Type>BONUSCLASS_LIVESTOCK</Type> ?!?
<Type>BONUSCLASS_RUSH</Type> ?!?
<Type>BONUSCLASS_MODERN</Type> ?!?

Thank you!
 
[...] (Dye, Fur, Gems, Gold, Incense, Ivory, Silk, Silver, Spices, Sugar, Wine), then I will post the results!
f1rpo, I take a look at the file you said but the strange thing is that in many maps I see Marble and Stone in a distance LESS than 8 tiles!
Hmm. Stone and Marble also have bNormalize=1, and it appears that, during the normalization of starting locations, the range requirements can be ignored.
[...] What about the other values? I don't understand the meaning of:

<Type>BONUSCLASS_GENERAL</Type> (...general...?!)
<Type>BONUSCLASS_GRAIN</Type> (maybe Corn/Wheat/Rice?)
<Type>BONUSCLASS_LIVESTOCK</Type> ?!?
<Type>BONUSCLASS_RUSH</Type> ?!?
<Type>BONUSCLASS_MODERN</Type> ?!?

Thank you!
It's determined by the BonusClassType tag in Civ4BonusInfos.xml. Grain - yep. Livestock is Cow, Pig, Sheep; Rush is Copper, Horse, Iron; Modern is Aluminum, Oil, Uranium. General: all the rest.

Sugar and Wine are the last two land resources in Civ4BonusInfos.xml and have PlacementOrder=5. The order of the XML file works as a tie-breaker when PlacementOrders are the same. So that ought to have something to do with the low frequency of appearance. Ultimately, all the answers are in the source code, in this case here: CvMapGenerator.cpp#L673
The other relevant functions are addUniqueBonusType (for bArea=1), addNonUniqueBonusType (bArea=0) and canPlaceBonusAt. The Perfect World maps replace all that.
P.S. Sure you're from Germany? Your avatar is not new to me at all... I'm from Italy! ;)
Well, he's revered here too. As is Italian ice cream. :lol:
 
OK, if Full of resources doesn’t work, try Perfect world or my own Totestra variant of Perfect World. Perfect World has code where it tries very hard to make sure each resource gets placed on the map at least once. And, yes, it also tries hard to put resources on the appropriate terrain.

Note that, by default, Perfect World has a somewhat annoying way of putting different resources on separate continents, but my Totestra variant has an option, “Map resources” (one may have to scroll down to see it), which can disable that annoying behavior, and even has a “Full of resources” mode which puts more resources on the map. There is also an option in Totestra to give the player more resources near their starting location.

Adapting Perfect World’s very complicated resource (“Bonus”) placement code in to a more standard map script is left as an exercise to the reader.

Hi vktj, I tried your map generator but unfortunately is not what I'm searching for: at Deity difficulty I have to exactly calibrate some aspects of the map, an these options are only possible with Full of Resources or Planet Generator.
Example: I can't start on a big huge continent with 6/7 AIs on it, it's sure they will destroy me! That's why I usually start on Custom Continents setting 6 landmasses; in this case I havo to face "only" 2/max 3 CPUs Deity to have the control of my continent; sometimes I also prefer Islands, with 1 island for player, and from that isle I'll start my
amphibious war with galleys!
Apart from that with FoR I have calibrated also many many little settings of the map which helps me with Deity CPUs, i.e. there are a little abundance of water resources, less deserts and tundras, many more forests to increase initial production with Bronze Working, less mountains, etc. but anyway every player (cpu/human) start the game with the same chances.

@f1rpo

I changed the file Civ4BonusInfos.xml and I set most of the standard settings 1 point less of the original, now it's a little better with Marble and Stone.

I have however the same problem: Wine still rare, Incense inexistent in 80% of the maps and Sugar never ever present; can please someone check if on small maps it's not only a problem of my game regarding the Sugar? And finally: Sugar in alphabetical order is before Wine, but I have always more chances to find 1 or 2 Wines on the generated maps instead of Sugar. With the "S" we have also "Silk" and "Spices", and those 2 resources are ALWAYS sovra-abundant in every generated maps, I can found them in most of the continents, and in a group of 6 to 12 sometimes!!...
 
I have however the same problem: Wine still rare, Incense inexistent in 80% of the maps and Sugar never ever present; can please someone check if on small maps it's not only a problem of my game regarding the Sugar?
What settings can I use to (easily) reproduce the problem? 6 Custom Continents, Standard size, 18 players? Quick test with Better BAT AI: No Sugar, presumably because the continents are all placed a good distance from the equator, i.e. no jungle.
 
Yes, that settings!
The low jungle areas was one of my first thoughts, however Sugar can also be placed in grasslands.
My usual settings:

- Full of Resources 3.11 / PlanetGenerator 0.68 (mods included in Better BAT AI), but also Civ4 BtS standard maps have the same problems
- Custom Continents with 6 continents (1 every 3 player) OR Islands (1 per player)
- Small map
- Sealevel normal or high (not much difference in small maps!)

Difficult to find: Stone (rare), Wine (rare), Incense (only few games), Sugar (never!)
All this without touching the XML files, so with the standard configuration; now it's a little better but I bet that using different map configurations (i.e. standard size, archipelago/snaky continents) the editing of the XML files could lead to unpredictable results... the best solution would be to create something standard for every map!
Thank you for now! ;)
 
Last edited:
One more info: a quick way to increase in percentage the water resources on standard map generators? (without using Full of Resources)?
Thank you all!
 
One more info: a quick way to increase in percentage the water resources on standard map generators? (without using Full of Resources)?
Thank you all!
I'm not aware of any special treatment for water resources in the placement code. So, I think you'd have to reduce the iTilesPer value for each of them or increase the iPlayers value.
The low jungle areas was one of my first thoughts, however Sugar can also be placed in grasslands.
Jungle gets cleared around starting locations, so Sugar can end up on open Grassland, but I think it has to be placed on Jungle. Such local requirements are delegated to CvPlot.cpp::canHaveBonus:
Code:
if (getFeatureType() != NO_FEATURE) {
   if (!GC.getBonusInfo(eBonus).isFeature(getFeatureType()))
      return false;
   if (!GC.getBonusInfo(eBonus).isFeatureTerrain(getTerrainType()))
      return false;
   }
else {
   if (!GC.getBonusInfo(eBonus).isTerrain(getTerrainType()))
      return false;
}
If there is no feature, then the resource needs to have a TerrainBoolean; Sugar has none.

I'm attaching a screenshot from my own mod - which actually does alter the resource placement a little, but I don't think it matters much here. I have Better BAT AI installed, but can't take a nice screenshot in there (or would have to apply some tweaks first). This was with the 1-continent-per-team option; seems like 6 is the limit.

I've tried Tropical climate afterwards to correct the map's anti-Jungle bias. That leads to a fair amount of Jungle before the players are placed (about 4 rows of tiles per continent), but there is still no Sugar. So you're right that lack of Jungle isn't the main issue.

Apparently, all the continents are just filled to the brim with resources, so the last two, Wine and Sugar, don't find any room (Wine some because it doesn't require Jungle). Resources don't get placed – orthogonally or diagonally – adjacent to each other except during the normalization of starting locations (CvGame::normalizeAddExtras). normalizeAddExtras goes through the resources in the order of Civ4BonusInfos.xml. Also, Jungle gets removed before considering extra resources. So, again, no Sugar.

What I'd try for the these super-crowded maps is to reduce the iPlayer values as much as necessary to get the resources spaced a bit farther apart; and to set Tropical climate for the 6-continent option.

My tentative takeaway for modding the DLL is that ties in the placement order should be broken randomly, not (quasi-)alphabetically, and that normalizeAddExtras needs to go through the resources in random order as well. The latter change might also increase the variety of starting locations.
 

Attachments

  • CustomContinentsSmall18Plyrs.jpg
    CustomContinentsSmall18Plyrs.jpg
    405.5 KB · Views: 181
Top Bottom