refactor: Replace hardcoded thresholds with constants in biome determination
Signed-off-by: szdytom <szdytom@qq.com>
This commit is contained in:
parent
6be8869568
commit
849b7b2ed9
@ -92,19 +92,22 @@ BiomeType determine_biome(double temperature, double humidity) {
|
|||||||
temperature = std::clamp(temperature, 0.0, 1.0);
|
temperature = std::clamp(temperature, 0.0, 1.0);
|
||||||
humidity = std::clamp(humidity, 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;
|
BiomeTemperature temp_category;
|
||||||
if (temperature < 0.33) {
|
if (temperature < threshold1) {
|
||||||
temp_category = BiomeTemperature::Cold;
|
temp_category = BiomeTemperature::Cold;
|
||||||
} else if (temperature < 0.66) {
|
} else if (temperature < threshold2) {
|
||||||
temp_category = BiomeTemperature::Temperate;
|
temp_category = BiomeTemperature::Temperate;
|
||||||
} else {
|
} else {
|
||||||
temp_category = BiomeTemperature::Hot;
|
temp_category = BiomeTemperature::Hot;
|
||||||
}
|
}
|
||||||
|
|
||||||
BiomeHumidity humidity_category;
|
BiomeHumidity humidity_category;
|
||||||
if (humidity < 0.33) {
|
if (humidity < threshold1) {
|
||||||
humidity_category = BiomeHumidity::Dry;
|
humidity_category = BiomeHumidity::Dry;
|
||||||
} else if (humidity < 0.66) {
|
} else if (humidity < threshold2) {
|
||||||
humidity_category = BiomeHumidity::Moderate;
|
humidity_category = BiomeHumidity::Moderate;
|
||||||
} else {
|
} else {
|
||||||
humidity_category = BiomeHumidity::Wet;
|
humidity_category = BiomeHumidity::Wet;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user