调整衰减函数
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
2025-10-24 01:59:41 +08:00
parent 021133954e
commit afda0680ec

View File

@ -1,10 +1,17 @@
import base64
import math
import random
import time
from pathlib import Path
def dec_func(t: float) -> float:
if t < 86400:
return 0.5 * (1 + math.tanh(t / 43200 - 1))
return math.exp(-0.00000043 * (t - 86400))
class RandomTextManager:
_cache: list[tuple[float, str]]
@ -55,7 +62,8 @@ class RandomTextManager:
for ts, cn in self._cache:
contents.append(cn)
weights.append((abs(now - ts) + 0.01) ** (-1))
# weights.append((abs(now - ts) + 0.01) ** (-1))
weights.append(dec_func(now - ts))
return random.choices(contents, weights)[0]