regoarrarr Wrote:What we need to do is figure out the odds of different resources appearing on different tiles to check the odds that our plains tile is horse / copper / something else / nothing. It's got to be somewhere in the map generator, right? I mean we always see certain bonuses always appearing on certain tiles, right? Like gold is always on plains or desert hills, or gems always on grass or grass hills.
The algorithm for resource placement seems to be roughly:
1. Decide on a number of resources (bonuses) of a given kind to place.
2. Repeatedly choose a random tile, and if that tile's terrain allows the given resource, place a resource there.
The function deciding the number of resources to place is this one:
Code:
int CvMapGenerator::calculateNumBonusesToAdd(BonusTypes eBonusType)
{
CvBonusInfo& pBonusInfo = GC.getBonusInfo(eBonusType);
// Calculate iBonusCount, the amount of this bonus to be placed:
int iRand1 = GC.getGameINLINE().getMapRandNum(pBonusInfo.getRandAppearance1(), "calculateNumBonusesToAdd-1");
int iRand2 = GC.getGameINLINE().getMapRandNum(pBonusInfo.getRandAppearance2(), "calculateNumBonusesToAdd-2");
int iRand3 = GC.getGameINLINE().getMapRandNum(pBonusInfo.getRandAppearance3(), "calculateNumBonusesToAdd-3");
int iRand4 = GC.getGameINLINE().getMapRandNum(pBonusInfo.getRandAppearance4(), "calculateNumBonusesToAdd-4");
int iBaseCount = pBonusInfo.getConstAppearance() + iRand1 + iRand2 + iRand3 + iRand4;
bool bIgnoreLatitude = GC.getGameINLINE().pythonIsBonusIgnoreLatitudes();
// Calculate iNumPossible, the number of plots that are eligible to have this bonus:
int iLandTiles = 0;
if (pBonusInfo.getTilesPer() > 0)
{
int iNumPossible = 0;
for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
if (pPlot->canHaveBonus(eBonusType, bIgnoreLatitude))
{
iNumPossible++;
}
}
iLandTiles += (iNumPossible / pBonusInfo.getTilesPer());
}
int iPlayers = (GC.getGameINLINE().countCivPlayersAlive() * pBonusInfo.getPercentPerPlayer()) / 100;
int iBonusCount = (iBaseCount * (iLandTiles + iPlayers)) / 100;
iBonusCount = std::max(1, iBonusCount);
return iBonusCount;
}
Horse (placeable on flatland grassland, plains and tundra):
<iConstAppearance>100</iConstAppearance>
<Rands>
<iRandApp1>10</iRandApp1>
<iRandApp2>10</iRandApp2>
<iRandApp3>0</iRandApp3>
<iRandApp4>0</iRandApp4>
</Rands>
<iPlayer>100</iPlayer>
<iTilesPer>256</iTilesPer>
Copper (placeable on grass, desert, tundra, plains, snow):
<iConstAppearance>100</iConstAppearance>
<Rands>
<iRandApp1>10</iRandApp1>
<iRandApp2>10</iRandApp2>
<iRandApp3>0</iRandApp3>
<iRandApp4>0</iRandApp4>
</Rands>
<iPlayer>50</iPlayer>
<iTilesPer>128</iTilesPer>
Iron (also placeable on grass, desert, tundra, plains, snow):
<iConstAppearance>100</iConstAppearance>
<Rands>
<iRandApp1>10</iRandApp1>
<iRandApp2>10</iRandApp2>
<iRandApp3>0</iRandApp3>
<iRandApp4>0</iRandApp4>
</Rands>
<iPlayer>100</iPlayer>
<iTilesPer>128</iTilesPer>
If you can figure out the likely terrain composition of the world, you can probably calculate the odds of having copper, horse and iron on that tile. Good luck!
I have to run.