Spaces:
Sleeping
Sleeping
Update main.py
Browse files124 unmodified lines125126127128129130131132460 unmodified lines593594595596597598599600601308 unmodified lines910911912913914915916917918124 unmodified linesdef _engine_hash_mb() -> int:try:# Default kept conservative to prevent hash table blowups on small VMs.v = int(os.environ.get("ENGINE_HASH_MB", "32"))except ValueError:v = 128return max(8, min(512, v))460 unmodified linesdel resultdel info# FIX: Clear hash + force memory back to OS after hintasync with _ENGINE_IO_LOCK:await _clear_engine_hash(engine)force_memory_release()return MoveResponse(308 unmodified linesaccuracy = max(10.0, min(100.0, 100.0 * math.exp(-0.005 * avg_cpl)))estimated_elo = int(max(400, min(3600, round(3600 * math.exp(-0.015 * avg_cpl)))))# FIX: Clear engine hash + force memory back to OS after full game analysisasync with _ENGINE_IO_LOCK:await _clear_engine_hash(engine)force_memory_release()return AnalyzeResponse(124 unmodified lines125126127128129130131132460 unmodified lines593594595596597598599600601602603604308 unmodified lines913914915916917918919920921922923924124 unmodified linesdef _engine_hash_mb() -> int:try:# Default used for transposition table size testing.v = int(os.environ.get("ENGINE_HASH_MB", "512"))except ValueError:v = 128return max(8, min(512, v))460 unmodified linesdel resultdel info# FIX: clear/restart engine to keep memory stable after hintasync with _ENGINE_IO_LOCK:if _RESTART_ENGINE_AFTER_MOVE:await _detach_and_quit_engine(engine)elif _CLEAR_HASH_AFTER_MOVE:await _clear_engine_hash(engine)force_memory_release()return MoveResponse(308 unmodified linesaccuracy = max(10.0, min(100.0, 100.0 * math.exp(-0.005 * avg_cpl)))estimated_elo = int(max(400, min(3600, round(3600 * math.exp(-0.015 * avg_cpl)))))# FIX: Clear/restart engine to keep memory stable after full game analysisasync with _ENGINE_IO_LOCK:if _RESTART_ENGINE_AFTER_MOVE:await _detach_and_quit_engine(engine)elif _CLEAR_HASH_AFTER_MOVE:await _clear_engine_hash(engine)force_memory_release()return AnalyzeResponse(
main.py+12-6