Implemented concept of island origin coords.
Useful for hashing an island potentially.
This commit is contained in:
@@ -6,17 +6,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2;
|
||||
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
public class IslandWorldMapTest {
|
||||
public final int SEED = 102385923;
|
||||
public final int GRIDSIZE = 2048;
|
||||
public Random random = new Random(SEED);
|
||||
public IslandWorldMap mapper = new IslandWorldMap(random);
|
||||
public final double[][] answers = new double[2048][2048];
|
||||
public final double[][] answers = new double[GRIDSIZE][GRIDSIZE];
|
||||
|
||||
@BeforeAll
|
||||
public void setUp() {
|
||||
@@ -27,12 +29,6 @@ public class IslandWorldMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void individualSetUp() {
|
||||
random = new Random(SEED);
|
||||
mapper = new IslandWorldMap(random);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockValueConsistency() {
|
||||
for (int x = 0; x < answers.length; x++) {
|
||||
@@ -44,7 +40,7 @@ public class IslandWorldMapTest {
|
||||
|
||||
@Test
|
||||
public void testBlockValueConsistencyRandom() {
|
||||
for (int amount = 0; amount < 1024; amount++) {
|
||||
for (int amount = 0; amount < GRIDSIZE; amount++) {
|
||||
int x = random.nextInt(answers.length);
|
||||
int y = random.nextInt(answers[x].length);
|
||||
assertEquals(answers[x][y], mapper.getWorldValue(x, y), String.format("Occurred at (%d, %d)", x, y));
|
||||
@@ -52,13 +48,47 @@ public class IslandWorldMapTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2048ValuesValidity() {
|
||||
public void testValuesValidity() {
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
int x = random.nextInt();
|
||||
int y = random.nextInt();
|
||||
assertTrue((mapper.getWorldValue(x, y) <= 1));
|
||||
assertTrue((mapper.getWorldValue(x, y) >= -1));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIslandOriginConsistency() {
|
||||
Point2 origin = null;
|
||||
for (int i = 0; i < GRIDSIZE; i++) {
|
||||
if (origin != null) {
|
||||
if (mapper.isSameIsland(origin.x, origin.y, i, 0)) {
|
||||
assertEquals(origin, mapper.findIslandOrigin(i, 0), String.format("Looking at (%d, 0)", i));
|
||||
} else {
|
||||
origin = null;
|
||||
}
|
||||
} else if (mapper.isIsland(i, 0)) {
|
||||
origin = mapper.findIslandOrigin(i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIslandOriginConsistency2D() {
|
||||
int gridSize = 32;
|
||||
Point2 origin = null;
|
||||
for (int y = 0; y < gridSize; y++) {
|
||||
for (int x = 0; x < gridSize; x++) {
|
||||
if (origin != null) {
|
||||
if (mapper.isSameIsland(origin.x, origin.y, x, y)) {
|
||||
assertEquals(origin, mapper.findIslandOrigin(x, y), String.format("Looking at (%d, %d)", x, y));
|
||||
} else {
|
||||
origin = null;
|
||||
}
|
||||
} else if (mapper.isIsland(x, y)) {
|
||||
origin = mapper.findIslandOrigin(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -33,7 +33,6 @@ public class UniqueBiomeGeneratorTest {
|
||||
private final DummyWorld dummyWorld = new DummyWorld();
|
||||
private volatile Cache<Point2, Double> blockValueCache;
|
||||
private volatile Cache<Point2, Biome[]> biomeCache;
|
||||
private volatile Cache<Point2, Boolean> chunkExistenceCache;
|
||||
private final BiomeMap biomeSelector = new BiomeMap(new Random(SEED));
|
||||
|
||||
|
||||
@@ -65,7 +64,7 @@ public class UniqueBiomeGeneratorTest {
|
||||
for (int localZ = 0; localZ < GeneralUtilities.CHUNK_SIZE; localZ++) {
|
||||
if (biomes[localX][localZ] == null) {
|
||||
biomeGenerator.generateBiomeColumn(biomes, dummyWorld, chunkX, chunkZ, localX, localZ, mapper,
|
||||
biomeSelector, temperatureMapGenerator, biomeCache, chunkExistenceCache);
|
||||
biomeSelector, temperatureMapGenerator, biomeCache);
|
||||
}
|
||||
if (biomes[localX][localZ] == null)
|
||||
throw new IllegalStateException("Biome was null.");
|
||||
@@ -82,14 +81,12 @@ public class UniqueBiomeGeneratorTest {
|
||||
public void individualSetup() {
|
||||
blockValueCache = new Cache<>(524288);
|
||||
biomeCache = new Cache<>(524288);
|
||||
chunkExistenceCache = new Cache<>(16384);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void individualCleanup() {
|
||||
blockValueCache.clearCache();
|
||||
biomeCache.clearCache();
|
||||
chunkExistenceCache.clearCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,7 +124,6 @@ public class UniqueBiomeGeneratorTest {
|
||||
public void testBiomeGenerationMultithread1608ChunksSmallCache() {
|
||||
this.blockValueCache = new Cache<>(1024);
|
||||
this.biomeCache = new Cache<>(1024);
|
||||
this.chunkExistenceCache = new Cache<>(1024);
|
||||
|
||||
int chunksToDoEach = 268;
|
||||
Runnable g1 = new BiomeGenTask(chunksToDoEach, 0);
|
||||
@@ -198,7 +194,6 @@ public class UniqueBiomeGeneratorTest {
|
||||
public void testBiomeGenerationMultithread1608ChunksScatteredColumnsSmallCache() {
|
||||
this.blockValueCache = new Cache<>(1024);
|
||||
this.biomeCache = new Cache<>(1024);
|
||||
this.chunkExistenceCache = new Cache<>(1024);
|
||||
int chunksToDoEach = 268;
|
||||
Runnable g1 = new BiomeGenTask(chunksToDoEach, 0);
|
||||
Runnable g2 = new BiomeGenTask(chunksToDoEach, 2);
|
||||
@@ -261,7 +256,6 @@ public class UniqueBiomeGeneratorTest {
|
||||
public void testBiomeGenerationMultithread6000ChunksScatteredColumnsSmallCache() {
|
||||
this.blockValueCache = new Cache<>(1024);
|
||||
this.biomeCache = new Cache<>(1024);
|
||||
this.chunkExistenceCache = new Cache<>(1024);
|
||||
|
||||
int chunksToDoEach = 1000;
|
||||
Runnable g1 = new BiomeGenTask(chunksToDoEach, 0);
|
||||
|
Reference in New Issue
Block a user