Guys I’m getting this really weird fault with my program when I run it. This is the important code:
variables (edit):
const short int maxX = 100;
const short int maxZ = 100;
const short int lakeChance = 0.9;
addLake function (edit):
void addLake(Sect sector[][maxZ], int x, int z){
sector[x][z].setMaterial(1);
}
main source (edit):
//Generating land mass
for (int x = 0; x < maxX; x++){
for (int z = 0; z < maxZ; z++){
//Default material
sector[x][z].setMaterial(0);
//Add lake/sea source
int r = rand();
float r1 = (r % 1000);
float r2 = r1 / 1000;
if (r2 <= lakeChance) addLake(sector, x, z);
}
}
The fault is, that whatever I change the ‘lakeChance’ value to, the result seems to be exactly the same. As in the addLake function seems to be called about 3 to 6 times every launch despite me changing the value of lakeChance higher (i.e.: 0.5, 0.7, 0.9). The function is only called all the time when I change the value of ‘lakeChance’ to 1. The random number generator works fine btw so the result are somewhat varying every time.
I see nothing obviously wrong per se. So I tried the following bit of code:
Predictably, I got these results:
How many lakes are you trying to add?