feat: 노을 공기 보정을 평소 공기 기준점 중심으로 바꿔 맑은 날 점수가 한 점에 몰리지 않게

This commit is contained in:
skkim committed 2026-10-08 11:59:08 +09:00
1 parent 91a86a2c10
commit 3857ef8d14
4 files changed
+24 -14

No files matched your search

+16 -7
View File
@@ -36,19 +36,28 @@ def score(near20: Layers, far100: Layers) -> int:
return round(100 * (0.75 * f_canvas + 0.25 * f_near) * (0.25 + 0.75 * light))
def _ramp(v: float, bad: float, good: float, low: float) -> float:
"""good 쪽은 1.0, bad 쪽은 low, 사이는 직선."""
t = max(0.0, min(1.0, (v - bad) / (good - bad)))
return low + (1 - low) * t
# 공기 보정 기준점 (값, 배수). 평소 공기(가시거리 20km, 습도 60%)가 ×1.0 이고 좋으면 올리고 나쁘면 내린다. 양 끝 밖은 끝 값 그대로.
_VISIBILITY_FACTOR = ((5, 0.8), (20, 1.0), (40, 1.12))
_HUMIDITY_FACTOR = ((40, 1.06), (60, 1.0), (90, 0.85))
def _interp(v: float, points: tuple[tuple[float, float], ...]) -> float:
"""기준점 사이를 직선으로 잇는다."""
if v <= points[0][0]:
return points[0][1]
for (x0, f0), (x1, f1) in zip(points, points[1:]):
if v <= x1:
return f0 + (f1 - f0) * (v - x0) / (x1 - x0)
return points[-1][1]
def air_factor(air: Air) -> float:
"""공기로 구름 점수를 보정하는 배수. 뿌연 공기·높은 습도는 색을 흐리게 하고, 비 갠 뒤는 더 붉다."""
"""공기로 구름 점수를 보정하는 배수. 맑고 건조하면 올리고 뿌옇거나 습하면 내린다. 비 갠 뒤는 더 붉다."""
f = 1.0
if air.visibility_km is not None:
f *= _ramp(air.visibility_km, 5, 20, 0.8)
f *= _interp(air.visibility_km, _VISIBILITY_FACTOR)
if air.humidity is not None:
f *= _ramp(air.humidity, 90, 70, 0.85)
f *= _interp(air.humidity, _HUMIDITY_FACTOR)
if air.rain_before is not None and air.rain_before >= 60 and (air.rain_now or 0) < 40:
f *= 1.15
return f