Phase E: HUD voll in die Engine durchgereicht + Delta-Gedaechtnis je Spieler

Owner 8.11.: 'reizen wir das Wissen aus?' - CoinPokers HUD liefert ~13 Werte, die Engine
nutzte 4. Jetzt fliessen die 8 brachliegenden (cbet, foldToCbet, threeBet, foldToThreeBet,
steal, checkRaise, wtsd, wsd) end-to-end bis ins Rust-Profile (lesen/profil DURCHGEREICHT ->
wire/decode_villain -> exploit/profile, sample/mark mit None-Prior = Clientwert unveraendert).
NOCH keine Exploit-Regel liest sie: eine wtsd-Regel wurde gebaut, durch die Leiter-Benchmark
NICHT bewiesen (Stationen leicht negativ, kein Gewinn) und VERWORFEN - keine unbewiesene Kante
gegen Echtgeld. Engine bit-identisch zur Basislinie (Benchmark GESAMT nicht unterscheidbar,
kein Reg schlechter). Neu: lesen/gedaechtnis.py - Delta-Speicher je User-ID (gezeigte Haende,
Sizing/Timing-Buckets, Tendenz, vs-uns), speichert NUR was CoinPoker nicht liefert. Specs:
profil 15, gedaechtnis 11, Rust-Fixtures gruen. (Subagent-Arbeit, von mir verifiziert + Benchmark-
geprueft + committet.)
This commit is contained in:
2026-11-08 22:02:45 +01:00
parent 9c511a84b6
commit e107be73a5
18 changed files with 369 additions and 8 deletions
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env python3
"""Gegner-Gedaechtnis je CoinPoker-Nutzerkennung - das Delta, das der Client NICHT liefert.
Der Client gibt vpip/pfr/foldToBet und die uebrigen HUD-Zahlen schon selbst heraus (lesen/profil.py);
die doppelt dieses Gedaechtnis NIE. Gespeichert wird nur, was aus dem Verkehr faellt und sonst
verloren ginge:
* `gezeigt` - die letzten N ganz aufgedeckten Haende (aus profil.mit_gezeigten), alt -> neu.
* `sizing` - Zaehler je Sizing-Eimer (z. B. "mini", "halb", "pot", "over").
* `timing` - Zaehler je Timing-Eimer (z. B. "schnell", "normal", "lang").
* `notiz` - eine kurze Tendenz-Notiz (die letzte gewinnt).
* `vs_uns` - ein kleines Log der Begegnungen gegen uns (letzte N), HUD-Felder rausgefiltert.
Alles rein-funktional (ergaenzen/leer liefern neue Datensaetze); nur laden/speichern fassen die
Platte an. Die Ablage ist eine kleine JSON-Datei, laedt sofort und ohne Netz. Kaputte/fehlende
Ablage -> leeres Gedaechtnis, nie eine Ausnahme.
Spezifikation: tests/gedaechtnis_spec.py.
"""
import json
import os
import sys
_w = os.path.dirname(os.path.abspath(__file__))
if _w not in sys.path:
sys.path.insert(0, _w)
import profil
GRENZE_GEZEIGT = 10 # so viele zuletzt gezeigte Haende je Gegner
GRENZE_VS_UNS = 20 # so viele letzte Begegnungen gegen uns
# Was der Client selbst liefert (lesen/profil.py) - das Gedaechtnis speichert davon NICHTS.
VERBOTEN = frozenset(("vpip", "pfr", "foldToBet", "fta", "fold", "aggression") + profil.DURCHGEREICHT)
FELDER = ("gezeigt", "sizing", "timing", "notiz", "vs_uns")
def leer():
"""Ein frischer, leerer Datensatz je Gegner."""
return {"gezeigt": [], "sizing": {}, "timing": {}, "notiz": "", "vs_uns": []}
def _ohne_hud(d):
"""Ein vs-uns-Eintrag ohne die vom Client gelieferten HUD-Felder (kein Doppeln)."""
if not isinstance(d, dict):
return d
return {k: v for k, v in d.items() if k not in VERBOTEN}
def _eimer(zaehler, name):
"""`zaehler` um eine Beobachtung im Eimer `name` erhoeht (neues Dict)."""
neu = dict(zaehler or {})
if name:
neu[name] = int(neu.get(name, 0)) + 1
return neu
def ergaenzen(eintrag, gezeigt=None, sizing=None, timing=None, notiz=None, vs_uns=None):
"""`eintrag` um neue Beobachtungen erweitert - rein-funktional (neuer Datensatz).
`gezeigt`: eine Liste gezeigter Haende (je eine Kartenliste), wird angehaengt und auf die
letzten GRENZE_GEZEIGT begrenzt. `sizing`/`timing`: ein Eimer-Name, dessen Zaehler steigt.
`notiz`: ersetzt die Tendenz-Notiz (leere Notiz laesst die alte stehen). `vs_uns`: eine
Begegnung (Dict), wird angehaengt und auf die letzten GRENZE_VS_UNS begrenzt; HUD-Felder
werden dabei entfernt (NIE vpip/pfr doppeln)."""
e = leer()
e.update({k: _kopie(eintrag.get(k, e[k])) for k in FELDER} if eintrag else {})
if gezeigt:
e["gezeigt"] = (e["gezeigt"] + [list(h) for h in gezeigt])[-GRENZE_GEZEIGT:]
if sizing:
e["sizing"] = _eimer(e["sizing"], sizing)
if timing:
e["timing"] = _eimer(e["timing"], timing)
if notiz:
e["notiz"] = str(notiz)
if vs_uns:
e["vs_uns"] = (e["vs_uns"] + [_ohne_hud(vs_uns)])[-GRENZE_VS_UNS:]
return e
def _kopie(wert):
"""Flache Kopie der veraenderlichen Felder, damit der alte Datensatz unberuehrt bleibt."""
if isinstance(wert, list):
return list(wert)
if isinstance(wert, dict):
return dict(wert)
return wert
def merken(speicher, kennung, **beobachtung):
"""`speicher` um die Beobachtungen zu `kennung` erweitert - neues Gedaechtnis (alte Kopie)."""
kennung = str(kennung)
neu = dict(speicher or {})
neu[kennung] = ergaenzen(neu.get(kennung), **beobachtung)
return neu
def laden(pfad):
"""Das Gedaechtnis von der Platte - {} bei fehlender oder kaputter Ablage, nie eine Ausnahme."""
try:
with open(pfad, "r", encoding="utf-8") as f:
daten = json.load(f)
except (OSError, ValueError):
return {}
return daten if isinstance(daten, dict) else {}
def speichern(pfad, speicher):
"""Das Gedaechtnis atomar schreiben (erst .tmp, dann os.replace - nie halb)."""
os.makedirs(os.path.dirname(pfad) or ".", exist_ok=True)
tmp = pfad + ".tmp"
with open(tmp, "w", encoding="utf-8") as f:
json.dump(speicher or {}, f, ensure_ascii=False)
os.replace(tmp, pfad)
if __name__ == "__main__":
print(json.dumps(laden(sys.argv[1] if len(sys.argv) > 1 else ""), ensure_ascii=False, indent=1))
+11 -1
View File
@@ -17,6 +17,11 @@ import re
FELDER = {"vpip": "vpip", "pfr": "pfr"}
FALTEN = ("fta", "fold")
# Phase E: schon abgerufene HUD-Felder, die der Kern bisher nicht nutzte. Namen bleiben wie im
# Client (die Wire-Form an die Engine liest sie genau so, src/wire/decode_villain.rs) - kein
# Umbenennen, nur auf unsere 0..1-Skala gebracht. VPIP/PFR/foldToBet bleiben ihr eigener Weg.
DURCHGEREICHT = ("cbet", "foldToCbet", "threeBet", "foldToThreeBet",
"steal", "checkRaise", "wtsd", "wsd")
STATISTIK = re.compile(r'"api"\s*:\s*"hud_stats"')
@@ -126,7 +131,8 @@ def stichproben(text):
def statistiken(text):
"""{kennung: {"vpip": 0..1, "pfr": 0..1, "foldToBet": 0..1}} - spätere Angaben gewinnen."""
"""{kennung: profil} - vpip/pfr/foldToBet plus die DURCHGEREICHT-Felder (0..1), falls geliefert;
spätere Angaben gewinnen."""
ergebnis = {}
for kennung, werte in _hud(text):
profil_werte = {}
@@ -140,6 +146,10 @@ def statistiken(text):
if anteil is not None:
profil_werte["foldToBet"] = anteil
break
for feld in DURCHGEREICHT:
anteil = _anteil(werte.get(feld))
if anteil is not None:
profil_werte[feld] = anteil
if profil_werte:
ergebnis[kennung] = profil_werte
return ergebnis
+18 -1
View File
@@ -6,12 +6,21 @@
use super::profile::Profile;
/// What a beginner or fish is assumed to do where nothing is measured.
/// What a beginner or fish is assumed to do where nothing is measured. The HUD extras stay unknown:
/// the label is a coarse prior, no basis to invent continuation or showdown frequencies.
const WEAK_PLAYER: Profile = Profile {
vpip: Some(0.45),
pfr: Some(0.10),
fold_to_bet: Some(0.25),
aggression: Some(0.20),
cbet: None,
fold_to_cbet: None,
three_bet: None,
fold_to_three_bet: None,
steal: None,
check_raise: None,
wtsd: None,
wsd: None,
};
fn prior(mark: &str) -> Option<Profile> {
@@ -29,5 +38,13 @@ pub fn with_mark(measured: Option<Profile>, mark: &str) -> Option<Profile> {
pfr: known.pfr.or(prior.pfr),
fold_to_bet: known.fold_to_bet.or(prior.fold_to_bet),
aggression: known.aggression.or(prior.aggression),
cbet: known.cbet.or(prior.cbet),
fold_to_cbet: known.fold_to_cbet.or(prior.fold_to_cbet),
three_bet: known.three_bet.or(prior.three_bet),
fold_to_three_bet: known.fold_to_three_bet.or(prior.fold_to_three_bet),
steal: known.steal.or(prior.steal),
check_raise: known.check_raise.or(prior.check_raise),
wtsd: known.wtsd.or(prior.wtsd),
wsd: known.wsd.or(prior.wsd),
})
}
+23
View File
@@ -1,6 +1,12 @@
/// Observed opponent tendencies, all frequencies in `[0, 1]`. Every field optional.
/// Wire shape (extension):
/// `"profile": {"vpip": 0.45, "pfr": 0.08, "foldToBet": 0.3, "aggression": 0.4}`.
///
/// The fields below `aggression` are the HUD numbers the client already delivers but the core did
/// not read before (`lesen/profil.py` DURCHGEREICHT). They carry their client names on the wire
/// (`src/wire/decode_villain.rs`) and reach the engine per villain. No exploit rule reads them yet:
/// every new read must first earn its place on the ladder benchmark (`read_gate`), which no
/// candidate has so far. They stand ready for the opponent memory and future, ladder-proven rules.
#[derive(Clone, Copy, Debug, PartialEq, Default)]
pub struct Profile {
/// Voluntarily put money in pot, preflop.
@@ -12,4 +18,21 @@ pub struct Profile {
/// Share of the player's postflop actions that are bets or raises (aggression
/// frequency). Steers how much of their betting range is a bluff (`bluff_share`).
pub aggression: Option<f64>,
/// How often the player continuation-bets the flop as the preflop aggressor.
pub cbet: Option<f64>,
/// How often the player folds to a continuation bet.
pub fold_to_cbet: Option<f64>,
/// Preflop three-bet frequency.
pub three_bet: Option<f64>,
/// How often the player folds to a three-bet.
pub fold_to_three_bet: Option<f64>,
/// How often the player attempts to steal the blinds from late position.
pub steal: Option<f64>,
/// How often the player check-raises.
pub check_raise: Option<f64>,
/// Went to showdown: how often the player reaches showdown once seeing the flop. A high
/// value marks a sticky, showdown-happy opponent.
pub wtsd: Option<f64>,
/// Won at showdown: how often the player wins once at showdown.
pub wsd: Option<f64>,
}
+19 -1
View File
@@ -14,12 +14,22 @@ use crate::exploit::profile::Profile;
/// Hands at which the sample and the population weigh the same (`trust` 0.5).
pub const PRIOR_HANDS: f64 = 30.0;
/// The population an unknown opponent is assumed to be: a regular of the stock.
/// The population an unknown opponent is assumed to be: a regular of the stock. The HUD extras have
/// no population prior yet: a missing one leaves `shrink` to pass the measured value through, so a
/// field without a prior is never pulled off the client's number.
pub const PRIOR: Profile = Profile {
vpip: Some(0.28),
pfr: Some(0.18),
fold_to_bet: Some(0.45),
aggression: Some(0.35),
cbet: None,
fold_to_cbet: None,
three_bet: None,
fold_to_three_bet: None,
steal: None,
check_raise: None,
wtsd: None,
wsd: None,
};
/// Weight of the sample in `[0, 1)`.
@@ -45,5 +55,13 @@ pub fn shrink(profile: &Profile, hands: f64) -> Profile {
pfr: pull(profile.pfr, PRIOR.pfr, w),
fold_to_bet: pull(profile.fold_to_bet, PRIOR.fold_to_bet, w),
aggression: pull(profile.aggression, PRIOR.aggression, w),
cbet: pull(profile.cbet, PRIOR.cbet, w),
fold_to_cbet: pull(profile.fold_to_cbet, PRIOR.fold_to_cbet, w),
three_bet: pull(profile.three_bet, PRIOR.three_bet, w),
fold_to_three_bet: pull(profile.fold_to_three_bet, PRIOR.fold_to_three_bet, w),
steal: pull(profile.steal, PRIOR.steal, w),
check_raise: pull(profile.check_raise, PRIOR.check_raise, w),
wtsd: pull(profile.wtsd, PRIOR.wtsd, w),
wsd: pull(profile.wsd, PRIOR.wsd, w),
}
}
+1
View File
@@ -16,6 +16,7 @@ fn p(vpip: f64, pfr: f64, fold_to_bet: f64, aggression: f64) -> Option<Profile>
pfr: Some(pfr),
fold_to_bet: Some(fold_to_bet),
aggression: Some(aggression),
..Profile::default()
})
}
+9
View File
@@ -17,6 +17,15 @@ fn profile(villain: &Value, path: &str) -> Result<Option<Profile>, Fault> {
pfr: opt_number_member(object, &at_profile, "pfr")?,
fold_to_bet: opt_number_member(object, &at_profile, "foldToBet")?,
aggression: opt_number_member(object, &at_profile, "aggression")?,
// HUD extras (lesen/profil.py DURCHGEREICHT): same client names on the wire.
cbet: opt_number_member(object, &at_profile, "cbet")?,
fold_to_cbet: opt_number_member(object, &at_profile, "foldToCbet")?,
three_bet: opt_number_member(object, &at_profile, "threeBet")?,
fold_to_three_bet: opt_number_member(object, &at_profile, "foldToThreeBet")?,
steal: opt_number_member(object, &at_profile, "steal")?,
check_raise: opt_number_member(object, &at_profile, "checkRaise")?,
wtsd: opt_number_member(object, &at_profile, "wtsd")?,
wsd: opt_number_member(object, &at_profile, "wsd")?,
};
// `hands` (extension, exploit::sample): with it, few hands count little
Ok(Some(match opt_number_member(object, &at_profile, "hands")? {
+1 -1
View File
@@ -99,7 +99,7 @@ fn station(fold_to_bet: f64) -> Villain {
seat: 2,
stack: 100.0,
folded: false,
profile: Some(Profile { vpip: Some(0.75), pfr: Some(0.03), fold_to_bet: Some(fold_to_bet), aggression: None }),
profile: Some(Profile { vpip: Some(0.75), pfr: Some(0.03), fold_to_bet: Some(fold_to_bet), aggression: None, ..Profile::default() }),
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ use rechner::game::{ActionKind, Spot, Street, Villain};
use rechner::variant::Variant;
fn prof(vpip: f64, pfr: f64, fold: f64, aggr: f64) -> Option<Profile> {
Some(Profile { vpip: Some(vpip), pfr: Some(pfr), fold_to_bet: Some(fold), aggression: Some(aggr) })
Some(Profile { vpip: Some(vpip), pfr: Some(pfr), fold_to_bet: Some(fold), aggression: Some(aggr), ..Profile::default() })
}
fn spot_mit(villains: Vec<Villain>) -> Spot {
+1
View File
@@ -10,6 +10,7 @@ fn profile(vpip: Option<f64>, pfr: Option<f64>, fold_to_bet: Option<f64>) -> Pro
pfr,
fold_to_bet,
aggression: None,
..Profile::default()
}
}
+1
View File
@@ -155,6 +155,7 @@ fn sticky_players_hold_wider_ranges_than_foldy_ones() {
pfr: None,
fold_to_bet: Some(ftb),
aggression: None,
..Profile::default()
})
};
assert!(
+1 -1
View File
@@ -12,7 +12,7 @@ use rechner::exploit::sample::{shrink, trust, PRIOR_HANDS, PRIOR};
use rechner::wire::respond::respond;
fn station() -> Profile {
Profile { vpip: Some(0.60), pfr: Some(0.05), fold_to_bet: Some(0.15), aggression: Some(0.20) }
Profile { vpip: Some(0.60), pfr: Some(0.05), fold_to_bet: Some(0.15), aggression: Some(0.20), ..Profile::default() }
}
#[test]
+1
View File
@@ -7,6 +7,7 @@ fn profile(vpip: Option<f64>, pfr: Option<f64>, fold_to_bet: Option<f64>) -> Pro
pfr,
fold_to_bet,
aggression: None,
..Profile::default()
}
}
+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
"""Spezifikation des Gegner-Gedaechtnisses - geschrieben VOR dem Code.
Das Gedaechtnis speichert je CoinPoker-Kennung NUR das Delta, das der Client nicht liefert:
gezeigte Haende, Sizing-/Timing-Eimer, eine Tendenz-Notiz, ein kleines vs-uns-Log. Geprueft wird:
Round-Trip ueber die Platte, Begrenzung auf die letzten N, kein Doppeln der HUD-Zahlen, sofortiges
Laden ohne Netz, und dass die reinen Funktionen den alten Datensatz nie veraendern.
python3 tests/gedaechtnis_spec.py -v
"""
import os
import sys
import tempfile
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",):
_q = os.path.join(_w, _u)
if os.path.isdir(_q):
sys.path.append(_q)
import gedaechtnis
class RoundTrip(unittest.TestCase):
def test_speichern_und_laden_ist_dasselbe(self):
speicher = gedaechtnis.merken({}, 1662615, gezeigt=[["Ah", "Kd"]], sizing="pot", notiz="barrelt viel")
with tempfile.TemporaryDirectory() as d:
pfad = os.path.join(d, "gegner", "gedaechtnis.json")
gedaechtnis.speichern(pfad, speicher)
self.assertEqual(gedaechtnis.laden(pfad), speicher)
def test_fehlende_ablage_ist_leer(self):
self.assertEqual(gedaechtnis.laden("/gibt/es/nicht.json"), {})
def test_kaputte_ablage_ist_leer(self):
with tempfile.TemporaryDirectory() as d:
pfad = os.path.join(d, "kaputt.json")
with open(pfad, "w") as f:
f.write("{ kein json")
self.assertEqual(gedaechtnis.laden(pfad), {})
class Begrenzung(unittest.TestCase):
def test_nur_die_letzten_n_gezeigten_haende(self):
haende = [[f"{r}h", f"{r}d"] for r in "23456789TJQKA"] # 13 > GRENZE_GEZEIGT (10)
e = gedaechtnis.ergaenzen(gedaechtnis.leer(), gezeigt=haende)
self.assertEqual(len(e["gezeigt"]), gedaechtnis.GRENZE_GEZEIGT)
self.assertEqual(e["gezeigt"][-1], ["Ah", "Ad"]) # neueste bleibt
self.assertEqual(e["gezeigt"][0], ["5h", "5d"]) # die drei aeltesten sind weggefallen
def test_vs_uns_log_ist_begrenzt(self):
e = gedaechtnis.leer()
for i in range(gedaechtnis.GRENZE_VS_UNS + 5):
e = gedaechtnis.ergaenzen(e, vs_uns={"hand": i})
self.assertEqual(len(e["vs_uns"]), gedaechtnis.GRENZE_VS_UNS)
self.assertEqual(e["vs_uns"][-1]["hand"], gedaechtnis.GRENZE_VS_UNS + 4)
class KeinDoppeln(unittest.TestCase):
def test_hud_felder_landen_nicht_im_vs_uns_log(self):
e = gedaechtnis.ergaenzen(gedaechtnis.leer(),
vs_uns={"vpip": 0.3, "pfr": 0.2, "wtsd": 0.5, "aktion": "callt River"})
eintrag = e["vs_uns"][-1]
self.assertEqual(eintrag, {"aktion": "callt River"})
for feld in ("vpip", "pfr", "wtsd"):
self.assertNotIn(feld, eintrag)
def test_der_datensatz_hat_keine_hud_felder(self):
e = gedaechtnis.ergaenzen(gedaechtnis.leer(), notiz="tight", sizing="mini")
self.assertTrue(gedaechtnis.VERBOTEN.isdisjoint(e))
class Eimer(unittest.TestCase):
def test_sizing_und_timing_zaehlen_hoch(self):
e = gedaechtnis.leer()
e = gedaechtnis.ergaenzen(e, sizing="pot", timing="schnell")
e = gedaechtnis.ergaenzen(e, sizing="pot", timing="lang")
self.assertEqual(e["sizing"]["pot"], 2)
self.assertEqual(e["timing"], {"schnell": 1, "lang": 1})
def test_notiz_die_letzte_gewinnt(self):
e = gedaechtnis.ergaenzen(gedaechtnis.leer(), notiz="alt")
e = gedaechtnis.ergaenzen(e, notiz="neu")
self.assertEqual(e["notiz"], "neu")
class Unveraenderlich(unittest.TestCase):
def test_ergaenzen_laesst_den_alten_datensatz_in_ruhe(self):
alt = gedaechtnis.ergaenzen(gedaechtnis.leer(), gezeigt=[["Ah", "Kd"]], sizing="pot")
_neu = gedaechtnis.ergaenzen(alt, gezeigt=[["2c", "2d"]], sizing="pot")
self.assertEqual(len(alt["gezeigt"]), 1)
self.assertEqual(alt["sizing"]["pot"], 1)
def test_merken_kopiert_den_speicher(self):
a = gedaechtnis.merken({}, 1, notiz="x")
b = gedaechtnis.merken(a, 2, notiz="y")
self.assertNotIn("2", a)
self.assertIn("1", b)
if __name__ == "__main__":
unittest.main(verbosity=2)
+38
View File
@@ -43,6 +43,13 @@ OHNE_FTA = esc('"api":"hud_stats","data":{"msg":{"1701711":{"1":{"fold":76,"vpip
KAPUTT = esc('"api":"hud_stats","data":{"msg":{"1701711":{"1":{"mkdir":1,"vpip":120,"pfr":-5}}}}')
# Der Client liefert je Gegner rund dreizehn Zahlen; bis Phase E nutzte der Kern nur vpip/pfr/fta.
# Diese Vorlage trägt die volle HUD-Zeile, damit die bisher brachen Felder geprüft sind.
HUD_VOLL = esc('"api":"hud_stats","data":{"msg":{"1662615":{"1":{'
'"vpip":29,"pfr":20,"fta":65,"fold":73,'
'"cbet":58,"foldToCbet":34,"threeBet":9,"foldToThreeBet":62,'
'"steal":41,"checkRaise":7,"wtsd":28,"wsd":54}}}}')
class Werte(unittest.TestCase):
def test_prozent_wird_zu_anteil(self):
@@ -71,6 +78,37 @@ class Werte(unittest.TestCase):
self.assertEqual(profil.statistiken(""), {})
class HudFelder(unittest.TestCase):
"""Phase E: die schon abgerufenen, bisher brachen HUD-Felder landen im Profil je Sitz."""
NEU = ("cbet", "foldToCbet", "threeBet", "foldToThreeBet", "steal", "checkRaise", "wtsd", "wsd")
ERWARTET = {"cbet": 0.58, "foldToCbet": 0.34, "threeBet": 0.09, "foldToThreeBet": 0.62,
"steal": 0.41, "checkRaise": 0.07, "wtsd": 0.28, "wsd": 0.54}
def test_alle_neuen_felder_als_anteil(self):
s = profil.statistiken(HUD_VOLL)["1662615"]
for feld, wert in self.ERWARTET.items():
self.assertAlmostEqual(s[feld], wert, places=4, msg=feld)
def test_vpip_pfr_foldtobet_bleiben_erhalten(self):
s = profil.statistiken(HUD_VOLL)["1662615"]
self.assertAlmostEqual(s["vpip"], 0.29, places=4)
self.assertAlmostEqual(s["pfr"], 0.20, places=4)
self.assertAlmostEqual(s["foldToBet"], 0.65, places=4)
def test_fehlende_neue_felder_fliegen_raus(self):
s = profil.statistiken(OHNE_FTA)["1701711"]
for feld in self.NEU:
self.assertNotIn(feld, s)
def test_felder_haengen_am_sitz_und_an_der_sitzliste(self):
werte = profil.statistiken(HUD_VOLL)
liste = [{"seatId": 2, "userName": "SneS77", "userId": 1662615}]
p = profil.aus_sitzliste(liste, werte)
self.assertAlmostEqual(p[2]["foldToCbet"], 0.34, places=4)
self.assertAlmostEqual(p[2]["threeBet"], 0.09, places=4)
class Sitze(unittest.TestCase):
def test_profil_haengt_am_sitz(self):
p = profil.profile_je_sitz(SITZE + KOMPLETT)
+1 -1
View File
@@ -45,7 +45,7 @@ pub fn villain(seat: u8, profile: Option<Profile>) -> Villain {
}
pub fn profile(vpip: Option<f64>, pfr: Option<f64>, fold: Option<f64>) -> Option<Profile> {
Some(Profile { vpip, pfr, fold_to_bet: fold, aggression: None })
Some(Profile { vpip, pfr, fold_to_bet: fold, aggression: None, ..Profile::default() })
}
pub fn vpip(value: f64) -> Option<Profile> {
+1 -1
View File
@@ -140,7 +140,7 @@ fn property_random_histories_always_give_a_well_formed_spec() {
rng = r;
let (seat, r) = rng.below(12);
rng = r;
let mut s = spot(board, history, Some(Profile { vpip, pfr, fold_to_bet: fold, aggression: None }));
let mut s = spot(board, history, Some(Profile { vpip, pfr, fold_to_bet: fold, aggression: None, ..Profile::default() }));
s.seats = seats as u8;
s.button_seat = if button == 13 { None } else { Some(button as u8) };
let v = Villain { seat: seat as u8, stack: 50.0, folded: false, profile: s.villains[0].profile };
+19
View File
@@ -138,6 +138,25 @@ fn extension_fields() {
assert_eq!((p1.vpip, p1.pfr, p1.fold_to_bet), (Some(0.2), None, None));
}
/// The HUD extras the client already delivers (Phase E, `lesen/profil.py` DURCHGEREICHT) decode
/// under their client names; absent ones stay `None`.
#[test]
fn hud_extra_fields() {
let ext = r#""villains":[{"seat":1,"stack":50,"folded":false,"profile":{
"cbet":0.58,"foldToCbet":0.34,"threeBet":0.09,"foldToThreeBet":0.62,
"steal":0.41,"checkRaise":0.07,"wtsd":0.28,"wsd":0.54}}]"#;
let p = run(&plus(ext)).unwrap().villains[0].profile.unwrap();
assert_eq!((p.cbet, p.fold_to_cbet), (Some(0.58), Some(0.34)));
assert_eq!((p.three_bet, p.fold_to_three_bet), (Some(0.09), Some(0.62)));
assert_eq!((p.steal, p.check_raise), (Some(0.41), Some(0.07)));
assert_eq!((p.wtsd, p.wsd), (Some(0.28), Some(0.54)));
let sparse = r#""villains":[{"seat":1,"stack":50,"folded":false,"profile":{"wtsd":0.6}}]"#;
let q = run(&plus(sparse)).unwrap().villains[0].profile.unwrap();
assert_eq!(q.wtsd, Some(0.6));
assert_eq!((q.cbet, q.fold_to_cbet, q.three_bet, q.wsd), (None, None, None, None));
}
#[test]
fn unknown_fields_are_ignored() {
let extra = r#""whatever":{"x":[1]},"villains":[{"seat":1,"stack":1,"folded":false,"nick":"x"}]"#;