-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblackjack-simulator.js
More file actions
605 lines (492 loc) · 21.2 KB
/
blackjack-simulator.js
File metadata and controls
605 lines (492 loc) · 21.2 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
// Blackjack Monte Carlo Simulator
// Uses exact backward-induction solver for play decisions AND bet sizing
// No Hi-Lo heuristics — pure solver-based strategy
import readline from 'readline';
// import { solve, solveOverallEV } from './blackjack-solver.js';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const native = require('./native/index.node');
const { solve, solveOverallEv, generateStrategyChart } = native;
const solveOverallEV = solveOverallEv;
// ─── Card Helpers ───────────────────────────────────────────────────────────
const CARD_NAMES = { '0': '10', '1': 'A', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9' };
const CARDS_PER_DECK = { '0': 16, '1': 4, '2': 4, '3': 4, '4': 4, '5': 4, '6': 4, '7': 4, '8': 4, '9': 4 };
function cardName(c) { return CARD_NAMES[c] || c; }
function cardVal(c) { return c === '1' ? 11 : c === '0' ? 10 : parseInt(c); }
function handValue(cards) {
let total = 0, softAces = 0;
for (const c of cards) {
const v = cardVal(c);
total += v;
if (c === '1') softAces++;
}
while (total > 21 && softAces > 0) { total -= 10; softAces--; }
const isBJ = cards.length === 2 && total === 21;
return { total, softAces, isBJ };
}
function formatCards(cards) { return cards.map(cardName).join(' '); }
// ─── Shoe ───────────────────────────────────────────────────────────────────
class Shoe {
constructor(deckCount) {
this.deckCount = deckCount;
this.cards = [];
this.index = 0;
this.shuffle();
}
shuffle() {
this.cards = [];
for (let d = 0; d < this.deckCount; d++) {
for (const [card, count] of Object.entries(CARDS_PER_DECK)) {
for (let i = 0; i < count; i++) this.cards.push(card);
}
}
// Fisher-Yates
for (let i = this.cards.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[this.cards[i], this.cards[j]] = [this.cards[j], this.cards[i]];
}
this.index = 0;
}
deal() { return this.cards[this.index++]; }
remaining() { return this.cards.length - this.index; }
penetration() { return this.index / this.cards.length; }
}
// ─── Interactive Config ─────────────────────────────────────────────────────
async function promptConfig() {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const ask = (q) => new Promise(r => rl.question(q, r));
console.log('\n\x1b[1m=== Blackjack Monte Carlo Simulator ===\x1b[0m\n');
console.log('Press Enter to accept defaults shown in [brackets].\n');
const num = (v, min, max) => { const n = Number(v); return isNaN(n) ? null : Math.max(min, Math.min(max, n)); };
const yn = (v) => v.toLowerCase().startsWith('y');
const cfg = {};
let v;
v = await ask('Deck count [8]: ');
cfg.deckCount = num(v.trim() || '8', 1, 8) || 8;
v = await ask('Dealer hits soft 17? (y/n) [y]: ');
cfg.hitOnSoft17 = v.trim() === '' ? true : yn(v);
v = await ask('Dealer peeks for blackjack? (y/n) [y]: ');
cfg.dealerPeeks = v.trim() === '' ? true : yn(v);
v = await ask('Double after split? (y/n) [y]: ');
cfg.doubleAfterSplit = v.trim() === '' ? true : yn(v);
v = await ask('Blackjack payout (1.5 = 3:2, 1.2 = 6:5) [1.5]: ');
cfg.bjPayout = num(v.trim() || '1.5', 1, 2) || 1.5;
v = await ask('Penetration (0.5 - 0.95) [0.75]: ');
cfg.penetration = num(v.trim() || '0.75', 0.5, 0.95) || 0.75;
v = await ask('Starting bankroll ($) [10000]: ');
cfg.bankroll = num(v.trim() || '10000', 1, 1e9) || 10000;
v = await ask('Minimum bet ($) [10]: ');
cfg.minBet = num(v.trim() || '10', 1, 1e6) || 10;
v = await ask('Maximum bet ($) [500]: ');
cfg.maxBet = num(v.trim() || '500', cfg.minBet, 1e6) || 500;
v = await ask('Bet strategy (flat / spread / selective) [flat]: ');
const strat = v.trim().toLowerCase();
cfg.betStrategy = ['spread', 'selective'].includes(strat) ? strat : 'flat';
cfg.wongOut = false;
cfg.wongThreshold = -0.02;
if (cfg.betStrategy === 'spread') {
v = await ask('Wong out when EV < -2%? (y/n) [n]: ');
cfg.wongOut = v.trim() === '' ? false : yn(v);
}
if (cfg.betStrategy === 'selective') {
cfg.wongOut = true;
v = await ask('Minimum EV to play (%) [3]: ');
cfg.wongThreshold = (num(v.trim() || '3', -10, 50) || 3) / 100;
}
v = await ask('Number of hands [10000]: ');
cfg.numHands = num(v.trim() || '10000', 1, 1e8) || 10000;
if (cfg.betStrategy !== 'flat') {
console.log('\n\x1b[33m⚠ This mode calls solveOverallEV() per hand (~5-30s each).');
console.log(` ${cfg.numHands} hands could take a very long time.`);
console.log(' Recommend ≤500 hands.\x1b[0m');
}
rl.close();
return cfg;
}
// ─── Simulator ──────────────────────────────────────────────────────────────
class Simulator {
constructor(cfg) {
this.cfg = cfg;
this.shoe = new Shoe(cfg.deckCount);
this.seenCards = {}; // dead cards from previous rounds
this.bankroll = cfg.bankroll;
this.startBankroll = cfg.bankroll;
this.peakBankroll = cfg.bankroll;
this.maxDrawdown = 0;
// Stats
this.handsPlayed = 0;
this.shoesUsed = 1;
this.wins = 0;
this.losses = 0;
this.pushes = 0;
this.bjCount = 0;
this.doubleCount = 0;
this.splitCount = 0;
this.totalWagered = 0;
this.totalPayout = 0;
this.wongsOut = 0;
}
solverOpts() {
return {
deckCount: this.cfg.deckCount,
hitOnSoft17: this.cfg.hitOnSoft17,
dealerPeeks: this.cfg.dealerPeeks,
bjPayout: this.cfg.bjPayout,
doubleAfterSplit: this.cfg.doubleAfterSplit,
};
}
// ── Bet sizing ──
async computeBet() {
if (this.cfg.betStrategy === 'flat') {
return { bet: this.cfg.minBet, ev: null };
}
// Selective / Spread: call solver for exact shoe EV
const result = await solveOverallEV({ ...this.solverOpts(), deadCards: { ...this.seenCards } });
const ev = result.ev; // decimal, e.g. -0.007
// Wong out: sit out if EV below threshold
if (this.cfg.wongOut && ev < this.cfg.wongThreshold) {
return { bet: 0, ev };
}
// Selective: flat min bet whenever we play
if (this.cfg.betStrategy === 'selective') {
return { bet: this.cfg.minBet, ev };
}
// Spread: scale bet linearly with EV
const { minBet, maxBet } = this.cfg;
const scaled = ev <= 0 ? minBet : Math.min(maxBet, minBet + (maxBet - minBet) * (ev / 0.02));
const bet = Math.max(minBet, Math.round(scaled));
return { bet, ev };
}
// ── Reshuffle check ──
checkReshuffle() {
if (this.shoe.penetration() >= this.cfg.penetration) {
this.shoe.shuffle();
this.seenCards = {};
this.shoesUsed++;
return true;
}
return false;
}
// ── Deal phantom hand (wong out) ──
dealPhantomHand() {
// Advance the shoe as if a hand were dealt but player sits out
const roundCards = [];
for (let i = 0; i < 4; i++) roundCards.push(this.shoe.deal());
// Player plays basic: hit until 17
const pCards = [roundCards[0], roundCards[2]];
let pVal = handValue(pCards);
while (pVal.total < 17 && !pVal.isBJ) {
const c = this.shoe.deal();
pCards.push(c);
roundCards.push(c);
pVal = handValue(pCards);
}
// Dealer plays
const dCards = [roundCards[1], roundCards[3]];
let dVal = handValue(dCards);
if (pVal.total <= 21) {
while (this.shouldDealerHit(dCards)) {
const c = this.shoe.deal();
dCards.push(c);
roundCards.push(c);
}
}
// Add all cards to seenCards
for (const c of roundCards) this.seenCards[c] = (this.seenCards[c] || 0) + 1;
}
// ── Dealer logic ──
shouldDealerHit(cards) {
const { total, softAces } = handValue(cards);
if (total < 17) return true;
if (total === 17 && softAces > 0 && this.cfg.hitOnSoft17) return true;
return false;
}
playDealer(cards) {
while (this.shouldDealerHit(cards)) {
cards.push(this.shoe.deal());
}
}
// ── Settle ──
settle(playerTotal, dealerTotal, bet) {
if (playerTotal > 21) return -bet; // bust
if (dealerTotal > 21) return bet; // dealer bust
if (playerTotal > dealerTotal) return bet; // win
if (playerTotal < dealerTotal) return -bet; // lose
return 0; // push
}
// ── Play single hand (hit/stand/double loop) ──
playSingleHand(playerCards, dealerUp, roundCards) {
const opts = { ...this.solverOpts(), deadCards: { ...this.seenCards } };
let doubled = false;
while (true) {
const pv = handValue(playerCards);
if (pv.total >= 21) break; // stand on 21 or bust
const result = solve(dealerUp, playerCards, opts);
const action = result.action;
if (action === 'stand') break;
if (action === 'double' && playerCards.length === 2) {
const c = this.shoe.deal();
playerCards.push(c);
roundCards.push(c);
doubled = true;
break;
}
if (action === 'hit' || (action === 'double' && playerCards.length > 2)) {
// If solver says double but we can't (>2 cards), hit instead
const c = this.shoe.deal();
playerCards.push(c);
roundCards.push(c);
continue;
}
// Fallback: stand
break;
}
return { playerCards, doubled };
}
// ── Play split ──
playSplit(card, dealerUp, roundCards) {
this.splitCount++;
const results = [];
for (let h = 0; h < 2; h++) {
const handCards = [card];
const newCard = this.shoe.deal();
handCards.push(newCard);
roundCards.push(newCard);
// Split aces: only 1 card each
if (card === '1') {
results.push({ playerCards: handCards, doubled: false });
continue;
}
const { playerCards, doubled } = this.playSingleHand(handCards, dealerUp, roundCards);
results.push({ playerCards, doubled });
}
return results;
}
// ── Main hand logic ──
playHand(bet) {
const roundCards = [];
// Deal: player1, dealerUp, player2, dealerHole
const p1 = this.shoe.deal();
const dUp = this.shoe.deal();
const p2 = this.shoe.deal();
const dHole = this.shoe.deal();
roundCards.push(p1, dUp, p2, dHole);
const dealerCards = [dUp, dHole];
const playerCards = [p1, p2];
const dv = handValue(dealerCards);
const pv = handValue(playerCards);
// ── Dealer BJ check (if peek) ──
if (this.cfg.dealerPeeks && dv.isBJ) {
if (pv.isBJ) {
// Push
this.pushes++;
this.finishRound(roundCards, 0, bet);
return 0;
}
this.losses++;
this.finishRound(roundCards, -bet, bet);
return -bet;
}
// ── Player BJ ──
if (pv.isBJ) {
this.bjCount++;
this.wins++;
const payout = bet * this.cfg.bjPayout;
this.finishRound(roundCards, payout, bet);
return payout;
}
// ── Player play ──
const opts = { ...this.solverOpts(), deadCards: { ...this.seenCards } };
const initialResult = solve(dUp, playerCards, opts);
let handResults; // array of { playerCards, doubled }
if (initialResult.action === 'split' && playerCards[0] === playerCards[1]) {
handResults = this.playSplit(playerCards[0], dUp, roundCards);
} else {
const res = this.playSingleHand(playerCards, dUp, roundCards);
handResults = [res];
}
// ── No-peek dealer BJ check (European rules) ──
// Player has already played; now reveal dealer hole card
if (!this.cfg.dealerPeeks && dv.isBJ) {
let totalBet = 0;
for (const h of handResults) {
const handBet = h.doubled ? bet * 2 : bet;
totalBet += handBet;
this.losses++;
if (h.doubled) this.doubleCount++;
}
this.finishRound(roundCards, -totalBet, totalBet);
return -totalBet;
}
// ── Dealer play ──
// Only if at least one player hand isn't busted
const anyAlive = handResults.some(h => handValue(h.playerCards).total <= 21);
if (anyAlive) {
this.playDealer(dealerCards);
// Add dealer hit cards to roundCards
for (let i = 2; i < dealerCards.length; i++) roundCards.push(dealerCards[i]);
}
const dealerTotal = handValue(dealerCards).total;
// ── Settle each hand ──
let totalPayout = 0;
let totalBet = 0;
for (const h of handResults) {
const pTotal = handValue(h.playerCards).total;
const handBet = h.doubled ? bet * 2 : bet;
totalBet += handBet;
if (h.doubled) this.doubleCount++;
const payout = this.settle(pTotal, dealerTotal, handBet);
totalPayout += payout;
if (payout > 0) this.wins++;
else if (payout < 0) this.losses++;
else this.pushes++;
}
// For split, the initial bet is on each hand separately — wagered is totalBet
// But we track wager as totalBet for the round
this.finishRound(roundCards, totalPayout, totalBet);
return totalPayout;
}
// ── Finish round: update seenCards + stats ──
finishRound(roundCards, payout, wagered) {
for (const c of roundCards) {
this.seenCards[c] = (this.seenCards[c] || 0) + 1;
}
this.totalWagered += wagered;
this.totalPayout += payout;
this.bankroll += payout;
this.peakBankroll = Math.max(this.peakBankroll, this.bankroll);
const drawdown = (this.peakBankroll - this.bankroll) / this.peakBankroll;
this.maxDrawdown = Math.max(this.maxDrawdown, drawdown);
}
// ── Progress bar ──
printProgress(i, total, startTime, ev) {
const pct = i / total;
const filled = Math.round(pct * 30);
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(30 - filled);
const elapsed = (Date.now() - startTime) / 1000;
const eta = pct > 0 ? (elapsed / pct * (1 - pct)).toFixed(1) : '?';
const evStr = ev !== null ? ` EV: ${(ev * 100).toFixed(3)}%` : '';
process.stdout.write(`\r [${bar}] ${(pct * 100).toFixed(0)}% ${i.toLocaleString()} / ${total.toLocaleString()} (${elapsed.toFixed(1)}s, ETA ${eta}s)${evStr} `);
}
// ── Print config ──
printConfig() {
const c = this.cfg;
console.log('\n\x1b[1m── Configuration ──\x1b[0m');
console.log(` Decks: ${c.deckCount} H17: ${c.hitOnSoft17 ? 'Yes' : 'No'} Peek: ${c.dealerPeeks ? 'Yes' : 'No'} DAS: ${c.doubleAfterSplit ? 'Yes' : 'No'}`);
console.log(` BJ payout: ${c.bjPayout === 1.5 ? '3:2' : c.bjPayout === 1.2 ? '6:5' : c.bjPayout} Penetration: ${(c.penetration * 100).toFixed(0)}%`);
const stratLabel = c.betStrategy === 'selective' ? `selective (play at EV ≥ ${(c.wongThreshold * 100).toFixed(1)}%)` :
`${c.betStrategy}${c.wongOut ? ` +wong (EV < ${(c.wongThreshold * 100).toFixed(1)}% sit out)` : ''}`;
console.log(` Bankroll: $${c.bankroll.toLocaleString()} Bet: $${c.minBet}-$${c.maxBet} Strategy: ${stratLabel}`);
console.log(` Hands: ${c.numHands.toLocaleString()}`);
}
// ── Print results ──
printResults(elapsed) {
const c = this.cfg;
const net = this.bankroll - this.startBankroll;
const roi = (net / this.startBankroll) * 100;
const houseEdge = this.totalWagered > 0 ? (-net / this.totalWagered) * 100 : 0;
const total = this.wins + this.losses + this.pushes;
const avgBet = total > 0 ? this.totalWagered / total : 0;
const g = '\x1b[32m', r = '\x1b[31m', y = '\x1b[33m', b = '\x1b[1m', d = '\x1b[2m', x = '\x1b[0m';
console.log(`\n\n${b}══════════════════════════════════════${x}`);
console.log(`${b} SIMULATION RESULTS${x}`);
console.log(`${b}══════════════════════════════════════${x}`);
console.log(`\n${b} Hands:${x} ${this.handsPlayed.toLocaleString()} ${d}(${this.shoesUsed} shoes, ${elapsed.toFixed(1)}s)${x}`);
if (this.wongsOut > 0)
console.log(`${b} Wong-outs:${x} ${this.wongsOut.toLocaleString()}`);
console.log(`\n${b} Bankroll:${x} ${net >= 0 ? g : r}$${this.bankroll.toLocaleString()}${x} ${d}(started $${this.startBankroll.toLocaleString()})${x}`);
console.log(`${b} Net P/L:${x} ${net >= 0 ? g + '+' : r}$${net.toLocaleString()}${x}`);
console.log(`${b} ROI:${x} ${net >= 0 ? g : r}${roi.toFixed(2)}%${x}`);
console.log(`${b} Total wagered:${x} $${this.totalWagered.toLocaleString()}`);
console.log(`${b} Avg bet:${x} $${avgBet.toFixed(2)}`);
console.log(`\n${b} Win rate:${x} ${g}${total > 0 ? (this.wins / total * 100).toFixed(2) : 0}%${x} ${d}(${this.wins.toLocaleString()} wins)${x}`);
console.log(`${b} Loss rate:${x} ${r}${total > 0 ? (this.losses / total * 100).toFixed(2) : 0}%${x} ${d}(${this.losses.toLocaleString()} losses)${x}`);
console.log(`${b} Push rate:${x} ${y}${total > 0 ? (this.pushes / total * 100).toFixed(2) : 0}%${x} ${d}(${this.pushes.toLocaleString()} pushes)${x}`);
console.log(`${b} BJ rate:${x} ${total > 0 ? (this.bjCount / this.handsPlayed * 100).toFixed(2) : 0}% ${d}(${this.bjCount.toLocaleString()})${x}`);
console.log(`${b} Doubles:${x} ${this.doubleCount.toLocaleString()} ${b}Splits:${x} ${this.splitCount.toLocaleString()}`);
console.log(`\n${b} Peak bankroll:${x} $${this.peakBankroll.toLocaleString()}`);
console.log(`${b} Max drawdown:${x} ${r}${(this.maxDrawdown * 100).toFixed(2)}%${x}`);
console.log(`${b} House edge:${x} ${houseEdge >= 0 ? r : g}${houseEdge.toFixed(4)}%${x}`);
console.log(`\n${b}══════════════════════════════════════${x}\n`);
}
// ── Main loop ──
async run() {
this.printConfig();
console.log('\n\x1b[1m── Simulating ──\x1b[0m');
const startTime = Date.now();
const { numHands, minBet } = this.cfg;
let i = 0;
while (i < numHands) {
// Reshuffle check
this.checkReshuffle();
// Bankroll check
if (this.bankroll < minBet) {
console.log(`\n\n \x1b[31mBankrupt after ${this.handsPlayed.toLocaleString()} hands.\x1b[0m`);
break;
}
// Compute bet
const { bet, ev } = await this.computeBet();
// Wong out
if (bet === 0) {
this.wongsOut++;
this.dealPhantomHand();
i++;
if (i % 50 === 0 || i === numHands) this.printProgress(i, numHands, startTime, ev);
continue;
}
// Clamp bet to bankroll
const actualBet = Math.min(bet, this.bankroll);
// Play
this.playHand(actualBet);
this.handsPlayed++;
i++;
// Progress
if (i % 100 === 0 || i === numHands) this.printProgress(i, numHands, startTime, ev);
}
const elapsed = (Date.now() - startTime) / 1000;
this.printResults(elapsed);
}
}
// ─── Defaults (for --defaults flag or CLI overrides) ────────────────────────
function defaultConfig(overrides = {}) {
return {
deckCount: 8,
hitOnSoft17: true,
dealerPeeks: true,
doubleAfterSplit: true,
bjPayout: 1.5,
penetration: 0.75,
bankroll: 10000,
minBet: 10,
maxBet: 500,
betStrategy: 'flat',
wongOut: false,
wongThreshold: -0.02,
numHands: 10000,
...overrides,
};
}
// ─── Main ───────────────────────────────────────────────────────────────────
const args = process.argv.slice(2);
const useDefaults = args.includes('--defaults');
// Parse CLI overrides
const overrides = {};
for (const a of args) {
if (a.startsWith('--hands=')) overrides.numHands = parseInt(a.split('=')[1]) || 10000;
if (a.startsWith('--bet=')) overrides.betStrategy = a.split('=')[1] || 'flat';
if (a.startsWith('--decks=')) overrides.deckCount = parseInt(a.split('=')[1]) || 8;
if (a === '--s17') overrides.hitOnSoft17 = false;
if (a === '--h17') overrides.hitOnSoft17 = true;
if (a === '--wong') overrides.wongOut = true;
if (a.startsWith('--wong-ev=')) { overrides.wongOut = true; overrides.wongThreshold = parseFloat(a.split('=')[1]) / 100; }
if (a === '--no-peek') overrides.dealerPeeks = false;
if (a.startsWith('--pen=')) overrides.penetration = parseFloat(a.split('=')[1]) || 0.75;
if (a.startsWith('--bankroll=')) overrides.bankroll = parseInt(a.split('=')[1]) || 10000;
if (a.startsWith('--min=')) overrides.minBet = parseFloat(a.split('=')[1]) || 10;
if (a.startsWith('--max=')) overrides.maxBet = parseFloat(a.split('=')[1]) || 500;
if (a.startsWith('--bj=')) overrides.bjPayout = parseFloat(a.split('=')[1]) || 1.5;
}
const cfg = useDefaults ? defaultConfig(overrides) : await promptConfig();
const sim = new Simulator(cfg);
await sim.run();
process.exit(0);