refactor: Replace hardcoded thresholds with constants in biome determination

Signed-off-by: szdytom <szdytom@qq.com>
This commit is contained in:
方而静 2025-08-01 21:41:15 +08:00
parent 6be8869568
commit 849b7b2ed9
Signed by: szTom
GPG Key ID: 072D999D60C6473C

View File

@ -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;