Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -8,6 +8,7 @@ import chess
|
|
| 8 |
import chess.engine
|
| 9 |
import asyncio
|
| 10 |
import json
|
|
|
|
| 11 |
|
| 12 |
@asynccontextmanager
|
| 13 |
async def lifespan(app: FastAPI):
|
|
@@ -18,7 +19,6 @@ async def lifespan(app: FastAPI):
|
|
| 18 |
await pool.stop()
|
| 19 |
|
| 20 |
app = FastAPI(title="Deepcastle Engine API", lifespan=lifespan)
|
| 21 |
-
from contextlib import asynccontextmanager
|
| 22 |
|
| 23 |
# βββ Multiplaying / Challenge Manager ββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
class ConnectionManager:
|
|
@@ -514,8 +514,9 @@ async def analyze_game(request: AnalyzeRequest):
|
|
| 514 |
accuracy = 0.0
|
| 515 |
|
| 516 |
# Elo from avg CPL using exponential decay calibrated to your 3600 engine
|
|
|
|
| 517 |
avg_cpl = sum(player_cpls) / max(1, len(player_cpls))
|
| 518 |
-
estimated_elo = int(max(400, min(3600, round(3600 * math.exp(-0.
|
| 519 |
|
| 520 |
return AnalyzeResponse(
|
| 521 |
accuracy=round(accuracy, 1),
|
|
|
|
| 8 |
import chess.engine
|
| 9 |
import asyncio
|
| 10 |
import json
|
| 11 |
+
from contextlib import asynccontextmanager
|
| 12 |
|
| 13 |
@asynccontextmanager
|
| 14 |
async def lifespan(app: FastAPI):
|
|
|
|
| 19 |
await pool.stop()
|
| 20 |
|
| 21 |
app = FastAPI(title="Deepcastle Engine API", lifespan=lifespan)
|
|
|
|
| 22 |
|
| 23 |
# βββ Multiplaying / Challenge Manager ββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
class ConnectionManager:
|
|
|
|
| 514 |
accuracy = 0.0
|
| 515 |
|
| 516 |
# Elo from avg CPL using exponential decay calibrated to your 3600 engine
|
| 517 |
+
# Toughened constant from -0.01 to -0.015 for more realistic scoring
|
| 518 |
avg_cpl = sum(player_cpls) / max(1, len(player_cpls))
|
| 519 |
+
estimated_elo = int(max(400, min(3600, round(3600 * math.exp(-0.015 * avg_cpl)))))
|
| 520 |
|
| 521 |
return AnalyzeResponse(
|
| 522 |
accuracy=round(accuracy, 1),
|