The user wants to choose what the bot plays (several formats at once) and learn which works best. Each table now knows its format from roomProperties (lesen/formate.py: cash, aof, bombpot, turnier, kpoker), every hand records it, and the stats compare formats with a 95 % span; a "best" verdict only when one span lies above all others. The plan holds tables per format; the runner fills per format and never sits at an unchosen one. Lobby tabs other than Cash/Practice are unmeasured, so those formats are selectable but the runner says why it opens nothing. All-In or Fold hands now count as AOF in the stats (they were dropped); the runner still abstains there until the AoF buttons are measured - spielart_spec's exact reason text is updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
189 lines
7.9 KiB
Python
189 lines
7.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Spezifikation: Format je Tisch, je Hand und der Vergleich je Format (plans/2026-10-30_formate.md).
|
|
|
|
Format = was am Tisch gespielt wird (cash, aof, bombpot, turnier, kpoker, vip, freeroll); nicht zu
|
|
verwechseln mit dem Modus Übung/Echt.
|
|
|
|
* Tisch (lesen/spot_from_log.Tisch.format) aus roomProperties beim Betreten:
|
|
Turnier-Lobby verknüpft -> turnier; isKPoker -> kpoker; gameType Allinfold -> aof;
|
|
isBombpot -> bombpot; gameType Ring -> cash; ohne Angabe -> None (unbekannt, nie geraten).
|
|
* Allinfold mit zwei Handkarten ist die Spielart AOF (Kern: binäre Entscheidung). Der Läufer
|
|
setzt dort aus, bis die AoF-Knöpfe gemessen sind - die Statistik zählt die Hände trotzdem.
|
|
* Hand (lesen/ergebnis.haende): jeder Eintrag trägt `format` - echte Hände aus dem Bestand.
|
|
* Statistik (betrieb/statistik.kennzahlen_aus): `je_format` mit Händen, bb/100 und 95-%-Spanne;
|
|
Hände ohne Format zählen als "unbekannt". `bestes_format`: nur wenn die Spanne eines Formats
|
|
ganz über allen anderen liegt - sonst None mit Grund.
|
|
|
|
python3 tests/format_spec.py -v
|
|
"""
|
|
import glob
|
|
import os
|
|
import sys
|
|
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 ("lesen", "betrieb", "sicht"):
|
|
sys.path.append(os.path.join(_w, _u))
|
|
import ergebnis
|
|
import spot_from_log as S
|
|
import statistik
|
|
import ansicht
|
|
|
|
ARCHIV = os.path.join(_w, "archiv", "echt")
|
|
RING = {"gameType": "Ring", "miniGameTypeId": 1, "isBombpot": False, "isKPoker": False}
|
|
|
|
|
|
def tisch(rp=None, turnier=None):
|
|
t = S.Tisch("T")
|
|
if rp is not None:
|
|
t.merke_raum(rp)
|
|
if turnier is not None:
|
|
t.merke_turnier(turnier)
|
|
return t
|
|
|
|
|
|
class FormatJeTisch(unittest.TestCase):
|
|
def test_ring_ist_cash(self):
|
|
self.assertEqual(tisch(RING).format(), "cash")
|
|
|
|
def test_allinfold_ist_aof(self):
|
|
self.assertEqual(tisch(dict(RING, gameType="Allinfold")).format(), "aof")
|
|
|
|
def test_bombpot_tisch(self):
|
|
self.assertEqual(tisch(dict(RING, isBombpot=True)).format(), "bombpot")
|
|
|
|
def test_kpoker_tisch(self):
|
|
self.assertEqual(tisch(dict(RING, isKPoker=True)).format(), "kpoker")
|
|
|
|
def test_turniertisch(self):
|
|
t = tisch(dict(RING, gameType="Tournament"), {"tourneyTableProperties": {"tournamentId": 117632}})
|
|
self.assertEqual(t.format(), "turnier")
|
|
|
|
def test_ohne_angabe_unbekannt(self):
|
|
self.assertIsNone(tisch().format())
|
|
|
|
def test_unbekannter_gametype_unbekannt(self):
|
|
self.assertIsNone(tisch(dict(RING, gameType="Spin")).format())
|
|
|
|
def test_aof_ist_spielart_aof(self):
|
|
self.assertEqual(tisch(dict(RING, gameType="Allinfold")).spielart(2), ("AOF", None))
|
|
|
|
def test_aof_mit_vier_karten_setzt_aus(self):
|
|
art, grund = tisch(dict(RING, gameType="Allinfold")).spielart(4)
|
|
self.assertIsNone(art)
|
|
self.assertIn("2", grund)
|
|
|
|
|
|
@unittest.skipUnless(glob.glob(os.path.join(ARCHIV, "main*.log.gz")), "Archiv fehlt")
|
|
class FormatJeHand(unittest.TestCase):
|
|
"""Echte Hände, geschnitten wie in tests/ergebnis_spec.py (Hand samt game_alldata des Raums).
|
|
Eine ganze AoF-Hand gibt es im Bestand nicht (5 Zeilen von 224829) - AoF belegt FormatJeTisch."""
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
sys.path.append(os.path.join(_w, "tests"))
|
|
import ergebnis_spec
|
|
ergebnis_spec.setUpModule()
|
|
cls.e = ergebnis_spec
|
|
|
|
def format_von(self, name, held):
|
|
raum, nr = self.e.HAENDE[name]
|
|
h = [x for x in ergebnis.haende(self.e.schnitt(name), held=held) if x["hand"] == nr]
|
|
self.assertTrue(h, name)
|
|
return {x["format"] for x in h}
|
|
|
|
def test_big_ben_ist_cash(self):
|
|
self.assertEqual(self.format_von("A", "mmintel"), {"cash"})
|
|
|
|
def test_plo_bombpot_raum(self):
|
|
# 14R PLO ... (B) 1663440: roomProperties isBombpot true, Bomb Pot alle 16 Hände
|
|
self.assertEqual(self.format_von("G", "ezmoney"), {"bombpot"})
|
|
|
|
|
|
def hand(fmt, netto_bb, bb=2.0, **mehr):
|
|
return dict({"format": fmt, "netto": netto_bb * bb, "bb": bb, "spielart": "NLHE", "stake": "1/2",
|
|
"aktionen": []}, **mehr)
|
|
|
|
|
|
class VergleichJeFormat(unittest.TestCase):
|
|
def je(self, haende):
|
|
return {g["format"]: g for g in statistik.kennzahlen_aus(haende)["je_format"]}
|
|
|
|
def test_gruppen_je_format(self):
|
|
g = self.je([hand("cash", 1), hand("cash", -1), hand("aof", 3)])
|
|
self.assertEqual((g["cash"]["haende"], g["aof"]["haende"]), (2, 1))
|
|
self.assertEqual(g["aof"]["bb_pro_100"], 300.0)
|
|
|
|
def test_ohne_format_ist_unbekannt(self):
|
|
alt = hand("cash", 1)
|
|
del alt["format"]
|
|
self.assertEqual(list(self.je([alt])), ["unbekannt"])
|
|
|
|
def test_spanne_um_den_schnitt(self):
|
|
g = self.je([hand("cash", x) for x in (2, -1, 0, 3, -2, 1)])["cash"]
|
|
self.assertLess(g["unten"], g["bb_pro_100"])
|
|
self.assertGreater(g["oben"], g["bb_pro_100"])
|
|
|
|
def test_eine_hand_hat_keine_spanne(self):
|
|
g = self.je([hand("aof", 3)])["aof"]
|
|
self.assertIsNone(g["unten"])
|
|
self.assertIsNone(g["oben"])
|
|
|
|
def test_bestes_format_nur_bei_klarem_abstand(self):
|
|
klar = [hand("aof", 10 + (i % 3)) for i in range(40)] + [hand("cash", -10 - (i % 3)) for i in range(40)]
|
|
k = statistik.kennzahlen_aus(klar)
|
|
self.assertEqual(k["bestes_format"]["format"], "aof")
|
|
|
|
def test_ueberlappende_spannen_kein_urteil(self):
|
|
knapp = [hand("aof", x) for x in (5, -5, 4, -3)] + [hand("cash", x) for x in (4, -4, 3, -2)]
|
|
b = statistik.kennzahlen_aus(knapp)["bestes_format"]
|
|
self.assertIsNone(b["format"])
|
|
self.assertIn("zu wenig", b["grund"])
|
|
|
|
def test_stats_md_hat_den_vergleich(self):
|
|
md = statistik.md_aus(statistik.kennzahlen_aus([hand("aof", 3), hand("cash", -1), hand("cash", 1)]))
|
|
self.assertIn("### je Format", md)
|
|
self.assertIn("| aof | 1 |", md)
|
|
self.assertIn("Am besten: noch kein Urteil", md)
|
|
|
|
def test_ein_format_allein_ist_kein_vergleich(self):
|
|
b = statistik.kennzahlen_aus([hand("cash", 1) for _ in range(50)])["bestes_format"]
|
|
self.assertIsNone(b["format"])
|
|
|
|
|
|
class InDerAnsicht(unittest.TestCase):
|
|
"""sicht/ansicht.wachstum: je_format und bestes_format - gesamt und je Modus (Übung/Echt getrennt)."""
|
|
|
|
def test_wachstum_traegt_den_vergleich(self):
|
|
haende = [{"raum": "A", "hand": str(i), "zeit": "2026-10-30T10:00:00Z", "netto": 20.0 if i % 2 else -4.0,
|
|
"bb": 2.0, "stake": "1/2", "spielart": "AOF", "format": "aof"} for i in range(6)]
|
|
haende += [{"raum": "B", "hand": str(i), "zeit": "2026-10-30T10:00:00Z", "netto": -2.0, "bb": 2.0,
|
|
"stake": "1/2", "spielart": "NLHE"} for i in range(3)]
|
|
w = ansicht.wachstum({"haende": haende}, jetzt=1793354400.0)
|
|
je = {g["format"]: g for g in w["je_format"]}
|
|
self.assertEqual((je["aof"]["haende"], je["unbekannt"]["haende"]), (6, 3))
|
|
self.assertEqual(je["aof"]["name"], "All-In or Fold")
|
|
self.assertIn("grund", w["bestes_format"])
|
|
self.assertIn("je_format", w["je_modus"]["uebung"])
|
|
|
|
|
|
class SpielplanInDerAnsicht(unittest.TestCase):
|
|
def test_alle_formate_mit_messstand(self):
|
|
k = ansicht.bauen({"spielplan": {"modus": "echt", "tische": 2, "formate": {"cash": 1, "aof": 1}}},
|
|
jetzt=1793354400.0)["kopf"]["spielplan"]
|
|
self.assertEqual(k["formate"], {"cash": 1, "aof": 1})
|
|
liste = {f["format"]: f for f in k["formate_liste"]}
|
|
self.assertEqual(set(liste), {"cash", "aof", "bombpot", "turnier", "kpoker", "vip", "freeroll"})
|
|
self.assertTrue(liste["cash"]["gemessen"])
|
|
self.assertFalse(liste["aof"]["gemessen"])
|
|
|
|
def test_alter_plan_zeigt_cash(self):
|
|
k = ansicht.bauen({"spielplan": {"modus": "uebung", "tische": 3}}, jetzt=1793354400.0)["kopf"]["spielplan"]
|
|
self.assertEqual(k["formate"], {"cash": 3})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|