So, I’m making a planet generator. It builds it’s continents with perlin noise, and then I run an algorithm I wrote to map out global temperatures based on some photos I viewed of earth’s average global temperatures.
So other than that algorithm being pretty bad most of the time, I’ve got another problem that’s coming from Java’s threads.
At the end of the standard generation I listed above, I must begin landmark and organism generation and placement. This proved to be very CPU extensive, so I thought it’d be a good idea to make a thread for it instead of trying to execute it all in one step to keep the program from freezing up.
So, essentially, it moves across the map, generating a local map for every tile on a 128x128 map. Each local map is 32x32 tiles. Not too bad, right?
Anyway, it runs, and then around at a y pf 55-59 it stops completely, as in it just stops looping. No errors fire, no exceptions, no crashes, the game runs fine. What this does however, is keep the generator from progressing, which is the problem. Honestly, I have no idea what’s going on, I’ve never had this problem with a thread before.
Here’s the code, not that this is the “alpha” code, and has yet to be cleaned up for max efficiency (don’t laugh!):
Thread threadGenerator = new Thread(){
public void run(){
//Local Maps
for (int x = 0; x < planetSize; x++){
for (int y = 0; y < planetSize; y++){
System.out.println(x+"/"+y);
if (map[x][y][0] != TILE_WATER && map[x][y][0] != TILE_RIVER && map[x][y][0] != TILE_MOUNTAIN){
if (map[x][y][1] > 55){
if (r.nextInt(2000) < 10){
map[x][y][0] = TILE_TOWN;
landmarks++;
}else if (r.nextInt(5000) < 10){
map[x][y][0] = TILE_TOWN_RUINS;
landmarks++;
}
}
if (r.nextInt(1500) < 20){
map[x][y][0] = TILE_CAVE;
landmarks++;
}
}
localMaps[x][y] = new LocalMap(map[x][y][1], map[x][y][0]);
localMaps[x][y].generateObjects(r, organisms);
population+=localMaps[x][y].getLocalPopulation();
if (population > maxPopulation && limitPopulation){
localMaps[x][y].clearPopulation();
population = maxPopulation;
}
}
}
};
Any ideas? I’m dumbfounded.