Ursache: der Laeufer gibt ergebnis.haende nur den Logschwanz (TAIL); die roomProperties (gameType) kommen nur einmal mit game_alldata beim Beitritt. Sitzt ein Tisch laenger, faellt die Zeile heraus -> format null (2861 von 3088 Haenden in archiv/lauf/haende.jsonl). - runner._format_ergaenzen: Format je Raum merken, sonst aus der Tischlage des Sitzers; auch die Schattenzeile fuehrt jetzt format. - lesen/ergebnis._format verfeinert wie hand/sitzen (cash_plo bei Omaha-Ring). - statistik.format_von: alte Zeilen ohne Format = Cash NLH nur bei Echtgeld-Tisch (BB unter 1) und Holdem; sonst bleibt "unbekannt". Genutzt in statistik.je_format und sicht/ansicht._haende. Spec tests/format_ableitung_spec.py (12, mit echten Haenden aus archiv/mitschrieb). Live-Daten: Cash-Modus 2671 unbekannt -> 2687 Cash NLH. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
132 lines
6.1 KiB
Python
132 lines
6.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Spezifikation: das Format jeder gespeicherten Hand (betrieb/runner._format_ergaenzen,
|
|
betrieb/statistik.format_von, lesen/ergebnis._format).
|
|
|
|
14.11.: die Statistik zeigte 2671 Haende als Format "unbekannt" - in archiv/lauf/haende.jsonl stand
|
|
bei 2861 von 3088 Haenden `"format": null`. Ursache: der Laeufer gibt `ergebnis.haende` nur den
|
|
Logschwanz (TAIL); die roomProperties (gameType) kommen aber nur einmal mit game_alldata beim
|
|
Beitritt. Sitzt ein Tisch laenger, faellt die Zeile aus dem Schwanz und der Leser kennt das Format
|
|
nicht mehr. Jetzt (1) merkt sich der Laeufer das Format je Raum und nimmt sonst die Tischlage des
|
|
Sitzers, (2) beim Lesen wird eine alte Zeile nur dort abgeleitet, wo es sicher ist: Echtgeld-Tisch
|
|
(BB unter 1) mit Holdem = Cash NLH.
|
|
|
|
python3 tests/format_ableitung_spec.py -v
|
|
"""
|
|
import os
|
|
import sys
|
|
import types
|
|
import unittest
|
|
|
|
_w = os.path.dirname(os.path.abspath(__file__))
|
|
while _w != "/" and not os.path.isdir(os.path.join(_w, "lesen")):
|
|
_w = os.path.dirname(_w)
|
|
for _u in ("tests", "betrieb", "lesen", "sicht"):
|
|
_p = os.path.join(_w, _u)
|
|
if _p not in sys.path:
|
|
sys.path.insert(0, _p)
|
|
import ergebnis # noqa: E402
|
|
import ergebnis_spec as E # noqa: E402 (Schnitte echter Haende aus archiv/mitschrieb)
|
|
import formate # noqa: E402
|
|
import runner # noqa: E402
|
|
import statistik # noqa: E402
|
|
|
|
|
|
def setUpModule():
|
|
E.setUpModule()
|
|
|
|
|
|
def ohne_alldata(text):
|
|
"""Der Logschwanz eines laenger sitzenden Tisches: die Hand ist da, game_alldata nicht mehr."""
|
|
return "\n".join(z for z in text.split("\n") if "game.game_alldata" not in z) + "\n"
|
|
|
|
|
|
class Ursache(unittest.TestCase):
|
|
"""Echte Hand C (Big Ben, Ring): mit game_alldata kennt der Leser das Format, ohne nicht."""
|
|
|
|
def test_mit_alldata_cash(self):
|
|
raum, hand = E.HAENDE["C"]
|
|
h = [x for x in ergebnis.haende_aller(E.schnitt("C")) if x["hand"] == hand]
|
|
self.assertTrue(h)
|
|
self.assertEqual({x["format"] for x in h}, {formate.CASH})
|
|
|
|
def test_ohne_alldata_none(self):
|
|
raum, hand = E.HAENDE["C"]
|
|
alle = ergebnis.haende_aller(ohne_alldata(E.schnitt("C")))
|
|
h = [x for x in alle if x["hand"] == hand]
|
|
self.assertTrue(h)
|
|
self.assertTrue(all(x["format"] is None for x in h)) # genau das stand in haende.jsonl
|
|
|
|
def test_bombpot_bleibt_bombpot(self):
|
|
"""Hand G (14R PLO mit Bomb Pots): das Tischformat schlaegt die Spielart."""
|
|
raum, hand = E.HAENDE["G"]
|
|
h = [x for x in ergebnis.haende_aller(E.schnitt("G")) if x["hand"] == hand]
|
|
self.assertTrue(h)
|
|
self.assertEqual({x["format"] for x in h}, {formate.BOMBPOT})
|
|
|
|
def test_plo_ring_wie_die_tischlage(self):
|
|
"""Ein Omaha-Ring: der Leser verfeinert wie hand/sitzen -> cash_plo, nicht cash (sonst stuende
|
|
derselbe Tisch je nach Quelle einmal so, einmal so im Bestand)."""
|
|
t = ergebnis.S.Tisch("R")
|
|
t.merke_raum({"gameType": "Ring", "miniGameTypeId": 2})
|
|
if t.format() != formate.CASH:
|
|
self.skipTest("gameType-Wert fuer Ring weicht ab")
|
|
self.assertEqual(ergebnis._format(t), formate.CASH_PLO)
|
|
t2 = ergebnis.S.Tisch("H")
|
|
t2.merke_raum({"gameType": "Ring", "miniGameTypeId": 1})
|
|
self.assertEqual(ergebnis._format(t2), formate.CASH)
|
|
|
|
|
|
class Laeufer(unittest.TestCase):
|
|
def setUp(self):
|
|
runner.FORMAT_JE_RAUM.clear()
|
|
|
|
def test_merkt_das_format_je_raum(self):
|
|
runner._format_ergaenzen({"raum": "R1", "format": "cash"})
|
|
self.assertEqual(runner._format_ergaenzen({"raum": "R1", "format": None})["format"], "cash")
|
|
|
|
def test_tischlage_des_sitzers(self):
|
|
sitzer = types.SimpleNamespace(lagen={"R2": types.SimpleNamespace(format="aof")})
|
|
self.assertEqual(runner._format_ergaenzen({"raum": "R2", "format": None}, sitzer)["format"], "aof")
|
|
|
|
def test_echte_hand_ohne_alldata_bekommt_ihr_format(self):
|
|
raum, hand = E.HAENDE["C"]
|
|
runner._format_ergaenzen(ergebnis.haende_aller(E.schnitt("C"))[0]) # erste Lesung mit alldata
|
|
spaeter = [x for x in ergebnis.haende_aller(ohne_alldata(E.schnitt("C"))) if x["hand"] == hand][0]
|
|
self.assertEqual(runner._format_ergaenzen(spaeter)["format"], formate.CASH)
|
|
|
|
def test_ohne_wissen_bleibt_es_offen(self):
|
|
self.assertIsNone(runner._format_ergaenzen({"raum": "R3", "format": None}, None)["format"])
|
|
|
|
|
|
class AlteZeilen(unittest.TestCase):
|
|
"""Beim Lesen: nur Echtgeld + Holdem wird Cash NLH; alles andere bleibt unbekannt."""
|
|
|
|
def test_echtgeld_holdem_ist_cash_nlh(self):
|
|
h = {"format": None, "raum": "14R NL 0.01-0.02 EV-INRIT-(A) 1776792", "spielart": "NLHE",
|
|
"stake": "0.01/0.02", "bb": 0.02}
|
|
self.assertEqual(statistik.format_von(h), formate.CASH)
|
|
self.assertEqual(formate.NAMEN[statistik.format_von(h)], "Cash NLH")
|
|
|
|
def test_uebung_plo_und_gesetztes_bleiben(self):
|
|
self.assertIsNone(statistik.format_von({"format": None, "spielart": "NLHE", "bb": 2000})) # Uebung
|
|
self.assertIsNone(statistik.format_von({"format": None, "spielart": "PLO4", "bb": 0.05})) # Omaha
|
|
self.assertIsNone(statistik.format_von({"format": None, "spielart": "NLHE"})) # ohne BB
|
|
self.assertEqual(statistik.format_von({"format": "aof", "spielart": "NLHE", "bb": 0.02}), "aof")
|
|
|
|
def test_je_format_zaehlt_sie_als_cash(self):
|
|
alt = {"format": None, "spielart": "NLHE", "bb": 0.02, "netto": -0.04}
|
|
neu = {"format": "cash", "spielart": "NLHE", "bb": 0.02, "netto": 0.1}
|
|
g = statistik.je_format([alt, neu, dict(alt, bb=2000, netto=-4000)])
|
|
self.assertEqual({x["format"]: x["haende"] for x in g}, {"cash": 2, statistik.UNBEKANNT: 1})
|
|
|
|
def test_cockpit_sieht_cash_nlh(self):
|
|
import ansicht
|
|
q = {"haende": [{"zeit": "2026-11-14 19:00:00", "raum": "14R NL 0.01-0.02 (A) 1", "hand": "1",
|
|
"netto": -0.04, "bb": 0.02, "spielart": "NLHE", "stake": "0.01/0.02",
|
|
"format": None, "spieler": None}]}
|
|
self.assertEqual([h["format"] for h in ansicht._haende(q)], [formate.CASH])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|