add predictions page with game theory analysis and card stats

Bayesian next-chair predictor (Markov chains, base rate, streak regression),
statistical tests (chi-squared, runs test, autocorrelation), theory
backtesting with rolling accuracy, and card-level analysis (value/suit
distribution, face card frequency, top winning cards).
This commit is contained in:
2026-02-25 23:16:37 +05:00
parent d8ec792a88
commit b07b073cc0
6 changed files with 1003 additions and 0 deletions

View File

@@ -43,6 +43,8 @@ class WebServer:
self.app.router.add_get("/api/analytics", self._handle_analytics)
self.app.router.add_get("/patterns", self._handle_patterns_page)
self.app.router.add_get("/api/patterns", self._handle_patterns)
self.app.router.add_get("/predictions", self._handle_predictions_page)
self.app.router.add_get("/api/predictions", self._handle_predictions)
self.app.router.add_get("/ws", self._handle_ws)
self.app.router.add_static("/static/", STATIC_DIR, name="static")
@@ -104,6 +106,18 @@ class WebServer:
log.error("Pattern analysis query failed: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def _handle_predictions_page(self, request: web.Request) -> web.Response:
path = os.path.join(STATIC_DIR, "predictions.html")
return web.FileResponse(path)
async def _handle_predictions(self, request: web.Request) -> web.Response:
try:
data = await _run_sync(db.get_prediction_analysis)
return web.json_response(data)
except Exception as e:
log.error("Prediction analysis query failed: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def _handle_analytics(self, request: web.Request) -> web.Response:
period = request.query.get("period", "all")
if period not in ("1h", "6h", "24h", "7d", "all"):