# Pfadpreis (messung/eichung/tor, main, unveraendert entpackt nach nach/tor_main) fuer die Profil-Zerlegung. # Die Tor-Spots tragen keine Gegnerprofile; hier bekommen sie sie wie in lesen.py (andere Tageshaelfte, ohne gezaehlte # Reads) und VORWISSEN wie in teile_spots.py. Gefragt werden nur Spots mit Profil am lebenden Gegner; ohne Profil ist # PROFIL_OHNE ohne Wirkung (Differenz 0, beide Arme bekommen dieselbe Antwort CHECK). # python -B -X utf8 tor_pfad.py spots # python -B -X utf8 tor_pfad.py arm ... # python -B -X utf8 tor_pfad.py preis ... (arm minus live, alle / a / b) import json, os, sys, types sys.dont_write_bytecode = True HIER = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HIER) import teile as T # noqa: E402 AR = T.AR NACH = os.path.join(AR.GS, "nach") AUS = os.path.join(NACH, "tor_profil") QUELLE = os.path.join(os.path.expanduser("~"), "pokerfreak-regulars", "eichung", "tor") sys.path.insert(0, os.path.join(NACH, "tor_main", "messung", "eichung", "tor")) ANTEIL = {"river": 1.0, "turn": 0.15} def suf(s): return "" if s == "river" else "_" + s def spots(strasse): import collections import lesen as L, draht, tor sch = AR.KN.roentgen.lies_schalter(os.environ["KERN_SCHALTER"]) sp = draht.Quelle(sch["VORWISSEN"], 10 ** 6).speicher(True) art = sch.get("VORWISSEN_ART", "pool") ohne = tuple(x.strip() for x in sch.get("VORWISSEN_OHNE", "").split(",") if x.strip()) sitze = json.load(open(os.path.join(NACH, "sitze.json"), encoding="utf-8")) tage = json.load(open(os.path.join(NACH, "tage.json"), encoding="utf-8")) S = [s for s in map(json.loads, open(os.path.join(QUELLE, "spots%s.jsonl" % suf(strasse)), encoding="utf-8")) if tor.in_probe(s["id"], ANTEIL[strasse])] acc, hand = L.zaehlungen({x for s in S for x in sitze.get(s["id"].split(".")[0], []) if x}) st = collections.Counter() for v in ("teile_live", "teile_ohne_vw"): os.makedirs(os.path.join(AUS, v), exist_ok=True) f = {v: open(os.path.join(AUS, v, "spots%s.jsonl" % suf(strasse)), "w", encoding="utf-8", newline="\n") for v in ("teile_live", "teile_ohne_vw")} for s in S: st["spots"] += 1 nr = s["id"].split(".")[0] h, pl = tage.get(nr), sitze.get(nr) if pl is None or h is None: st["ohne_sitze"] += 1 continue n = 0 for v in s["req"]["villains"]: if v.get("folded"): continue k = pl[v["seat"] - 1] if v["seat"] - 1 < len(pl) else None if not k or hand[(k, 1 - h % 2)] < L.MIN: continue p = L.profil(acc[(k, 1 - h % 2)], hand[(k, 1 - h % 2)], k, False) v["vw"] = p.pop("vw") v["profile"] = p n += 1 if not n: st["ungelesen"] += 1 continue st["gelesen"] += 1 o = json.loads(json.dumps(s)) for v in o["req"]["villains"]: v.pop("vw", None) r = json.loads(draht.anreichern(json.dumps(s["req"], ensure_ascii=True), sp, art, ohne)) for v in r["villains"]: v.pop("vw", None) st["mit_vorwissen"] += any("vorwissen" in (v.get("profile") or {}) for v in r["villains"]) s["req"] = r f["teile_live"].write(json.dumps(s, separators=(",", ":")) + "\n") f["teile_ohne_vw"].write(json.dumps(o, separators=(",", ":")) + "\n") print(strasse, dict(st), flush=True) def arm(strasse, pr, arme): for a in arme: quelle, zusatz, heraus, binr, _ = T.ARME[a] env = AR.umgebung("live") for k in heraus: env.pop(k) env.update(zusatz) d = os.path.join(AUS, "arme", a) os.makedirs(d, exist_ok=True) aus = os.path.join(d, "antw%s.jsonl" % suf(strasse)) if not os.path.exists(aus): print("==", strasse, a, flush=True) AR.KN.lf.lauf_entscheiden(os.path.join(AUS, quelle, "spots%s.jsonl" % suf(strasse)), aus, binr, env, prozesse=pr, block=60) def preis(strasse, arme): import tor ids = [z[7:z.index('",')] for z in open(os.path.join(QUELLE, "spots%s.jsonl" % suf(strasse)), encoding="utf-8")] tor.TOR = AUS roh = tor.antworten def antworten(marke, suffix=""): A = roh(marke, suffix) for i in ids: A.setdefault(i, {"action": "CHECK"}) return A tor.antworten = antworten for a in ["live"] + arme: json.dump({"anteil": ANTEIL[strasse]}, open(os.path.join(AUS, "arme", a, "arm%s.json" % suf(strasse)), "w")) for a in arme: for teil in ("alle", "a", "b"): tor.cmd_vergleich(types.SimpleNamespace(strasse=strasse, a=a, b="live", teil=teil)) if __name__ == "__main__": c, s = sys.argv[1:3] if c == "spots": spots(s) elif c == "arm": arm(s, int(sys.argv[3]), sys.argv[4:]) print("alle fertig", flush=True) else: preis(s, sys.argv[3:])