- betrieb/sicherung_extern.ps1: stuendliche, verschluesselte Sicherung nach infra.mintel.me in drei Stufen (kern: echte/gekaufte Haende und Live-Daten, tafeln: Motor-/SHARINGAN-Tabellen, rest: Mess-/Sim-Daten), gedrosselt waehrend der Laeufer spielt; Regel in CLAUDE.md - .gitignore: Protokoll und Stand der Sicherung bleiben lokal - Karten, Berichte und Auswerteskripte der Messungen (batterie, beute, motor, orakel, sammelkorb), Register, Plan, Ideen, Neubewertungen, lesen/stackoff.py, Waechter Rohdaten, Logs, Tabellen, Pickles und PID-Dateien bleiben bewusst ausserhalb von Git (Spielerkennungen, Groesse); sie sichert restic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
4.5 KiB
Python
70 lines
4.5 KiB
Python
# Beute je Spielertyp, Schritt 1: hhDealer NL2 6-max (nur gelesen) -> je Hand und Sitz Netto in bb, kompakt als numpy.
|
|
# Schluessel gesalzen (lesen/vorwissen/kennung, wie river.pkl), Ausgabe nur AUSSERHALB des Repos (D:/Projects/pokerfreak-daten/beute/).
|
|
# Namen nur fuer den Spieleratlas, ebenfalls nur ausserhalb (namen.pkl).
|
|
# python -X utf8 messung/beute/beute_scan.py <prozesse>
|
|
import sys as _s, os as _o; _s.path.insert(0, _o.path.abspath(__file__).split("messung")[0] + "messung"); import sicher # Regel 28.11.: nie "w" auf bestehende Datei
|
|
import sys; sys.dont_write_bytecode = True
|
|
import collections, io, os, pickle, re, zipfile
|
|
import numpy as np
|
|
HIER = os.path.dirname(os.path.abspath(__file__)); W = os.path.normpath(os.path.join(HIER, "..", ".."))
|
|
sys.path[:0] = [os.path.join(W, "messung/motor/schiedsrichter"), os.path.join(W, "lesen/vorwissen")]
|
|
import hhd_scan as HS, kennung as KE
|
|
AUS = "D:/Projects/pokerfreak-daten/beute/"
|
|
GEW = os.path.join(W, "messung/motor/schiedsrichter/gewinner.pkl") # Top 10 je Tageshaelfte
|
|
GEW_BREIT = "C:/Users/marcm/pokerfreak-regulars/echtgewinner/gewinner.pkl" # alle mit z>=1.65, n>=5000
|
|
RE_ZEIT = re.compile(r" (\d{2}):\d{2}:\d{2} ")
|
|
|
|
|
|
def teil(name):
|
|
HS._niedrig()
|
|
eigene = set(open(HS.EIGENE, encoding="utf-8").read().split()); ich = open(HS.NAME, encoding="utf-8").read().strip()
|
|
g10 = pickle.load(open(GEW, "rb"))["gew"]; gb = pickle.load(open(GEW_BREIT, "rb"))["gew"]
|
|
tag = int(name[:10].replace("-", "")) - 20200000
|
|
za = zipfile.ZipFile(HS.ZIP); innen = zipfile.ZipFile(io.BytesIO(za.read(name)))
|
|
Hh = []; Pk = []; Pn = []; Pf = []; namen = {}; st = collections.Counter()
|
|
for info in innen.infolist():
|
|
for blk in re.split(r"\n\s*\n\s*\n", innen.read(info).decode("utf-8", "replace")):
|
|
zl = [z.rstrip("\r") for z in blk.strip().splitlines()]
|
|
if not zl or not zl[0].startswith("CoinPoker Hand #"): continue
|
|
if "straddle" in blk or "Ante" in zl[0]: st["straddle_ante"] += 1; continue
|
|
try: r = HS.lesen(zl)
|
|
except (ValueError, IndexError, KeyError): r = None
|
|
if not r: st["unlesbar"] += 1; continue
|
|
nr, htag, nach, h = r
|
|
if nr in eigene or ich in nach: st["eigene"] += 1; continue
|
|
m = HS.RE_RAKE.search(blk); rake = HS.zahl(m.group(1)) / 0.02 if m else 0.0
|
|
if abs(sum(h["netto"]) + rake) >= 0.6: st["unstimmig"] += 1; continue
|
|
mz = RE_ZEIT.search(zl[0]); hf = htag % 2
|
|
ende = max(s for s, i, a, z in h["akt"])
|
|
vp = {i for s, i, a, z in h["akt"] if s == 0 and a in "cr"}; pf = {i for s, i, a, z in h["akt"] if s == 0 and a == "r"}
|
|
Hh.append((tag, int(mz.group(1)) if mz else -1, ende, rake, len(nach), hf))
|
|
for i, nm in enumerate(nach):
|
|
k = KE.schluessel(nm); ki = int(k, 16); hk = (HS.kenn(nm), 1 - hf)
|
|
Pk.append(ki); Pn.append(h["netto"][i])
|
|
Pf.append((i in vp) | (i in pf) << 1 | (hk in g10) << 2 | (hk in gb) << 3 | (h["n"] > 2 and h["n"] < 7) << 4)
|
|
if ki not in namen: namen[ki] = nm
|
|
st["ok"] += 1
|
|
return (name, np.array(Hh, np.float32).reshape(-1, 6), np.array(Pk, np.uint64), np.array(Pn, np.float32),
|
|
np.array(Pf, np.int8), namen, st)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import multiprocessing as mp
|
|
HS._niedrig(); os.makedirs(AUS, exist_ok=True)
|
|
pr = int(sys.argv[1]) if len(sys.argv) > 1 else 8
|
|
nm = sorted(i.filename for i in zipfile.ZipFile(HS.ZIP).infolist())
|
|
R = {}; namen = {}; st = collections.Counter()
|
|
with mp.Pool(pr, initializer=HS._niedrig) as pool:
|
|
for j, (n, hh, pk, pn, pf, na, s) in enumerate(pool.imap_unordered(teil, nm)):
|
|
R[n] = (hh, pk, pn, pf); st.update(s)
|
|
for k, v in na.items(): namen.setdefault(k, v)
|
|
if j % 20 == 0: print(j, len(nm), dict(st), flush=True)
|
|
o = sorted(R)
|
|
hh = np.concatenate([R[n][0] for n in o]); anz = hh[:, 4].astype(np.int64)
|
|
np.savez(AUS + "haende.npz", tag=hh[:, 0].astype(np.int32), stunde=hh[:, 1].astype(np.int8), ende=hh[:, 2].astype(np.int8),
|
|
rake=hh[:, 3], n=hh[:, 4].astype(np.int8), half=hh[:, 5].astype(np.int8),
|
|
start=np.concatenate([[0], np.cumsum(anz)[:-1]]),
|
|
key=np.concatenate([R[n][1] for n in o]), netto=np.concatenate([R[n][2] for n in o]), flag=np.concatenate([R[n][3] for n in o]))
|
|
sicher.pickle_dump(namen, AUS + "namen.pkl")
|
|
print("fertig", len(hh), "Haende", int(anz.sum()), "Sitze", dict(st), flush=True)
|