From 849b7b2ed93b63f0c8a6e492af950a395b0a7094 Mon Sep 17 00:00:00 2001 From: szdytom Date: Fri, 1 Aug 2025 21:41:15 +0800 Subject: [PATCH] refactor: Replace hardcoded thresholds with constants in biome determination Signed-off-by: szdytom --- tilemap/src/biome.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tilemap/src/biome.cpp b/tilemap/src/biome.cpp index 13e5d27..809098d 100644 --- a/tilemap/src/biome.cpp +++ b/tilemap/src/biome.cpp @@ -92,19 +92,22 @@ 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; + BiomeTemperature temp_category; - if (temperature < 0.33) { + if (temperature < threshold1) { temp_category = BiomeTemperature::Cold; - } else if (temperature < 0.66) { + } else if (temperature < threshold2) { temp_category = BiomeTemperature::Temperate; } else { temp_category = BiomeTemperature::Hot; } BiomeHumidity humidity_category; - if (humidity < 0.33) { + if (humidity < threshold1) { humidity_category = BiomeHumidity::Dry; - } else if (humidity < 0.66) { + } else if (humidity < threshold2) { humidity_category = BiomeHumidity::Moderate; } else { humidity_category = BiomeHumidity::Wet;