diff --git a/tilemap/include/generation.h b/tilemap/include/generation.h index 7dab490..e1aa514 100644 --- a/tilemap/include/generation.h +++ b/tilemap/include/generation.h @@ -15,11 +15,11 @@ struct GenerationConfig { Seed seed; // Noise parameters - double temperature_scale = 0.005; // Scale for temperature noise - int temperature_octaves = 3; // Number of octaves for temperature noise + double temperature_scale = 0.05; // Scale for temperature noise + int temperature_octaves = 3; // Number of octaves for temperature noise double temperature_persistence = 0.4; // Persistence for temperature noise - double humidity_scale = 0.005; // Scale for humidity noise + double humidity_scale = 0.05; // Scale for humidity noise int humidity_octaves = 3; // Number of octaves for humidity noise double humidity_persistence = 0.4; // Persistence for humidity noise @@ -35,8 +35,8 @@ private: UniformPerlinNoise base_noise_; // For base terrain generation (uniform distribution) - PerlinNoise temperature_noise_; // For temperature - PerlinNoise humidity_noise_; // For humidity + UniformPerlinNoise temperature_noise_; // For temperature + UniformPerlinNoise humidity_noise_; // For humidity public: /** diff --git a/tilemap/src/biome.cpp b/tilemap/src/biome.cpp index 78199fd..decd3cf 100644 --- a/tilemap/src/biome.cpp +++ b/tilemap/src/biome.cpp @@ -11,11 +11,10 @@ constexpr BiomeProperties biome_properties[] = { // Snowy Peeks (Cold & Dry) { .name = "Snowy Peeks", - .water_ratio = .05, - .ice_ratio = .15, - .sand_ratio = .1, - .land_ratio = .2, + .ice_ratio = .2, + .sand_ratio = .05, + .land_ratio = .3, }, // Snowy Plains (Cold & Moderate) { @@ -28,42 +27,42 @@ constexpr BiomeProperties biome_properties[] = { // Frozen Ocean (Cold & Wet) { .name = "Frozen Ocean", - .water_ratio = .3, - .ice_ratio = .4, + .water_ratio = .1, + .ice_ratio = .7, .sand_ratio = .25, .land_ratio = .05, }, // Plains (Temperate & Dry) { .name = "Plains", - .water_ratio = .1, + .water_ratio = .05, .ice_ratio = .0, .sand_ratio = .05, - .land_ratio = .65, + .land_ratio = .7, }, // Forest (Temperate & Moderate) { .name = "Forest", - .water_ratio = .2, + .water_ratio = .1, .ice_ratio = .0, - .sand_ratio = .1, - .land_ratio = .5, + .sand_ratio = .05, + .land_ratio = .75, }, // Ocean (Temperate & Wet) { .name = "Ocean", - .water_ratio = .7, + .water_ratio = .8, .ice_ratio = .0, - .sand_ratio = .2, - .land_ratio = .1, + .sand_ratio = .15, + .land_ratio = .05, }, // Desert (Hot & Dry) { .name = "Desert", .water_ratio = .0, .ice_ratio = .0, - .sand_ratio = .75, - .land_ratio = .05, + .sand_ratio = .8, + .land_ratio = .0, }, // Savanna (Hot & Moderate) { @@ -78,8 +77,8 @@ constexpr BiomeProperties biome_properties[] = { .name = "Luke Ocean", .water_ratio = .8, .ice_ratio = .0, - .sand_ratio = .2, - .land_ratio = .0, + .sand_ratio = .05, + .land_ratio = .15, }, }; @@ -92,8 +91,8 @@ BiomeType determine_biome(double temperature, double humidity) { temperature = std::clamp(temperature, 0.0, 1.0); humidity = std::clamp(humidity, 0.0, 1.0); - const double threshold1 = 0.4; - const double threshold2 = 0.6; + const double threshold1 = 0.33; + const double threshold2 = 0.67; BiomeTemperature temp_category; if (temperature < threshold1) { diff --git a/tilemap/src/generation.cpp b/tilemap/src/generation.cpp index d9fd6dc..8636685 100644 --- a/tilemap/src/generation.cpp +++ b/tilemap/src/generation.cpp @@ -11,15 +11,23 @@ TerrainGenerator::TerrainGenerator(const GenerationConfig &config) Xoroshiro128PP rng{config.seed}; base_noise_ = UniformPerlinNoise(rng); rng = rng.jump_96(); - temperature_noise_ = PerlinNoise(rng); + temperature_noise_ = UniformPerlinNoise(rng); rng = rng.jump_96(); - humidity_noise_ = PerlinNoise(rng); + humidity_noise_ = UniformPerlinNoise(rng); - // Calibrate the uniform base noise with the same parameters that will be - // used for generation base_noise_.calibrate( config.base_scale, config.base_octaves, config.base_persistence ); + + temperature_noise_.calibrate( + config.temperature_scale, config.temperature_octaves, + config.temperature_persistence + ); + + humidity_noise_.calibrate( + config.humidity_scale, config.humidity_octaves, + config.humidity_persistence + ); } void TerrainGenerator::generate_map(TileMap &tilemap) { @@ -126,16 +134,14 @@ std::pair TerrainGenerator::get_climate( double global_x, double global_y ) const { // Generate temperature noise (0-1 range) - double temperature = temperature_noise_.octave_noise( + double temperature = temperature_noise_.uniform_noise( global_x * config_.temperature_scale, - global_y * config_.temperature_scale, config_.temperature_octaves, - config_.temperature_persistence + global_y * config_.temperature_scale ); // Generate humidity noise (0-1 range) - double humidity = humidity_noise_.octave_noise( - global_x * config_.humidity_scale, global_y * config_.humidity_scale, - config_.humidity_octaves, config_.humidity_persistence + double humidity = humidity_noise_.uniform_noise( + global_x * config_.humidity_scale, global_y * config_.humidity_scale ); return {temperature, humidity};