Files
pokerfreak/messung/pruef/range_probe.py
T
mmintelandClaude Opus 5.5 c75a2b1863 Motor: Rust-Engine mit NL2-Regeln und Spielertypen, Pruefwerkzeuge
Regeln fuer River, Flop/Turn, Einsaetze und Iso gegen Limper (nl2.rs), Tafeln ohne Spielerkennungen.
Gemeinsam gegen den Trainer-Pool: +8,0 +-3,9 bb/100 mit bekanntem Typ, +0,9 +-6,6 ohne. Gewinn live nicht belegt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 23:51:18 +01:00

33 lines
1.8 KiB
Python

import sys,glob,json,re,subprocess,random,math
sys.path.insert(0,r'D:\Projects\pokerfreak\messung\pruef')
import slumbot as S
H=[json.loads(z) for m in (*sys.argv[1].split(',')[1:],) for f in glob.glob(r'D:\Projects\pokerfreak\messung\pruef\%s'%m) for z in open(f,encoding='utf-8')]
random.Random(1).shuffle(H)
p=subprocess.Popen(sys.argv[2:],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True,encoding='utf-8',bufsize=1)
x=[];Y=[];N=int(sys.argv[1].split(',')[0]);ab=0
for h in H:
if len(x)>=N: break
ST=int(__import__('os').environ.get('RP','2'))
if len(h['brett'])<ST+2: continue
ich=0 if h['pos']==1 else 1
t=re.findall(r'b\d+|[kcf/]',h['aktion'])
for i in range(len(t)):
if t[i]=='/': continue
z=S.zerlege(''.join(t[:i]))
if z['dran']==ich and z['st']==ST:
a,_=S.anfrage(z,h['pos'],h['loch'],h['brett'][:ST+2],0.02,1)
a['probeHand']=[S.karte(c) for c in h['bot']]
p.stdin.write(json.dumps(a)+'\n');p.stdin.flush()
w=json.loads(p.stdout.readline())
if 'logp' in w: x.append(w['logp']); Y.append((h,w,''.join(t[:i])))
else: ab+=1
break
m=sum(x)/len(x);s=math.sqrt(sum((y-m)**2 for y in x)/len(x)/len(x))
print('%d Haende (%d nicht), log-Gewinn je Hand gegen Gleichverteilung %+.4f ± %.4f; schlechteste 5%%: %.2f'%(len(x),ab,m,s,sorted(x)[len(x)//20]))
import collections
for k in ('logp','pre','eigen','preeigen'): print(k,round(sum(w[k] for _,w,_ in Y)/len(Y),3))
g=collections.defaultdict(list)
for h,w,v in Y: g[('SB ' if h['pos'] else 'BB ')+re.sub(r'b(\d+)',lambda m:'b%d'%int(m[1]),v.split('/')[0])+' | '+re.sub(r'b\d+','b','/'.join(v.split('/')[1:]))].append((w['pre'],w['logp']))
for k,l in sorted(g.items(),key=lambda x:-len(x[1]))[:22]: print('%-28s n=%4d vorflop %+.2f mit Flop %+.2f'%(k,len(l),sum(a for a,_ in l)/len(l),sum(b for _,b in l)/len(l)))