Wrote a world information system and management for them.
Also large amounts of refactoring done. The tests implement the new changes. Island map test clears the cache now.
This commit is contained in:
@@ -2,6 +2,8 @@ package ca.recrown.islandsurvivalcraft.world;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -10,14 +12,13 @@ import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
public class BiomeSelectorTest {
|
||||
BiomeSelector biomeSelector;
|
||||
public class BiomeMapTest {
|
||||
private final Random random = new Random(10320452);
|
||||
BiomeMap biomeSelector;
|
||||
|
||||
@BeforeAll
|
||||
public void setUp() {
|
||||
|
||||
biomeSelector = new BiomeSelector();
|
||||
biomeSelector.initialize();
|
||||
biomeSelector = new BiomeMap(random);
|
||||
}
|
||||
|
||||
@Test
|
@@ -5,22 +5,17 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
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.caching.Cache;
|
||||
import ca.recrown.islandsurvivalcraft.datatypes.Point2;
|
||||
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
public class IslandWorldMapperTest {
|
||||
public final Cache<Point2, Double> blockValCache = new Cache<>(2048);
|
||||
public class IslandWorldMapTest {
|
||||
public final int SEED = 102385923;
|
||||
public Random random = new Random(SEED);
|
||||
public IslandWorldMapper mapper = new IslandWorldMapper(SEED, blockValCache);
|
||||
public IslandWorldMap mapper = new IslandWorldMap(random);
|
||||
public final double[][] answers = new double[2048][2048];
|
||||
|
||||
@BeforeAll
|
||||
@@ -31,17 +26,11 @@ public class IslandWorldMapperTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void individualCleanup() {
|
||||
random.setSeed(SEED);
|
||||
blockValCache.clearCache();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void individualSetUp() {
|
||||
random = new Random(SEED);
|
||||
mapper = new IslandWorldMapper(SEED, blockValCache);
|
||||
mapper = new IslandWorldMap(random);
|
||||
}
|
||||
|
||||
@Test
|
@@ -3,6 +3,7 @@ package ca.recrown.islandsurvivalcraft.world.generation.biomes;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -21,19 +22,19 @@ import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
import ca.recrown.islandsurvivalcraft.Utilities;
|
||||
import ca.recrown.islandsurvivalcraft.caching.Cache;
|
||||
import ca.recrown.islandsurvivalcraft.datatypes.Point2;
|
||||
import ca.recrown.islandsurvivalcraft.world.BiomeSelector;
|
||||
import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper;
|
||||
import ca.recrown.islandsurvivalcraft.world.BiomeMap;
|
||||
import ca.recrown.islandsurvivalcraft.world.IslandWorldMap;
|
||||
import ca.recrown.islandsurvivalcraft.world.TemperatureMap;
|
||||
import ca.recrown.islandsurvivalcraft.world.generation.DummyWorld;
|
||||
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
public class UniBiomeIslandGeneratorTest {
|
||||
public class UniqueBiomeGeneratorTest {
|
||||
private final int SEED = 249398015;
|
||||
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 BiomeSelector biomeSelector = new BiomeSelector();
|
||||
private final BiomeMap biomeSelector = new BiomeMap(new Random(SEED));
|
||||
|
||||
|
||||
private class BiomeGenTask implements Runnable {
|
||||
@@ -54,16 +55,17 @@ public class UniBiomeIslandGeneratorTest {
|
||||
}
|
||||
|
||||
public void generateBiome(int chunkX, int chunkZ) {
|
||||
IslandWorldMapper mapper = new IslandWorldMapper(SEED, blockValueCache);
|
||||
TemperatureMap temperatureMapGenerator = new TemperatureMap(SEED);
|
||||
BiomeGenerator biomeGenerator = new UniBiomeIslandGenerator();
|
||||
Random random = new Random(SEED);
|
||||
IslandWorldMap mapper = new IslandWorldMap(random);
|
||||
TemperatureMap temperatureMapGenerator = new TemperatureMap(random);
|
||||
BiomeGenerator biomeGenerator = new UniqueBiomeGenerator();
|
||||
|
||||
Biome[][][] biomes = new Biome[Utilities.CHUNK_SIZE][Utilities.CHUNK_SIZE][4];
|
||||
for (int localX = 0; localX < Utilities.CHUNK_SIZE; localX++) {
|
||||
for (int localZ = 0; localZ < Utilities.CHUNK_SIZE; localZ++) {
|
||||
if (biomes[localX][localZ] == null) {
|
||||
biomeGenerator.generateBiomeColumn(biomes, dummyWorld, chunkX, chunkZ, localX, localZ, mapper,
|
||||
biomeSelector, temperatureMapGenerator, biomeCache, chunkExistenceCache, SEED);
|
||||
biomeSelector, temperatureMapGenerator, biomeCache, chunkExistenceCache);
|
||||
}
|
||||
if (biomes[localX][localZ] == null)
|
||||
throw new IllegalStateException("Biome was null.");
|
||||
@@ -74,7 +76,6 @@ public class UniBiomeIslandGeneratorTest {
|
||||
|
||||
@BeforeAll
|
||||
public void setup() {
|
||||
biomeSelector.initialize();
|
||||
}
|
||||
|
||||
@BeforeEach
|
Reference in New Issue
Block a user