- entscheiden/motor/src/lbr6.rs: lokale beste Antwort auf einem Sitz gegen fuenf Motor-Sitze, echte Karten, NL2-Rake, gepaart gegen den Motor selbst; Fehlerfassungen viel/station/zufall - messung/motor/pruef6: Karte, Ergebnis, Starter, Warteschlange, LBR-Laeufe, All-in-EV fuer tisch6 - messung/pruef/dz6.py: Bruecke zum dezhou_20260508-Berater (MIT OR Apache-2.0) - dienst.rs/nachrechnen.rs/nl2.rs/tisch6_pool.py: Stand des Hauptbaums, auf dem gemessen wurde Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
88 lines
3.9 KiB
Python
88 lines
3.9 KiB
Python
"""Bruecke zum fremden 6-max-Motor dezhou_20260508 (xujesse1988-ship-it, MIT OR Apache-2.0, Commit 14f8e207):
|
|
Vertrag (docs/VERTRAG.md) rein, sein tools/openpoker_advisor (Blueprint, optional --search) raus.
|
|
|
|
Sein Protokoll: eine JSON-Zeile je eigener Entscheidung (hole, board, button_seat, my_seat, num_seats, small/big_blind,
|
|
actions = Verlauf ohne Blinds mit `to` = Betrag dieser Strasse, valid), Einheiten wie OpenPoker: SB 10 / BB 20 (100 bb = 2000).
|
|
Unsere Sitze 1..6 -> seine 0..5, Button = unser buttonSeat - 1. Antwort fold/check/call/raise(+amount = raise-to).
|
|
Aufruf: dz6.py <advisor.exe> <checkpoint> <bucket_table> [weitere Argumente des Advisors ...]
|
|
DZ_PROTOKOLL=<datei>: je Antwort eine Zeile `source` (Blueprint / fallback:<Grund> / search...), zum Zaehlen.
|
|
"""
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
RANG = "23456789TJQKA"
|
|
W = ("TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING", "ACE")
|
|
PROTOKOLL = os.environ.get("DZ_PROTOKOLL")
|
|
|
|
|
|
def karte(k):
|
|
r = k["rank"]
|
|
r = RANG[W.index(r)] if r in W else str(r)[0]
|
|
return r + str(k["suit"])[0].lower()
|
|
|
|
|
|
def chips(x, bb):
|
|
return int(round(float(x) / bb * 20))
|
|
|
|
|
|
def anfrage(a):
|
|
bb = float(a["bigBlind"])
|
|
board = [karte(k) for s in ("FLOP", "TURN", "RIVER") for k in (a.get("board") or {}).get(s, [])]
|
|
akt = []
|
|
for h in a.get("history") or []:
|
|
x = h["action"]
|
|
if x.startswith("POST"):
|
|
continue
|
|
e = {"seat": int(h["seat"]) - 1, "action": {"FOLD": "fold", "CHECK": "check", "CALL": "call", "BET": "raise", "RAISE": "raise", "ALL_IN": "all_in"}[x]}
|
|
if x in ("BET", "RAISE", "ALL_IN") and h.get("amount") is not None:
|
|
e["to"] = chips(h["amount"], bb)
|
|
akt.append(e)
|
|
legal = a.get("legalActions") or []
|
|
v = {"can_check": "CHECK" in legal, "can_call": "CALL" in legal, "can_raise": "RAISE" in legal}
|
|
if v["can_raise"]:
|
|
v["min_raise"], v["max_raise"] = chips(a["minRaiseTo"], bb), chips(a["maxRaiseTo"], bb)
|
|
return {"hole": [karte(k) for k in a["heroCards"]], "board": board, "button_seat": int(a["buttonSeat"]) - 1,
|
|
"my_seat": int(a["heroSeat"]) - 1, "num_seats": int(a["seats"]), "small_blind": 10, "big_blind": 20,
|
|
"actions": akt, "valid": v}
|
|
|
|
|
|
def antwort(w, a):
|
|
bb = float(a["bigBlind"])
|
|
x = w.get("action")
|
|
legal = a.get("legalActions") or []
|
|
if x == "raise" and "RAISE" in legal:
|
|
return {"action": "RAISE", "size": round(w["amount"] / 20 * bb, 6), "confidence": 1, "reason": "dz " + w.get("source", "")}
|
|
if x in ("call", "check"):
|
|
return {"action": "CALL" if "CALL" in legal else "CHECK", "size": None, "confidence": 1, "reason": "dz " + w.get("source", "")}
|
|
if x == "fold" and "FOLD" in legal:
|
|
return {"action": "FOLD", "size": None, "confidence": 1, "reason": "dz " + w.get("source", "")}
|
|
return {"action": "CHECK" if "CHECK" in legal else "FOLD", "size": None, "confidence": 0, "reason": "dz unklar " + json.dumps(w)[:80]}
|
|
|
|
|
|
def main():
|
|
exe, ckpt, table, *rest = sys.argv[1:]
|
|
p = subprocess.Popen([exe, "--checkpoint", ckpt, "--bucket-table", table, *rest], stdin=subprocess.PIPE,
|
|
stdout=subprocess.PIPE, text=True, bufsize=1, creationflags=0x4000 if sys.platform == "win32" else 0)
|
|
bereit = p.stdout.readline()
|
|
if '"ready":true' not in bereit.replace(" ", ""):
|
|
sys.exit("advisor nicht bereit: " + bereit)
|
|
log = open(PROTOKOLL, "a", encoding="utf-8") if PROTOKOLL else None
|
|
for z in sys.stdin:
|
|
if not z.strip():
|
|
continue
|
|
a = json.loads(z)
|
|
p.stdin.write(json.dumps(anfrage(a)) + "\n")
|
|
p.stdin.flush()
|
|
w = json.loads(p.stdout.readline())
|
|
if log:
|
|
log.write(f'{a["street"]} {w.get("source", "?")}\n')
|
|
log.flush()
|
|
sys.stdout.write(json.dumps(antwort(w, a)) + "\n")
|
|
sys.stdout.flush()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|