Replace many deprecated randInt calls with randBool.

Add optional probability to randBool to receive true and use where
applicable.

Patch By: bb
Differential Revision: https://code.wildfiregames.com/D235
Refs #4326 D121

This was SVN commit r19355.
This commit is contained in:
elexis
2017-03-28 04:28:55 +00:00
parent a934dfad5f
commit da2b89583a
28 changed files with 102 additions and 111 deletions
@@ -57,9 +57,9 @@ function randIntExclusive(min, max)
}
/**
* Returns true or false randomly.
* Returns a Bernoulli distributed boolean with p chance on true.
*/
function randBool()
function randBool(p = 0.5)
{
return Math.random() < 0.5;
return Math.random() < p;
}
@@ -252,7 +252,7 @@ createForests(
RMS.SetProgress(50);
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tGrass, tCliff, tHill], avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15));
else
createMountains(tCliff, avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15));
@@ -1,10 +1,7 @@
RMS.LoadLibrary("rmgen");
//set up the random terrain
var random_var = randInt(1,2);
//late spring
if (random_var == 1)
// late spring
if (randBool())
{
setFogThickness(0.26);
setFogFactor(0.4);
@@ -2,11 +2,8 @@ RMS.LoadLibrary("rmgen");
TILE_CENTERED_HEIGHT_MAP = true;
//set up the random terrain
var random_terrain = randInt(1,2);
//late spring
if (random_terrain == 1)
// late spring
if (randBool())
{
var tPrimary = ["alpine_dirt_grass_50"];
var tForestFloor = "alpine_forrestfloor";
@@ -214,7 +214,7 @@ for (var i = 0; i < numPlayers; i++)
createBumps([avoidClasses(clPlayer, 10), stayClasses(clLand, 5)]);
if (randInt(1,2) == 1)
if (randBool())
createHills([tMainTerrain, tCliff, tHill], [avoidClasses(clPlayer, 2, clHill, 15), stayClasses(clLand, 0)], clHill, scaleByMapSize(1, 4) * numPlayers);
else
createMountains(tCliff, [avoidClasses(clPlayer, 2, clHill, 15), stayClasses(clLand, 0)], clHill, scaleByMapSize(1, 4) * numPlayers);
@@ -396,8 +396,8 @@ for (var ix = 0; ix < mapSize; ix++)
explorableArea.points.push(pt);
}
if (h > 35 && g_Map.validT(ix, iz) && randFloat(0, 1) < 0.1 ||
h < 15 && g_Map.validT(ix, iz) && randFloat(0, 1) < 0.05 && hillDecoClass.countMembersInRadius(ix, iz, 1) == 0)
if (h > 35 && g_Map.validT(ix, iz) && randBool(0.1) ||
h < 15 && g_Map.validT(ix, iz) && randBool(0.05) && hillDecoClass.countMembersInRadius(ix, iz, 1) == 0)
placeObject(ix + randFloat(0, 1), iz + randFloat(0, 1), pickRandom(aTrees), 0, randFloat(0, 2 * PI));
}
}
@@ -301,97 +301,97 @@ for(var x = minTerrainDistToBorder; x < mapSize - minTerrainDistToBorder; x++)
// Add some props at...
if (i == 0) // ...deep water
{
if (randFloat() < 1/100 * propDensity)
if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
}
if (i == 1) // ...medium water (with fish)
{
if (randFloat() < 1/200 * propDensity)
if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
}
if (i == 2) // ...low water/mud
{
if (randFloat() < 1/200 * propDensity)
if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/20 * propDensity)
else if (randBool(propDensity / 20))
placeObject(x, y, "actor|props/flora/reeds_pond_lush_b.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/10 * propDensity)
else if (randBool(propDensity / 10))
placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
}
if (i == 3) // ...water suroundings/bog
{
if (randFloat() < 1/200 * propDensity)
if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
}
if (i == 4) // ...low height grass
{
if (randFloat() < 1/800 * propDensity)
if (randBool(propDensity / 800))
placeObject(x, y, "actor|props/flora/grass_field_flowering_tall.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/400 * propDensity)
else if (randBool(propDensity / 400))
placeObject(x, y, "actor|geology/gray_rock1.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/200 * propDensity)
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/bush_tempe_sm_lush.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/bush_tempe_b.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
}
if (i == 5) // ...medium height grass
{
if (randFloat() < 1/800 * propDensity)
if (randBool(propDensity / 800))
placeObject(x, y, "actor|geology/decal_stone_medit_a.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/400 * propDensity)
else if (randBool(propDensity / 400))
placeObject(x, y, "actor|props/flora/decals_flowers_daisies.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/200 * propDensity)
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_temp_field.xml", 0, randFloat(0, 2*PI));
}
if (i == 6) // ...high height grass
{
if (randFloat() < 1/400 * propDensity)
if (randBool(propDensity / 400))
placeObject(x, y, "actor|geology/stone_granite_boulder.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/200 * propDensity)
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/foliagebush.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/20 * propDensity)
else if (randBool(propDensity / 20))
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
}
if (i == 7) // ...forest border (with wood/food plants/deer/rabits)
{
if (randFloat() < 1/400 * propDensity)
if (randBool(propDensity / 400))
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/200 * propDensity)
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/bush_tempe_a.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
}
if (i == 8) // ...woods
{
if (randFloat() < 1/200 * propDensity)
if (randBool(propDensity / 200))
placeObject(x, y, "actor|geology/highland2_moss.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/100 * propDensity)
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
else if (randFloat() < 1/40 * propDensity)
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
}
break;
@@ -711,13 +711,13 @@ for (let h = 0; h < heighLimits.length; ++h)
let texture = pickRandom(myBiome[h].texture);
if (slopeMap[x][y] < 0.4 * (minSlope[h] + maxSlope[h]))
{
if (randFloat() < myBiome[h].actor[1])
if (randBool(myBiome[h].actor[1]))
actor = pickRandom(myBiome[h].actor[0]);
}
else
{
texture = pickRandom(myBiome[h].textureHS);
if (randFloat() < myBiome[h].actorHS[1])
if (randBool(myBiome[h].actorHS[1]))
actor = pickRandom(myBiome[h].actorHS[0]);
}
g_Map.setTexture(x, y, texture);
@@ -226,8 +226,7 @@ for (var i = 0; i < numPlayers; ++i)
// create bumps
createBumps([avoidClasses(clPlayer, 10), stayClasses(clLand, 5)]);
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tMainTerrain, tCliff, tHill], [avoidClasses(clPlayer, 20, clHill, 15, clBaseResource, 3), stayClasses(clLand, 5)], clHill, scaleByMapSize(1, 4) * numPlayers);
else
createMountains(tCliff, [avoidClasses(clPlayer, 20, clHill, 15, clBaseResource, 3), stayClasses(clLand, 5)], clHill, scaleByMapSize(1, 4) * numPlayers);
@@ -249,7 +249,7 @@ createForests(
RMS.SetProgress(50);
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tGrass, tCliff, tHill], avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15));
else
createMountains(tCliff, avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15));
@@ -106,7 +106,7 @@ for (var ix = 0; ix < mapSize; ix++)
}
// let's decide if we swap
var swap = Math.round(Math.random()); // should return about 50/50 a 0 or a 1
var swap = randBool();
// let's create Corsica
log("Creating Corsica");
var CorsicaX = fractionToTiles(0.99);
@@ -189,11 +189,8 @@ for (var island = 0; island <= 1; island++)
fz = radius * sin(angle);
fx = round(islandX[island] + fx);
fz = round(islandZ[island] + fz);
var size = scaleByMapSize(75,100);
if (Math.random() > 0.5)
size = Math.random() * 40 + 10;
else
size += Math.random() * 20;
var size = randBool() ? randFloat(10, 50) : scaleByMapSize(75, 100) + randFloat(0, 20);
var placer = new ClumpPlacer(size, 0.4, 0.01, 10, fx,fz);
var terrainPainter = new TerrainPainter(tSteepCliffs);
var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5,0); // base height is -10
@@ -226,7 +226,7 @@ for (var x = 0; x < mapSize; x++)
var tDensFactRad = abs((resourceRadius - radius) / resourceRadius);
var tDensFactEC = max(min((radius - radiusEC) / radiusEC, 1), 0);
var tDensActual = maxTreeDensity * tDensFactSL * tDensFactRad * tDensFactEC;
if (randFloat() < tDensActual && radius < playableMapRadius)
if (randBool(tDensActual) && radius < playableMapRadius)
{
if (tDensActual < bushChance*randFloat()*maxTreeDensity)
{
@@ -223,11 +223,13 @@ for (var ix = 0; ix < mapSize; ix++)
RMS.SetProgress(20);
log("Creating rivers");
for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++)
for (let i = 0; i <= randIntInclusive(8, scaleByMapSize(12, 20)); ++i)
{
var cLocation = randFloat(0.05,0.95);
var tang = 2*PI * randFloat(0.2, 0.8) * (randInt(2) - 0.5);
var cDistance = 0.05 * (tang > 0 ? 1 : -1);
var cLocation = randFloat(0.05, 0.95);
var sign = randBool() ? 1 : -1;
var tang = sign * PI * randFloat(0.2, 0.8);
var cDistance = sign * 0.05;
var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 4, 0.01);
if (point !== undefined)
@@ -354,7 +354,7 @@ for (var i = 0; i < numPlayers; i++)
createArea(placer, painter, null);
}
if (randInt(1,2) == 1)
if (randBool())
createHills([tMainTerrain, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers);
else
createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers);
@@ -350,7 +350,7 @@ else
createBumps(avoidClasses(clWater, 2, clPlayer, 10));
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tPrimary, tCliff, tPrimary], avoidClasses(clPlayer, 20, clHill, 15, clWater, 0), clHill, scaleByMapSize(1, 4) * numPlayers);
else
createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 0), clHill, scaleByMapSize(1, 4) * numPlayers);
@@ -239,7 +239,7 @@ for (var i = 0; i < numPlayers; ++i)
createBumps(avoidClasses(clWater, 2, clPlayer, 20));
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tMainTerrain, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers);
else
createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers);
@@ -299,7 +299,7 @@ for (var ix = 0; ix < mapSize; ix++)
var forestNoise = (noise6.get(x,z) + 0.5*noise7.get(x,z)) / 1.5 * pn - 0.59;
// Thin out trees a bit
if (forestNoise > 0 && randFloat() < 0.5)
if (forestNoise > 0 && randBool())
{
if (minH < 11 && minH >= 4)
{
@@ -333,14 +333,14 @@ for (var ix = 0; ix < mapSize; ix++)
else if (grassNoise < 0.34)
{
t = (diffH > 1.2) ? tGrassCliff : tGrassDry;
if (diffH < 0.5 && randFloat() < 0.02)
if (diffH < 0.5 && randBool(0.02))
placeObject(ix+randFloat(), iz+randFloat(), aGrassDry, 0, randFloat(0, TWO_PI));
}
else if (grassNoise > 0.61)
{
t = (diffH > 1.2 ? tGrassRock : tGrassShrubs);
}
else if (diffH < 0.5 && randFloat() < 0.02)
else if (diffH < 0.5 && randBool(0.02))
placeObject(ix+randFloat(), iz+randFloat(), aGrass, 0, randFloat(0, TWO_PI));
}
@@ -218,19 +218,14 @@ for (var i = 0; i <= randInt(3, scaleByMapSize(4,6)); i++)
// create tributaries
log("Creating tributaries");
for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++)
for (let i = 0; i <= randIntInclusive(8, scaleByMapSize(12, 20)); ++i)
{
var cLocation = randFloat(0.05,0.95);
var tang = randFloat(PI*0.2, PI*0.8)*((randInt(2)-0.5)*2);
if (tang > 0)
{
var cDistance = 0.05;
}
else
{
var cDistance = -0.05;
}
let cLocation = randFloat(0.05, 0.95);
let sign = randBool() ? 1 : -1;
let tang = sign * PI * randFloat(0.2, 0.8);
let cDistance = sign * 0.05;
var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 5, 0.01);
if (point !== undefined)
{
@@ -187,7 +187,7 @@ RMS.SetProgress(20);
createBumps();
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15), clHill, scaleByMapSize(3, 15));
else
createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15), clHill, scaleByMapSize(3, 15));
@@ -243,7 +243,8 @@ terrainPainter = new LayeredPainter( [pOasisForestLight,tShoreBlend, tWater, tWa
var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -3, 15 );
createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null);
RMS.SetProgress(50);
if(mapSize > 150 && randInt(0,1)) {
if (mapSize > 150 && randBool())
{
log ("creating path through");
var pAngle = randFloat(0, TWO_PI);
var px = round(fx) + round(fractionToTiles(0.13 * cos(pAngle)));
@@ -354,28 +355,30 @@ for (var sandx = 0; sandx < mapSize; sandx += 4)
{
if (getHeight(sandx,sandz) > 3.4)
{
if (Math.random()* 1.4 < getHeight(sandx,sandz) - 3.4)
if (randBool((getHeight(sandx,sandz) - 3.4) / 1.4))
{
group = new SimpleGroup( [new SimpleObject(aSand, 0,1, 0,2)], true, undefined, sandx,sandz );
createObjectGroup(group, 0);
}
} else if (getHeight(sandx,sandz) > -2.5 && getHeight(sandx,sandz) < -1.0)
{
if (Math.random() < 0.4)
if (randBool(0.4))
{
group = new SimpleGroup( [new SimpleObject(aWaterFlower, 1,4, 1,2)], true, undefined, sandx,sandz );
createObjectGroup(group, 0);
} else if (Math.random() > 0.3 && getHeight(sandx,sandz) < -1.9)
}
else if (randBool(0.7) && getHeight(sandx,sandz) < -1.9)
{
group = new SimpleGroup( [new SimpleObject(aReedsA, 5,12, 0,2),new SimpleObject(aReedsB, 5,12, 0,2)], true, undefined, sandx,sandz );
createObjectGroup(group, 0);
}
if (getTileClass(clPassage).countInRadius(sandx,sandz,2,true) > 0) {
if (Math.random() < 0.4)
if (randBool(0.4))
{
group = new SimpleGroup( [new SimpleObject(aWaterFlower, 1,4, 1,2)], true, undefined, sandx,sandz );
createObjectGroup(group, 0);
} else if (Math.random() > 0.3 && getHeight(sandx,sandz) < -1.9)
}
else if (randBool(0.7) && getHeight(sandx,sandz) < -1.9)
{
group = new SimpleGroup( [new SimpleObject(aReedsA, 5,12, 0,2),new SimpleObject(aReedsB, 5,12, 0,2)], true, undefined, sandx,sandz );
createObjectGroup(group, 0);
@@ -1,8 +1,8 @@
RMS.LoadLibrary("rmgen");
const tCity = "desert_city_tile_pers_dirt";
var random_season = randInt(0,1);
if (random_season) //summer
if (randBool()) // summer
{
var tDirtMain = ["desert_dirt_persia_1", "desert_dirt_persia_2", "grass_field_dry"];
var tLakebed1 = ["desert_lakebed_dry_b", "desert_lakebed_dry"];
@@ -27,6 +27,8 @@ else //spring
var tRocks = "desert_plants_a";
var tGrass = "desert_dirt_persia_rocky";
var tHill = "desert_cliff_persia_base";
setTerrainAmbientColor(0.329412, 0.419608, 0.501961);
}
// gaia entities
@@ -426,9 +428,6 @@ for (var i = 0; i < types.length; ++i)
);
}
if (!random_season)
setTerrainAmbientColor(0.329412, 0.419608, 0.501961);
setSunColor(1.0, 0.796, 0.374);
setSunElevation(PI / 6);
setSunRotation(-1.86532);
@@ -321,7 +321,7 @@ createObjectGroups(
);
RMS.SetProgress(95);
if (randInt(0, 2) == 0)
if (randBool(1/3))
{
setSkySet("sunset 1");
setSunColor(0.8, 0.7, 0.6);
@@ -369,7 +369,7 @@ RMS.SetProgress(40);
createBumps(avoidClasses(clWater, 2, clPlayer, 20));
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tMainTerrain, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(3, 15));
else
createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(3, 15));
@@ -110,7 +110,7 @@ function setBiome(biomeIndex)
"water": "medit_sand_wet"
};
if (randInt(2))
if (randBool())
{
g_Terrains.mainTerrain = "alpine_grass";
g_Terrains.forestFloor1 = "temp_forestfloor_pine";
@@ -296,7 +296,8 @@ function setBiome(biomeIndex)
"stoneSmall": "gaia/geology_stone_desert_small",
"metalLarge": "gaia/geology_metal_desert_slabs"
};
if (randInt(2))
if (randBool())
{
g_Gaia.tree1 = "gaia/flora_tree_cretan_date_palm_short";
g_Gaia.tree2 = "gaia/flora_tree_cretan_date_palm_tall";
@@ -307,7 +308,8 @@ function setBiome(biomeIndex)
g_Gaia.tree2 = "gaia/flora_tree_date_palm";
}
g_Gaia.tree3 = "gaia/flora_tree_fig";
if (randInt(2))
if (randBool())
{
g_Gaia.tree4 = "gaia/flora_tree_tamarix";
g_Gaia.tree5 = "gaia/flora_tree_tamarix";
@@ -454,12 +456,12 @@ function setBiome(biomeIndex)
g_Gaia.tree2 = "gaia/flora_tree_medit_fan_palm";
}
if (randInt(2))
if (randBool())
g_Gaia.tree3 = "gaia/flora_tree_apple";
else
g_Gaia.tree3 = "gaia/flora_tree_poplar_lombardy";
if (randInt(2))
if (randBool())
{
g_Gaia.tree4 = "gaia/flora_tree_cypress";
g_Gaia.tree5 = "gaia/flora_tree_cypress";
@@ -470,7 +472,7 @@ function setBiome(biomeIndex)
g_Gaia.tree5 = "gaia/flora_tree_aleppo_pine";
}
if (randInt(2))
if (randBool())
g_Gaia.fruitBush = "gaia/flora_bush_berry";
else
g_Gaia.fruitBush = "gaia/flora_bush_grapes";
@@ -518,7 +518,7 @@ function randomPlayerPlacementAt(singleBases, strongholdBases, heightmapScale, g
let strongholdBasesRandom = shuffleArray(strongholdBases);
let singleBasesRandom = shuffleArray(singleBases);
if (randInt(2) == 1 &&
if (randBool() &&
g_MapInfo.mapSize >= 256 &&
g_MapInfo.teams.length >= 2 &&
g_MapInfo.teams.length < g_MapInfo.numPlayers &&
@@ -432,7 +432,7 @@ for (var x = 0; x < mapSize; x++)
var tDensFactRad = abs((resourceRadius - radius) / resourceRadius);
var tDensActual = (maxTreeDensity * tDensFactSL * tDensFactRad)*0.75;
if (randFloat() < tDensActual && radius < playableMapRadius)
if (randBool(tDensActual) && radius < playableMapRadius)
{
if (tDensActual < bushChance*randFloat()*maxTreeDensity)
{
@@ -219,7 +219,7 @@ createObjectGroups(group, 0,
createBumps([avoidClasses(clWater, 2, clPlayer, 10), stayClasses(clLand, 5)]);
// create hills
if (randInt(1,2) == 1)
if (randBool())
createHills([tMainTerrain, tCliff, tHill], [avoidClasses(clPlayer, 20, clHill, 5, clBaseResource, 3, clWomen, 5), stayClasses(clLand, 5)], clHill, scaleByMapSize(10, 60) * numPlayers);
else
createMountains(tCliff, [avoidClasses(clPlayer, 20, clHill, 5, clBaseResource, 3, clWomen, 5), stayClasses(clLand, 5)], clHill, scaleByMapSize(10, 60) * numPlayers);
@@ -277,7 +277,7 @@ m.DiplomacyManager.prototype.handleDiplomacyRequest = function(gameState, player
let moreEnemiesThanAllies = gameState.getEnemies().length > gameState.getMutualAllies().length;
// For any given diplomacy request be likely to permanently decline
if (!request && gameState.getPlayerCiv() !== gameState.getPlayerCiv(player) && randFloat(0, 1) > 0.4 ||
if (!request && gameState.getPlayerCiv() !== gameState.getPlayerCiv(player) && randBool(0.6) ||
!moreEnemiesThanAllies || gameState.ai.HQ.attackManager.currentEnemyPlayer === player)
{
this.diplomacyRequests.set(player, { "requestType": requestType, "status": "declinedRequest" });
@@ -295,8 +295,8 @@ m.DiplomacyManager.prototype.handleDiplomacyRequest = function(gameState, player
requiredTribute = request;
}
}
else if (requestType === "ally" && gameState.getEntities(player).length < gameState.getOwnEntities().length &&
randFloat(0, 1) > 0.6 || requestType === "neutral" && moreEnemiesThanAllies && randFloat(0, 1) > 0.2)
else if (requestType === "ally" && gameState.getEntities(player).length < gameState.getOwnEntities().length && randBool(0.4) ||
requestType === "neutral" && moreEnemiesThanAllies && randBool(0.8))
{
response = "accept";
this.changePlayerDiplomacy(gameState, player, requestType);