-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPokerBot.java
More file actions
3934 lines (3674 loc) · 179 KB
/
PokerBot.java
File metadata and controls
3934 lines (3674 loc) · 179 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import java.util.*;
public class PokerBot extends PokerPlayer {
private boolean opMode = false;
private PokerDeck p = new PokerDeck();
private int[][] hands = { { 14, 14 }, { 14, 13 }, { 14, 12 }, { 14, 11 }, { 14, 10 }, { 14, 9 }, { 14, 8 }, { 14, 2 },
{ 13, 13 }, { 13, 12 }, { 13, 11 }, { 13, 10 }, { 13, 9 }, { 13, 8 }, { 12, 12 }, { 12, 11 }, { 12, 10 },
{ 12, 9 }, { 12, 8 }, { 11, 11 }, { 11, 10 }, { 11, 9 }, { 11, 8 }, { 10, 10 }, { 9, 9 }, { 8, 8 }, { 7, 7 },
{ 6, 6 }, { 5, 5 }, { 4, 4 }, { 3, 3 }, { 2, 2 } }; // preset hands for smart bot
public int botLevel; // 0 = dumb, 1 = smart, 2 = god, 3 = archetype bot
public CognitiveArchetype simulatedArchetype = null; // Phase 10: archetype bot identity
private boolean cbetFlop = false; // Persistent state for barrelling logic
public static java.util.concurrent.atomic.AtomicInteger __DBG_BULLY_TOTAL = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_BULLY_RAISE = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_BULLY_CALL = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_BULLY_FOLD = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_BULLY_BET = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_BULLY_CHECK = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_FACING_BET_RAISES = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_FACING_BET_CALLS = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_FACING_BET_FOLDS = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_PRE_OPEN = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_PRE_FOLD = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_PRE_4BET = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_PRE_CALL3B = new java.util.concurrent.atomic.AtomicInteger(0);
public static java.util.concurrent.atomic.AtomicInteger __DBG_PRE_FOLD3B = new java.util.concurrent.atomic.AtomicInteger(0);
/** Zero all debug counters. Call once at the start of each verify-harness
* run so dbg_count.txt reflects only this run, not accumulation across
* multiple runs in the same JVM. */
public static void resetDebugCounters() {
__DBG_BULLY_TOTAL.set(0);
__DBG_BULLY_RAISE.set(0);
__DBG_BULLY_CALL.set(0);
__DBG_BULLY_FOLD.set(0);
__DBG_BULLY_BET.set(0);
__DBG_BULLY_CHECK.set(0);
__DBG_FACING_BET_RAISES.set(0);
__DBG_FACING_BET_CALLS.set(0);
__DBG_FACING_BET_FOLDS.set(0);
__DBG_PRE_OPEN.set(0);
__DBG_PRE_FOLD.set(0);
__DBG_PRE_4BET.set(0);
__DBG_PRE_CALL3B.set(0);
__DBG_PRE_FOLD3B.set(0);
}
private boolean predatoryIntent = false; // "Two-Faced" nightmare personality
private String baseName; // Store original name to allow tag refreshing
public enum CognitiveArchetype {
NIT,
STATION,
MANIAC,
TAG,
LAG,
ELITE_REG,
WHALE,
FISH,
BULLY,
SHORT_STACKER,
UNKNOWN
}
// PHASE 8/9: The Dual-Matrix Cognitive System (STM + LTM)
public static class CognitiveProfile {
private static final int STYLE_WINDOW = 10;
public int handsPlayed = 0;
public double ltmAlpha = 0.01; // Configurable via simulator setup
public double currentStackBB = 100.0; // Updated each hand for SHORT_STACKER detection
// STM EMA variables (alpha ~0.35, fast adaptation)
public double vpipEMA = 0.0;
public double pfrEMA = 0.0;
public double afqPreflopEMA = 0.0;
public double afqFlopEMA = 0.0;
public double afqTurnEMA = 0.0;
public double afqRiverEMA = 0.0;
public double wtsdEMA = 0.0;
public double foldToCbetEMA = 0.0;
// LTM EMA variables (alpha ~0.01, slow deep-trend)
public double ltmVpipEMA = 0.0;
public double ltmPfrEMA = 0.0;
public double ltmAfqFlopEMA = 0.0;
public double ltmAfqTurnEMA = 0.0;
public double ltmAfqRiverEMA = 0.0;
public double ltmWtsdEMA = 0.0;
// Volatility tracking
public double vIndex = 0.0;
public double styleShiftEMA = 0.0;
// Archetype state
public CognitiveArchetype archetype = CognitiveArchetype.UNKNOWN; // legacy alias
public CognitiveArchetype stmArchetype = CognitiveArchetype.UNKNOWN;
public CognitiveArchetype ltmArchetype = CognitiveArchetype.UNKNOWN;
public CognitiveArchetype finalArchetype = CognitiveArchetype.UNKNOWN;
public boolean isGearShifted = false;
// Hysteresis state — smooths classification across hands so per-hand STM jitter
// doesn't flip finalArchetype. Once an archetype is established, switching requires
// the new candidate to persist for HYSTERESIS_PENDING_HANDS consecutive calls.
private CognitiveArchetype establishedArchetype = CognitiveArchetype.UNKNOWN;
private CognitiveArchetype pendingArchetype = CognitiveArchetype.UNKNOWN;
private int pendingRunLength = 0;
private static final int HYSTERESIS_PENDING_HANDS = 3;
// Backward compatibility for Phase 5/6
public int aggressiveActions = 0;
// Per-street EV instrumentation. Tracks how many hands ended at each street
// (0=preflop, 1=flop, 2=turn, 3=river-or-showdown) and the cumulative net chips
// delta for those hands. Used by Mode 6 telemetry to identify which streets are
// leaking BB/100 — essential scaffolding for future per-archetype exploit tuning.
public final long[] handsEndedAtStreet = new long[4];
public final long[] netChipsAtStreet = new long[4];
public void recordHandEnd(int endStreet, long chipDelta) {
if (endStreet < 0 || endStreet > 3) return;
handsEndedAtStreet[endStreet]++;
netChipsAtStreet[endStreet] += chipDelta;
}
private final double[] styleHistory = new double[STYLE_WINDOW];
private int styleSamples = 0;
private int styleWriteIndex = 0;
private double lastStylePoint = 0.0;
private boolean hasLastStylePoint = false;
public double getAggressionFactor() {
if (handsPlayed == 0)
return 0.0;
double postflopBlend = getPostflopAFqBlend();
double legacy = (double) aggressiveActions / Math.max(1, handsPlayed);
return clamp01((pfrEMA * 0.35) + (postflopBlend * 0.50) + (legacy * 0.15));
}
private double clamp01(double v) {
return Math.max(0.0, Math.min(1.0, v));
}
private double getPostflopAFqBlend() {
return (afqFlopEMA + afqTurnEMA + afqRiverEMA) / 3.0;
}
private double getPostflopAFqBlendLTM() {
return (ltmAfqFlopEMA + ltmAfqTurnEMA + ltmAfqRiverEMA) / 3.0;
}
private double getStylePoint() {
double postAFq = getPostflopAFqBlend();
double aggressionBlend = (pfrEMA + postAFq) / 2.0;
double showdownStickiness = (wtsdEMA + (1.0 - foldToCbetEMA)) / 2.0;
return clamp01((vpipEMA * 0.40) + (pfrEMA * 0.30) + (aggressionBlend * 0.20) + (showdownStickiness * 0.10));
}
private void observeStyleAndVolatility() {
double stylePoint = getStylePoint();
if (hasLastStylePoint) {
double handShift = Math.abs(stylePoint - lastStylePoint);
styleShiftEMA = (0.35 * handShift) + (0.65 * styleShiftEMA);
}
lastStylePoint = stylePoint;
hasLastStylePoint = true;
styleHistory[styleWriteIndex] = stylePoint;
styleWriteIndex = (styleWriteIndex + 1) % STYLE_WINDOW;
if (styleSamples < STYLE_WINDOW)
styleSamples++;
if (styleSamples <= 1) {
vIndex = 0.0;
return;
}
double mean = 0.0;
for (int i = 0; i < styleSamples; i++)
mean += styleHistory[i];
mean /= styleSamples;
double variance = 0.0;
for (int i = 0; i < styleSamples; i++) {
double d = styleHistory[i] - mean;
variance += d * d;
}
variance /= styleSamples;
vIndex = Math.sqrt(Math.max(0.0, variance));
}
// Archetype classifier — thresholds calibrated to actual Mode 6 telemetry
// measurements (5000-pair runs, exploits enabled).
//
// Reference Arc-bot stat ranges (measured):
// NIT: VPIP 0.12, PFR 0.03, flopAFq 0.00 (never bets postflop)
// TAG: VPIP 0.31, PFR 0.25, flopAFq 0.45-0.51 (bets only paired hands)
// LAG: VPIP 0.31, PFR 0.22, flopAFq 0.84-0.89 (bets ~67%, barrels wide)
// BULLY: VPIP 0.25, PFR 0.25, flopAFq 0.99 (bets 100%, overbets)
// MANIAC: VPIP 0.40, PFR 0.40, flopAFq 0.95 (bets every street)
//
// Disambiguation:
// MANIAC vs BULLY: both have flopAFq ≥ 0.95. MANIAC has VPIP ≥ 0.40 (loose).
// BULLY vs LAG: BULLY flopAFq ≥ 0.95, LAG flopAFq 0.65-0.95.
// LAG vs TAG: LAG flopAFq ≥ 0.65, TAG flopAFq < 0.65.
private CognitiveArchetype classifyArchetype(double vpip, double pfr, double totalAFq,
double postflopAFq, double wtsd, boolean useStack) {
double flopAFq = useStack ? afqFlopEMA : ltmAfqFlopEMA;
return classifyArchetype(vpip, pfr, totalAFq, postflopAFq, flopAFq, wtsd, useStack);
}
private CognitiveArchetype classifyArchetype(double vpip, double pfr, double totalAFq,
double postflopAFq, double flopAFq, double wtsd, boolean useStack) {
// Thresholds calibrated against measured Arc-bot stats at 200k+ hands (50k-pair Mode 6).
// See classifierTrace output for ground truth measurements.
// RECALIBRATED 2026-05 from confusion-matrix audit (5 trials × 9 archetypes,
// 50k pairs each). Old rule order/thresholds had MANIAC at 0%, TAG at 0%,
// BULLY at 40%. Key fixes:
// - SS rule capped at vpip < 0.40 (was unbounded, absorbing MANIAC).
// - MANIAC rule no longer requires flopAFq >= 0.85 (HU vs aggressive
// opponents prevents MANIAC reaching flop, so flopAFq registers as 0).
// - TAG/LAG flopAFq boundary moved 0.50 → 0.62 (TAG measures 0.45-0.55).
// MANIAC: enters with raise (vpip ≈ pfr), VPIP wide (≥ 0.40 — distinguishes
// from SS's narrow push-fold range), low WTSD. flopAFq dropped from rule
// because MANIAC's pots end preflop most of the time in tough HU matchups,
// leaving postflop AFq unmeasured (0.0).
if (vpip >= 0.40 && pfr >= 0.30 && Math.abs(vpip - pfr) < 0.15 && wtsd <= 0.20)
return CognitiveArchetype.MANIAC;
// SHORT_STACKER (behavioral): vpip ≈ pfr, no postflop, low WTSD (no showdowns).
// VPIP capped < 0.40 (above that we're looking at MANIAC, not push-fold).
// WTSD ≤ 0.20 separates SS (folds out preflop) from low-VPIP NITs (call down,
// WTSD ~0.40+).
if (handsPlayed > 10 && Math.abs(vpip - pfr) < 0.05
&& vpip >= 0.10 && vpip < 0.40 && postflopAFq <= 0.05 && wtsd <= 0.20)
return CognitiveArchetype.SHORT_STACKER;
// SHORT_STACKER (stack-based): only fires when behavior ALSO matches (vpip ≈ pfr).
// Without the behavioral check, Mode 7's 20 BB starting stacks misclassify EVERYONE
// as SS. Adding the vpip ≈ pfr requirement ensures only true push-fold players match.
if (useStack && handsPlayed > 10 && currentStackBB < 25.0
&& Math.abs(vpip - pfr) < 0.05 && vpip >= 0.10 && postflopAFq <= 0.10)
return CognitiveArchetype.SHORT_STACKER;
// NIT: very tight, never bets postflop.
if (vpip <= 0.18 && pfr <= 0.10 && postflopAFq <= 0.10)
return CognitiveArchetype.NIT;
// BULLY: very high flopAFq (≥ 0.85) — overbets every flop. flopAFq is more
// stable than the F/T/R blend because BULLY may not reach turn/river often
// (overbets force folds), so blend value drifts. Drop vpip floor since
// measured BULLY vpip dips to 0.15 in HU vs aggressive opponents. pfr < 0.45
// separates from MANIAC (vpip ≈ pfr ≥ 0.45).
if (flopAFq >= 0.85 && pfr >= 0.10 && pfr < 0.45)
return CognitiveArchetype.BULLY;
// LAG: heavier flop aggression but below BULLY's ceiling. Boundary at 0.65
// (was 0.62, but TAG's measured flopAFq peaks at ~0.63, causing TAG → LAG).
if (flopAFq >= 0.65 && flopAFq < 0.85 && vpip >= 0.10 && pfr >= 0.10)
return CognitiveArchetype.LAG;
// FISH and WHALE share "loose-passive, never bets" profile (PFR ≈ 0, low postflop AFq)
// but their CALLING patterns differ:
// WHALE: VPIP ≥ 0.35, calls EVERYTHING postflop including big bets (inelastic to size)
// FISH: VPIP 0.18-0.35, calls small bets but folds to big bets on flop, folds turn/river air
// Distinct exploit logic (overbet vs WHALE, sizing-based bluff vs FISH) made splitting worth it.
// WHALE: very loose preflop, never raises, never bets postflop.
if (vpip >= 0.35 && pfr <= 0.10 && postflopAFq < 0.30)
return CognitiveArchetype.WHALE;
// FISH: moderately loose preflop (looser than NIT, tighter than WHALE), passive.
if (vpip >= 0.18 && vpip < 0.35 && pfr <= 0.10 && postflopAFq < 0.30)
return CognitiveArchetype.FISH;
// STATION: catch-all loose-passive (broader pfr range than FISH/WHALE, e.g.,
// a human who limps a lot but occasionally raises). Distinct from FISH/WHALE
// mostly via PFR and slightly higher postflop AFq tolerance.
if (vpip >= 0.20 && pfr <= 0.18 && postflopAFq < 0.40)
return CognitiveArchetype.STATION;
// TAG: moderate stats, mid aggression, flopAFq < 0.65 (boundary with LAG).
if (vpip >= 0.15 && vpip < 0.50 && pfr >= 0.05 && pfr < 0.40 && flopAFq < 0.65)
return CognitiveArchetype.TAG;
return CognitiveArchetype.UNKNOWN;
}
private void refreshArchetype() {
double stmPostAFq = getPostflopAFqBlend();
double stmTotalAFq = (pfrEMA + stmPostAFq) / 2.0;
double ltmPostAFq = getPostflopAFqBlendLTM();
double ltmTotalAFq = (ltmPfrEMA + ltmPostAFq) / 2.0;
stmArchetype = classifyArchetype(vpipEMA, pfrEMA, stmTotalAFq, stmPostAFq, wtsdEMA, true);
ltmArchetype = classifyArchetype(ltmVpipEMA, ltmPfrEMA, ltmTotalAFq, ltmPostAFq, ltmWtsdEMA, false);
// ELITE_REG promotion REMOVED (deprecated 2026-05).
// ELITE_REG was meant to identify stable TAG-pattern players with elevated
// volatility, triggering conservative GTO baseline play (gtoFallback). The
// signal proved unreliable in practice — TAG-mimic strategy now handles
// tight aggressive opponents, and gtoFallback is preserved for Pure GTO
// mode usage only.
// Normalized Euclidean Distance (3-stat) — measures STM's deviation from LTM trend
double dVpip = vpipEMA - ltmVpipEMA;
double dPfr = pfrEMA - ltmPfrEMA;
double dAFq = stmTotalAFq - ltmTotalAFq;
double distance = Math.sqrt((dVpip * dVpip + dPfr * dPfr + dAFq * dAFq) / 3.0);
double dynamicThreshold = 0.15 + (vIndex * 1.5);
// Candidate archetype: prefer LTM after warmup (LTM is more stable). Before
// warmup, fall back to STM (LTM hasn't accumulated enough updates).
// Note: empirically LTM AFq under-converges in Mode 6 duels (only ~1200 updates
// for a bot in 10k hands), so STM is often more accurate. Use STM after 30 hands.
CognitiveArchetype candidate;
if (handsPlayed >= 30) {
// STM is well-converged (alpha 0.35 → 99% in ~12 updates). Trust STM unless
// it's UNKNOWN, in which case fall back to LTM.
candidate = (stmArchetype != CognitiveArchetype.UNKNOWN) ? stmArchetype : ltmArchetype;
isGearShifted = (candidate == stmArchetype && distance >= dynamicThreshold);
} else if (distance < dynamicThreshold) {
candidate = ltmArchetype;
isGearShifted = false;
} else {
candidate = stmArchetype;
isGearShifted = true;
}
// HYSTERESIS: prevent per-hand classification flips.
// - If candidate matches established → keep established.
// - If candidate matches pending → increment pendingRunLength; promote when threshold hit.
// - If candidate is something new → reset pending to candidate (length 1).
if (candidate == establishedArchetype) {
pendingArchetype = CognitiveArchetype.UNKNOWN;
pendingRunLength = 0;
} else if (candidate == pendingArchetype) {
pendingRunLength++;
if (pendingRunLength >= HYSTERESIS_PENDING_HANDS) {
establishedArchetype = pendingArchetype;
pendingArchetype = CognitiveArchetype.UNKNOWN;
pendingRunLength = 0;
}
} else {
pendingArchetype = candidate;
pendingRunLength = 1;
}
// First-time establishment: if no established yet, accept candidate immediately.
if (establishedArchetype == CognitiveArchetype.UNKNOWN) {
establishedArchetype = candidate;
}
finalArchetype = establishedArchetype;
archetype = finalArchetype; // keep legacy field in sync
}
// EMA update — maintains both STM (fast alpha) and LTM (slow ltmAlpha).
public void updateEMA(String stat, double value, double alpha) {
switch (stat) {
case "VPIP":
vpipEMA = (alpha * value) + ((1 - alpha) * vpipEMA);
ltmVpipEMA = (ltmAlpha * value) + ((1 - ltmAlpha) * ltmVpipEMA);
break;
case "PFR":
pfrEMA = (alpha * value) + ((1 - alpha) * pfrEMA);
ltmPfrEMA = (ltmAlpha * value) + ((1 - ltmAlpha) * ltmPfrEMA);
break;
case "AFq_Preflop":
afqPreflopEMA = (alpha * value) + ((1 - alpha) * afqPreflopEMA);
break;
case "AFq_Flop":
afqFlopEMA = (alpha * value) + ((1 - alpha) * afqFlopEMA);
ltmAfqFlopEMA = (ltmAlpha * value) + ((1 - ltmAlpha) * ltmAfqFlopEMA);
break;
case "AFq_Turn":
afqTurnEMA = (alpha * value) + ((1 - alpha) * afqTurnEMA);
ltmAfqTurnEMA = (ltmAlpha * value) + ((1 - ltmAlpha) * ltmAfqTurnEMA);
break;
case "AFq_River":
afqRiverEMA = (alpha * value) + ((1 - alpha) * afqRiverEMA);
ltmAfqRiverEMA = (ltmAlpha * value) + ((1 - ltmAlpha) * ltmAfqRiverEMA);
break;
case "WTSD":
wtsdEMA = (alpha * value) + ((1 - alpha) * wtsdEMA);
ltmWtsdEMA = (ltmAlpha * value) + ((1 - ltmAlpha) * ltmWtsdEMA);
break;
case "FoldToCBet":
foldToCbetEMA = (alpha * value) + ((1 - alpha) * foldToCbetEMA);
break;
default:
break;
}
observeStyleAndVolatility();
refreshArchetype();
}
public void updatePreflopTelemetry(boolean vpip, boolean pfr, double alpha) {
updateEMA("VPIP", vpip ? 1.0 : 0.0, alpha);
updateEMA("PFR", pfr ? 1.0 : 0.0, alpha);
}
public CognitiveArchetype getArchetype() {
return finalArchetype;
}
public String getArchetypeLabel() {
return finalArchetype.name() + (isGearShifted ? "*" : "");
}
/** Diagnostic: returns a single-line trace of this profile's classifier inputs and outputs. */
public String classifierTrace(String name) {
double stmAfqMean = (afqFlopEMA + afqTurnEMA + afqRiverEMA) / 3.0;
double ltmAfqMean = (ltmAfqFlopEMA + ltmAfqTurnEMA + ltmAfqRiverEMA) / 3.0;
return String.format(
"[CLASSIFIER] name=%s hands=%d ltmAlpha=%.5f stm{vpip=%.3f pfr=%.3f afq=%.3f flop=%.3f turn=%.3f river=%.3f}=%s ltm{vpip=%.3f pfr=%.3f afq=%.3f flop=%.3f turn=%.3f river=%.3f}=%s final=%s gearShift=%s",
name, handsPlayed, ltmAlpha,
vpipEMA, pfrEMA, stmAfqMean, afqFlopEMA, afqTurnEMA, afqRiverEMA, stmArchetype.name(),
ltmVpipEMA, ltmPfrEMA, ltmAfqMean, ltmAfqFlopEMA, ltmAfqTurnEMA, ltmAfqRiverEMA, ltmArchetype.name(),
finalArchetype.name(), isGearShifted);
}
}
/** Diagnostic: dump classifier traces for all tracked profiles to stderr. */
public static void dumpClassifierTrace() {
java.util.Map<String, CognitiveProfile> db = getCognitiveDB();
if (db == null || db.isEmpty()) return;
System.err.println("=== CLASSIFIER TRACE (" + db.size() + " profiles) ===");
for (java.util.Map.Entry<String, CognitiveProfile> e : db.entrySet()) {
System.err.println(e.getValue().classifierTrace(e.getKey()));
}
}
// Smart-bot specific leak profile for God's heads-up exploitation.
public static class SmartLeakProfile {
private static final double ALPHA = 0.30;
public int huSamples = 0;
public double foldTo3BetHUEMA = 0.50;
public double foldToFlopCbetHUEMA = 0.50;
public double foldToTurnBarrelHUEMA = 0.50;
public double foldToRiverLargeBetHUEMA = 0.50;
public double checkBackTurnHUEMA = 0.50;
public double raiseVsCbetHUEMA = 0.30;
public double onePairCallDownHUEMA = 0.50;
private double ema(double current, double observation) {
return (ALPHA * observation) + ((1.0 - ALPHA) * current);
}
public void observeFoldTo3Bet(boolean folded) {
huSamples++;
foldTo3BetHUEMA = ema(foldTo3BetHUEMA, folded ? 1.0 : 0.0);
}
public void observeFlopCbetResponse(boolean folded, boolean raised) {
huSamples++;
foldToFlopCbetHUEMA = ema(foldToFlopCbetHUEMA, folded ? 1.0 : 0.0);
raiseVsCbetHUEMA = ema(raiseVsCbetHUEMA, raised ? 1.0 : 0.0);
}
public void observeTurnBarrelResponse(boolean folded) {
huSamples++;
foldToTurnBarrelHUEMA = ema(foldToTurnBarrelHUEMA, folded ? 1.0 : 0.0);
}
public void observeRiverLargeBetResponse(boolean folded) {
huSamples++;
foldToRiverLargeBetHUEMA = ema(foldToRiverLargeBetHUEMA, folded ? 1.0 : 0.0);
}
public void observeTurnCheckBack(boolean checkedBack) {
huSamples++;
checkBackTurnHUEMA = ema(checkBackTurnHUEMA, checkedBack ? 1.0 : 0.0);
}
}
private static final ThreadLocal<Map<String, CognitiveProfile>> cognitiveDBLocal = ThreadLocal
.withInitial(HashMap::new);
private static final ThreadLocal<Map<String, SmartLeakProfile>> smartLeakDBLocal = ThreadLocal
.withInitial(HashMap::new);
public static boolean testLearnFromBots = false; // Enables telemetry learning from Dumb/Smart bots for testing.
public static Map<String, CognitiveProfile> getCognitiveDB() {
return cognitiveDBLocal.get();
}
public static void resetThreadCognitiveDB() {
cognitiveDBLocal.set(new HashMap<>());
smartLeakDBLocal.set(new HashMap<>());
}
public static void clearThreadCognitiveDB() {
cognitiveDBLocal.remove();
smartLeakDBLocal.remove();
}
public static Map<String, SmartLeakProfile> getSmartLeakDB() {
return smartLeakDBLocal.get();
}
public static SmartLeakProfile getOrCreateSmartLeakProfile(String playerName) {
Map<String, SmartLeakProfile> db = getSmartLeakDB();
db.putIfAbsent(playerName, new SmartLeakProfile());
return db.get(playerName);
}
public static void observeSmartFoldTo3BetHU(String playerName, boolean folded) {
getOrCreateSmartLeakProfile(playerName).observeFoldTo3Bet(folded);
}
public static void observeSmartFlopCbetResponseHU(String playerName, boolean folded, boolean raised) {
getOrCreateSmartLeakProfile(playerName).observeFlopCbetResponse(folded, raised);
}
public static void observeSmartTurnBarrelResponseHU(String playerName, boolean folded) {
getOrCreateSmartLeakProfile(playerName).observeTurnBarrelResponse(folded);
}
public static void observeSmartRiverLargeBetResponseHU(String playerName, boolean folded) {
getOrCreateSmartLeakProfile(playerName).observeRiverLargeBetResponse(folded);
}
public static void observeSmartTurnCheckBackHU(String playerName, boolean checkedBack) {
getOrCreateSmartLeakProfile(playerName).observeTurnCheckBack(checkedBack);
}
public static CognitiveProfile getOrCreateCognitiveProfile(String playerName) {
Map<String, CognitiveProfile> db = getCognitiveDB();
db.putIfAbsent(playerName, new CognitiveProfile());
return db.get(playerName);
}
public static void updatePreflopTelemetryTracked(String playerName, boolean vpip, boolean pfr, double alpha) {
CognitiveProfile profile = getOrCreateCognitiveProfile(playerName);
CognitiveArchetype before = profile.getArchetype();
profile.handsPlayed++;
profile.updatePreflopTelemetry(vpip, pfr, alpha);
CognitiveArchetype after = profile.getArchetype();
BotDiagnostics.recordArchetypeShift(playerName, before, after, profile, "preflopTelemetry");
BotDiagnostics.recordProfileSnapshot(playerName, profile, "preflopTelemetry");
}
public static void updateCognitiveStatTracked(String playerName, String stat, double value, double alpha) {
CognitiveProfile profile = getOrCreateCognitiveProfile(playerName);
CognitiveArchetype before = profile.getArchetype();
profile.updateEMA(stat, value, alpha);
CognitiveArchetype after = profile.getArchetype();
BotDiagnostics.recordArchetypeShift(playerName, before, after, profile, stat);
BotDiagnostics.recordProfileSnapshot(playerName, profile, stat);
}
public static CognitiveArchetype getTrackedArchetype(String playerName) {
CognitiveProfile profile = getCognitiveDB().get(playerName);
if (profile == null)
return CognitiveArchetype.UNKNOWN;
return profile.getArchetype();
}
private boolean revealTags = false; // Persistent memory for trigger detection
private boolean nightmareActive = false; // Persistent memory for nightmare mode
private boolean protectedMode = false; // "Protected Mode": Strips exploits for pure GTO testing
private boolean neuralProtectedMode = false; // Simulator-only neural sandbox (valid only with Protected Mode)
private int nightmareIntensity = 2; // Fixed adaptive nightmare mode
// ============================================================================
// PER-ARCHETYPE EXPLOIT KILL-SWITCHES (Neural Sandbox only)
// Each branch can be toggled independently for A/B verification at 50k pairs.
// Flip to false to revert that specific exploit; recompile to apply.
// ============================================================================
// TAG (tells: bets 65% pot only with pair, never bluffs, folds air to overbet)
private static final boolean EXPLOIT_TAG_FOLD_TO_BET = true;
private static final boolean EXPLOIT_TAG_BLUFF_OVERBET_VS_CHECK = true;
private static final boolean EXPLOIT_TAG_NO_THIN_VALUE = true;
// BULLY (tells: always overbets 120% pot, re-raises 50% facing bets)
private static final boolean EXPLOIT_BULLY_NEVER_CBET = false;
private static final boolean EXPLOIT_BULLY_CHECK_RAISE_TOP_PAIR = true;
private static final boolean EXPLOIT_BULLY_FOLD_AIR = true;
// TIGHTEN_PRE disabled: BULLY-counter preflop hard counter (4-bet QQ+, fold marginal vs
// 3-bet) handles defense. Tightening open in SB just costs blinds when BULLY folds.
private static final boolean EXPLOIT_BULLY_TIGHTEN_PRE = false;
// LAG (tells: 50%-pot=bluff, 70%-pot=value, check-raises 45% with strong)
// 3BET_SMALL_BET / BIG_BET_RESPONSE: disabled — narrow defensive overlays both regressed
// at 50k pairs (Forcing fold air to LAG value bets removes Pure GTO's calling overlay
// on backdoor equity; raising small bets builds pots that resolve worse on later streets.)
// TIGHTEN_PRE: enabled — Neural Sandbox's spicy preflop opens (wheelAce, faceCards, mixed)
// open ~50% width vs LAG's heavy aggression. Tighten to ~25% baseline to stop the bleed.
private static final boolean EXPLOIT_LAG_3BET_SMALL_BET = false;
private static final boolean EXPLOIT_LAG_BIG_BET_RESPONSE = false;
// LAG_TIGHTEN_PRE disabled: same logic as BULLY — preflop hard counter handles defense
// vs 3-bet, tightening opens just bleeds blinds when LAG folds (~65% of hands).
private static final boolean EXPLOIT_LAG_TIGHTEN_PRE = false;
// SHORT_STACKER (tell: shoves every postflop decision)
private static final boolean EXPLOIT_SS_TIGHT_OPEN = false;
// TAG: TAG only 3-bets ~5% (premiums). We can OPEN WIDER vs TAG since they fold 75%
// to opens AND rarely punish marginal opens. Gain blinds via fold equity.
private static final boolean EXPLOIT_TAG_WIDE_OPEN = true;
// Arc-mimic strategies: when our analytical counters can't beat the structural
// edge of an Arc-bot's deterministic play, just BORROW the Arc-bot's playbook.
// Ground-truth from Arc-vs-Arc tests (50k pairs each):
// Arc-TAG vs Arc-BULLY: +91.7 BB/100 (TAG wins big)
// Arc-TAG vs Arc-LAG: +17.5 BB/100 (TAG wins)
// Arc-NIT vs Arc-TAG: -12 BB/100 (NIT loses only ~12 to TAG vs God's -65)
// Split into preflop/postflop because NIT-mimic preflop is tight discipline (good)
// but NIT-mimic postflop never bets — leaves money on table since TAG folds 95%
// of postflop hands without pair. Hybrid: NIT preflop + existing TAG counter postflop.
private static final boolean EXPLOIT_NIT_MIMIC_VS_TAG_PRE = true;
private static final boolean EXPLOIT_NIT_MIMIC_VS_TAG_POST = false; // hybrid: keep TAG counter postflop
private static final boolean EXPLOIT_TAG_MIMIC_VS_AGGRESSIVE = true; // BULLY/LAG
public PokerBot(PokerPlayer[] currentPlayers) {
super("temp");
randomName(currentPlayers);
double r = SimRng.nextDouble();
if (r < 0.44)
botLevel = 0;
else if (r < 0.88)
botLevel = 1;
else
botLevel = 2;
this.baseName = super.getName();
refreshNameTag(currentPlayers);
if (super.getName().contains("Aventurine")) {
opMode = true;
}
}
public void refreshNameTag(PokerPlayer[] playersForNightmareCheck) {
// Trigger Check: Only update global state if a player list is provided
if (playersForNightmareCheck != null) {
this.revealTags = false;
this.nightmareActive = false;
for (PokerPlayer p : playersForNightmareCheck) {
if (p != null) {
if ("edj".equalsIgnoreCase(p.getName()) || "edjiang1234".equalsIgnoreCase(p.getName())) {
this.revealTags = true;
}
if ("edjiang1234".equalsIgnoreCase(p.getName())) {
this.nightmareActive = true;
if (botLevel != 2) {
botLevel = 2; // Sync level if nightmare triggered
predatoryIntent = (SimRng.nextDouble() < 0.5);
}
}
}
}
}
String tag = "";
if (this.revealTags) {
if (botLevel == 0)
tag = " [D]";
else if (botLevel == 1)
tag = " [S]";
else if (botLevel == 3) {
tag = (simulatedArchetype != null) ? " [ARC-" + simulatedArchetype.name() + "]" : " [ARC]";
} else {
if (this.nightmareActive) {
tag = predatoryIntent ? " [G-B]" : " [G-S]";
} else {
tag = " [G]";
}
}
}
super.setName(this.baseName + tag);
}
public PokerBot() {
this(null);
}
/** Phase 10: Centralized live game spawning tree (God bots and 7-Archetypes) */
public static PokerBot createLiveGameBot(PokerPlayer[] currentPlayers) {
PokerBot newBot = new PokerBot(currentPlayers);
double spawnRoll = SimRng.nextDouble();
if (spawnRoll < 0.40) {
// 40% chance: spawn a God Bot (via the randomized spawning tree)
newBot.setBotLevel(2);
double godRoll = SimRng.nextDouble();
if (godRoll < 0.50) {
// 50% Protected
newBot.setProtectedMode(true);
if (SimRng.nextDouble() < 0.50) {
newBot.setNeuralProtectedMode(false); // Protected + No Cognition = ELITE_REG-like
} else {
newBot.setNeuralProtectedMode(true); // Protected + Cognitive Matrix
}
} else {
// 50% Unprotected
newBot.setProtectedMode(false);
if (SimRng.nextDouble() >= 0.33) {
// Nightmare Mode (Bold or Sneaky)
newBot.setNightmareIntensity(2);
newBot.setNightmareActive(true);
newBot.setPredatoryIntent(SimRng.nextDouble() < 0.50);
}
}
} else {
// 60% chance: spawn a random archetype bot (7 archetypes, excluding SHORT_STACKER)
CognitiveArchetype[] archetypePool = {
CognitiveArchetype.NIT, CognitiveArchetype.MANIAC, CognitiveArchetype.STATION,
CognitiveArchetype.TAG, CognitiveArchetype.WHALE, CognitiveArchetype.FISH, CognitiveArchetype.BULLY,
CognitiveArchetype.LAG
};
CognitiveArchetype chosen = archetypePool[(int)(SimRng.nextDouble() * archetypePool.length)];
newBot.setBotLevel(3);
newBot.setSimulatedArchetype(chosen);
newBot.setProtectedMode(false);
}
newBot.refreshNameTag(currentPlayers);
return newBot;
}
public void randomName(PokerPlayer[] currentPlayers) {
super.setName(Names.getUniqueName(currentPlayers));
}
public void randomName() {
randomName(null);
}
public int getBotLevel() {
return botLevel;
}
public void setBotLevel(int level) {
this.botLevel = level;
if (level == 2 && !protectedMode)
predatoryIntent = (SimRng.nextDouble() < 0.5); // Re-roll intent for promoted gods (disable if protected)
refreshNameTag(null);
}
/** Phase 10: Set the simulated archetype for a botLevel 3 archetype bot. */
public void setSimulatedArchetype(CognitiveArchetype archetype) {
this.simulatedArchetype = archetype;
}
public void setProtectedMode(boolean val) {
this.protectedMode = val;
if (val) {
predatoryIntent = false; // Immediately disable aggression
} else {
neuralProtectedMode = false; // Hard guard: neural sandbox cannot survive outside protected mode.
}
refreshNameTag(null);
}
public void setNeuralProtectedMode(boolean enabled) {
// Neural sandbox is constrained to Protected Mode by design.
this.neuralProtectedMode = enabled && this.protectedMode;
}
public boolean isNeuralProtectedMode() {
return protectedMode && neuralProtectedMode;
}
private boolean neuralSandboxEnabled() {
return protectedMode && neuralProtectedMode;
}
public void setNightmareIntensity(int val) {
this.nightmareIntensity = 2;
}
/** Phase 10: Directly set predatory intent for God Bot spawning tree. */
public void setPredatoryIntent(boolean val) {
this.predatoryIntent = val;
}
/** Phase 10: Directly activate nightmare mode for God Bot spawning tree. */
public void setNightmareActive(boolean val) {
this.nightmareActive = val;
if (val && botLevel != 2) botLevel = 2;
}
public int getNightmareIntensity() {
return nightmareIntensity;
}
private void trace(String stage, String message) {
if (!BotDiagnostics.traceConsoleEnabled()) {
return;
}
System.out.println("[BOT TRACE][" + super.getName() + "][" + stage + "] " + message);
}
private String cardsToString(Card[] cards) {
if (cards == null || cards.length == 0)
return "(none)";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < cards.length; i++) {
if (cards[i] == null)
continue;
if (sb.length() > 0)
sb.append(" ");
sb.append(cards[i].getValue());
}
return sb.length() == 0 ? "(none)" : sb.toString();
}
private String actionLabel(int actionCode) {
switch (actionCode) {
case 1:
return "CALL/CHECK";
case 2:
return "FOLD";
case 3:
return "BET/RAISE";
case 4:
return "ALL-IN";
default:
return "UNKNOWN";
}
}
private void traceTableState(String stage, PokerPlayer[] players, Card[] board, int seatIndex) {
if (players == null)
return;
String boardText = (board == null) ? "(preflop)" : cardsToString(board);
trace(stage, "TABLE SNAPSHOT | board=" + boardText + ", seatIndex=" + seatIndex);
for (int i = 0; i < players.length; i++) {
PokerPlayer pl = players[i];
if (pl == null)
continue;
String marker = (i == seatIndex) ? " <- ACTING" : "";
trace(stage,
"seat=" + i + ", name=" + pl.getName() + ", inHand=" + pl.inHand() + ", chips=" + pl.getChips()
+ ", hole=" + cardsToString(pl.getHand()) + marker);
}
}
// funny
public void checkName() {
if (super.getName().equals("Aventurine")) {
opMode = true;
}
}
public int[] action(String round, int prevBet, int bet, int blind, int lastRaise, Card[] board, int potSize,
PokerPlayer[] players, int seatIndex, int preflopAggressorIndex, int sbIdx, int bbIdx) {
int tablePlayers = 0;
for (PokerPlayer p : players)
if (p.getChips() > 0)
tablePlayers++;
boolean headsUpTable = (tablePlayers == 2);
int activeCount = 0;
for (PokerPlayer p : players)
if (p.inHand())
activeCount++;
boolean headsUpHand = (activeCount == 2);
String stage = "ACTION-" + round.toUpperCase();
if (botLevel == 1 || botLevel == 2) {
trace(stage,
"ENTER | level=" + botLevel + ", hole=" + cardsToString(super.getHand()) + ", prevBet=" + prevBet
+ ", tableBet=" + bet + ", blind=" + blind + ", lastRaise=" + lastRaise + ", pot=" + potSize
+ ", headsUpTable=" + headsUpTable + ", headsUpHand=" + headsUpHand);
traceTableState(stage, players, board, seatIndex);
}
if (botLevel == 3) {
if (round.equals("preflop")) {
return archetypePreflop(prevBet, bet, blind, lastRaise, players, seatIndex);
} else {
return archetypePostflop(prevBet, bet, blind, potSize, board, players, seatIndex);
}
}
if (botLevel == 2) {
if (round.equals("preflop")) {
return godPreflop(prevBet, bet, blind, lastRaise, players, seatIndex, sbIdx, bbIdx);
} else {
return godPostflop(prevBet, bet, blind, lastRaise, board, potSize, players, seatIndex, preflopAggressorIndex,
sbIdx, bbIdx);
}
} else if (botLevel == 0) { // idiot bot code, fixed percentages for all situations no matter what
int[] action = new int[2];
double rand = SimRng.nextDouble();
if (opMode && super.getChips() > 0) {
action[0] = 4;
action[1] = super.getChips();
} else if (bet < super.getChips()) {
if (rand >= 0 && rand < 0.75) { // 75% chance to call
action[0] = 1;
if (bet > 0) {
action[1] = (bet >= super.getChips()) ? super.getChips() : bet - prevBet;
} else
action[1] = (bet == 0) ? 0 : bet - prevBet;
} else if (rand >= 0.75 && rand < 0.85) { // 10% chance to raise
if (((bet == 0) ? blind : bet + blind) + super.getChips() / 10 < super.getChips()) {
// however, only raises if the bet meets certain conditions
int max;
int min;
if (round.equals("preflop")) {
max = super.getChips() / 10 + bet + lastRaise;
min = bet + lastRaise;
} else {
if (bet == 0) {
max = super.getChips() / 10 + lastRaise;
min = lastRaise;
} else {
max = super.getChips() / 10 + bet + lastRaise;
min = bet + lastRaise;
}
}
action[0] = 3;
int raiseTo = (int) (SimRng.nextDouble() * (max - min + 1) + min);
action[1] = raiseTo - prevBet;
} else {
// if those "conditions" are not met, then has 15% to continue and all in the
// current bet, otherwise folds.
if (SimRng.nextDouble() > 0.85) {
action[0] = 4;
action[1] = super.getChips();
} else {
action[0] = 2;
}
}
} else if (rand >= 0.85 && rand < 0.97) { // 12% chance to call/fold
action[0] = (bet == 0) ? 1 : 2;
} else { // 3% chance to all in
action[0] = 4;
action[1] = super.getChips();
}
} else {
// Dumb Bot Extinction Rule: 50% Call, 50% Fold
if (SimRng.nextDouble() < 0.5) {
action[0] = 4;
action[1] = super.getChips();
} else {
action[0] = 2;
action[1] = 0;
}
}
return action;
} else { // intelligent bot code, varying percentages based on current siutation
int[] action = new int[2];
if (round.equals("preflop")) {
/*
* stack, otherwise, has a 80% chance to call and 20% chance of folding.
* for the former, 20% chance to raise, 80% chance to call.
* if hand is out of range, has a 25% chance to call and 75% chance of folding.
*/
boolean isHand = false;
String smartReason = "preflop-default";
trace("SMART-PREFLOP",
"START | hole=" + cardsToString(super.getHand()) + ", prevBet=" + prevBet + ", tableBet=" + bet
+ ", lastRaise=" + lastRaise + ", stack=" + super.getChips() + ", headsUpTable=" + headsUpTable);
for (int[] h : hands) {
if (Arrays.equals(Deck.cardToInt(super.getHand()), h)) {
isHand = true;
if (bet < super.getChips() / 2) {
if (SimRng.nextDouble() < 0.2) {
smartReason = "in-range hand + affordable pressure lane => raise";
action[0] = 3;
int raiseTo = (bet == 0) ? (int) (blind * (SimRng.nextDouble() + 2)) : (int) (bet * (SimRng.nextDouble() + 2));
raiseTo = Math.max(raiseTo, bet + lastRaise); // Standardized Floor
action[1] = Math.min(raiseTo - prevBet, super.getChips());
} else {
smartReason = "in-range hand + affordable pressure lane => call";
action[0] = 1;
if (bet > 0) {
action[1] = (bet >= super.getChips()) ? super.getChips() : bet - prevBet;
} else
action[1] = (bet == 0) ? 0 : bet - prevBet;
}
} else {
if (SimRng.nextDouble() < 0.8) {
smartReason = "in-range hand + expensive bet => defensive call";
action[0] = 1;
if (bet > 0) {
action[1] = (bet >= super.getChips()) ? super.getChips() : bet - prevBet;
} else
action[1] = (bet == 0) ? 0 : bet - prevBet;
} else {
smartReason = "in-range hand + expensive bet => disciplined fold";
action[0] = 2;
}
}
break;
}
}
if (!isHand) {
double callAirFreq = (headsUpTable) ? 0.70 : 0.25;
int[] cardInts = Deck.cardToInt(super.getHand());
if (headsUpTable && (cardInts[0] >= 12 || cardInts[1] >= 12))
callAirFreq = 1.0; // Play any Q+ preflop 1v1
if (bet < super.getChips() / 2 && SimRng.nextDouble() < callAirFreq) {
smartReason = "out-of-range hand + affordable bet + RNG under callAirFreq=" + callAirFreq + " => call";
action[0] = 1;
action[1] = (bet == 0) ? 0 : bet - prevBet;
} else {
smartReason = "out-of-range hand => fold";
action[0] = 2;
}