-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbaccartChopChopSuey_v_1.0.mjs
378 lines (338 loc) · 12.4 KB
/
baccartChopChopSuey_v_1.0.mjs
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
/***************************************************************
* Baccarat Chop Chop Suey Strategy
* MrBtcGambler (1st Jan 2025)
* Version 1.0
*
* Instructions:
* Download and install Node.js from https://nodejs.org
* npm install crypto
* node baccartChopChopSuey_v_1.0.mjs
*
* 1) We store the last two results (twoAgoResult, prevResult).
* 2) If they match => run => skip bet,
* else => chop => bet on prevResult side (except Tie => skip).
* 3) If first or second hand => skip automatically (not enough history).
* 4) Tie refunds your bet if placed. No nextBet changes on a Tie.
***************************************************************/
import crypto from 'crypto';
// -------------- Configuration --------------
const debugMode = false; // Show detailed logs
const debugDelay = 1000; // ms delay for debug
const noBets = 86_400_000; //1 day = 240_000 , 1 Week = 1_680_000, 1 Month = 7_200_000, 1 Year = 86_400_000
const startBalance = 3090000;
const baseBet = 0.0005;
const increaseOnLoss = 2.0527; // Martingale multiplier
const resetSeedAfter = 1_000; // Reseed interval
// -------------- System Variables --------------
let balance = startBalance;
let nextBet = baseBet;
let profit = 0;
let wager = 0;
let betCount = 0;
let loseCount = 0;
let currentStreak = 0;
let highestLosingStreak = 0;
let lowestBalance = startBalance;
let largestBetPlaced = 0;
// Track overall Banker/Player/Tie wins
let dealerWinCount = 0;
let playerWinCount = 0;
let tieWinCount = 0;
// Seeds & Reseeding
let serverSeed = generateRandomServerSeed(64);
let clientSeed = generateRandomClientSeed(10);
let nonce = 1;
let seedReset = 0;
// Keep track of last two results for run/chop detection
let twoAgoResult = null; // "Banker", "Player", or "Tie"
let prevResult = null; // "Banker", "Player", or "Tie"
// -------------- Card & RNG Functions --------------
const CARDS = [
'D2','H2','S2','C2','D3','H3','S3','C3',
'D4','H4','S4','C4','D5','H5','S5','C5',
'D6','H6','S6','C6','D7','H7','S7','C7',
'D8','H8','S8','C8','D9','H9','S9','C9',
'D10','H10','S10','C10','DJ','HJ','SJ','CJ',
'DQ','HQ','SQ','CQ','DK','HK','SK','CK',
'DA','HA','SA','CA'
];
function generateRandomServerSeed(length) {
const hexRef = '0123456789abcdef';
let result = '';
for (let i = 0; i < length; i++){
result += hexRef.charAt(Math.floor(Math.random()*16));
}
return result;
}
function generateRandomClientSeed(length) {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i=0; i<length; i++){
result += chars.charAt(Math.floor(Math.random()*chars.length));
}
return result;
}
function bytesToFloat(bytes) {
const [b1,b2,b3,b4] = bytes;
return (
(b1 / 256) +
(b2 / 256**2) +
(b3 / 256**3) +
(b4 / 256**4)
);
}
function getRawFloats(serverSeed, clientSeed, nonce) {
const hmac = crypto.createHmac('sha256', serverSeed);
hmac.update(`${clientSeed}:${nonce}:0`);
const buffer = hmac.digest();
let floats = [];
for(let i=0; i<6; i++){
const slice = buffer.slice(i*4, (i+1)*4);
floats.push(bytesToFloat(slice));
}
return floats;
}
function mapFloatToCard(float){
const index = Math.floor(float*52);
return CARDS[index];
}
function calculateBaccaratScore(cards){
let values = cards.map(card=>{
let face = card.slice(1);
if(['J','Q','K'].includes(face)) return 0;
if(face==='A') return 1;
return parseInt(face,10);
});
return values.reduce((acc,v)=> acc+v,0) %10;
}
/** Returns "Banker", "Player", or "Tie" */
function determineBaccaratResult(serverSeed, clientSeed, nonce){
let floats = getRawFloats(serverSeed, clientSeed, nonce);
let deck = floats.map(mapFloatToCard);
let playerCards = [deck[0], deck[1]];
let bankerCards = [deck[2], deck[3]];
let pScoreInit = calculateBaccaratScore(playerCards);
let bScoreInit = calculateBaccaratScore(bankerCards);
if(pScoreInit<8 && bScoreInit<8){
// Possibly draw more
let pThird = null;
if(pScoreInit<=5){
pThird = deck[4];
playerCards.push(pThird);
}
let finalPscore = calculateBaccaratScore(playerCards);
let bThirdIndex = pThird? 5:4;
let bThird = null;
if(bScoreInit<=2){
bThird = deck[bThirdIndex];
}
else if(bScoreInit===3 && (!pThird||pThird[1]!=='8')){
bThird = deck[bThirdIndex];
}
else if(bScoreInit===4 && pThird && ['2','3','4','5','6','7'].includes(pThird[1])){
bThird = deck[bThirdIndex];
}
else if(bScoreInit===5 && pThird && ['4','5','6','7'].includes(pThird[1])){
bThird = deck[bThirdIndex];
}
else if(bScoreInit===6 && pThird && ['6','7'].includes(pThird[1])){
bThird = deck[bThirdIndex];
}
else if(!pThird && bScoreInit<=5){
bThird = deck[bThirdIndex];
}
if(bThird){
bankerCards.push(bThird);
}
}
let finalP = calculateBaccaratScore(playerCards);
let finalB = calculateBaccaratScore(bankerCards);
if(debugMode) console.log(`Final Player: ${finalP}, Final Banker: ${finalB}`);
if(finalP > finalB) return "Player";
if(finalB > finalP) return "Banker";
return "Tie";
}
// -------------- Main Betting Loop --------------
async function runBets(){
const startTime = Date.now();
while(betCount < noBets){
// Reseed if needed
seedReset++;
if(profit > 0 && seedReset > resetSeedAfter){
serverSeed = generateRandomServerSeed(64);
clientSeed = generateRandomClientSeed(10);
nonce=1;
seedReset=0;
}
// Decide bet side & amount
let thisRoundSide = "None";
let thisRoundBet = 0;
// If we have fewer than 2 prior results, we skip automatically
if(betCount < 2){
thisRoundSide = "None";
thisRoundBet = 0;
}
else {
// Run detection: If twoAgoResult === prevResult => skip
if(twoAgoResult === prevResult){
// It's a run => skip
thisRoundSide = "None";
thisRoundBet = 0;
}
else {
// It's a chop => bet on prevResult side if it's Banker or Player
if(prevResult==="Banker" || prevResult==="Player"){
thisRoundSide = prevResult;
thisRoundBet = nextBet;
}
else {
// If prevResult==="Tie", skip
thisRoundSide = "None";
thisRoundBet = 0;
}
}
}
// Subtract bet from balance
balance -= thisRoundBet;
profit -= thisRoundBet;
wager += thisRoundBet;
// Increment nonce every hand
nonce++;
let currResult = determineBaccaratResult(serverSeed, clientSeed, nonce);
// Tally Banker/Player/Tie wins
if(currResult==="Banker") dealerWinCount++;
else if(currResult==="Player") playerWinCount++;
else tieWinCount++;
// If we placed a bet > 0, resolve it
if(thisRoundBet>0){
if(currResult==="Tie"){
// Tie => break even, refund
balance += thisRoundBet;
profit += thisRoundBet;
// No change to loseCount or nextBet
}
else if(thisRoundSide===currResult){
// Win
let multiplier = (currResult==="Banker")? 1.95 : 2.0;
let winnings = thisRoundBet * multiplier;
balance += winnings;
profit += winnings;
nextBet = baseBet;
currentStreak = currentStreak >= 0 ? currentStreak+1 : 1;
}
else {
// Lost
loseCount++;
nextBet *= increaseOnLoss;
currentStreak = currentStreak <= 0 ? currentStreak-1 : -1;
if(currentStreak < highestLosingStreak) highestLosingStreak= currentStreak;
}
}
// If bet=0 => skip => no changes to nextBet or loseCount
// Track largestBet & lowestBalance
if(thisRoundBet> largestBetPlaced){
largestBetPlaced = thisRoundBet;
}
if(balance< lowestBalance){
lowestBalance = balance;
}
// Debug logging
if(debugMode){
let sideColor = currResult==="Banker" ? "\x1b[31m"
: currResult==="Player" ? "\x1b[36m"
: "\x1b[33m";
let resetCol = "\x1b[0m";
console.log(
sideColor + "%s" + resetCol,
[
`\n----- BET #${betCount+1} -----`,
`nonce=${nonce}`,
//`twoAgoResult=${twoAgoResult || "None"}`,
//`PrevResult=${prevResult || "None"}`,
`BetOn=${thisRoundSide} @ ${thisRoundBet.toFixed(4)}`,
`GameResult=${currResult}`,
`Balance=${balance.toFixed(4)}`,
`Profit=${profit.toFixed(4)}`,
`nextBet=${nextBet.toFixed(4)}`,
//`loseCount=${loseCount}`,
`currentStreak=${currentStreak}`,
`highestLosingStreak=${highestLosingStreak}`,
`wager=${wager.toFixed(4)}`,
`nonce=${nonce}`,
'serverSeed='+serverSeed,
'clientSeed='+clientSeed,
`nonce=${nonce}`
].join(" | ")
);
await betDelay(debugDelay);
} else {
// Minimal logs
if(betCount % 10_000 === 0){
let elapsed = (Date.now() - startTime)/1000;
let bps = ((betCount+1)/elapsed).toFixed(2);
let progress = ((betCount/noBets)*100).toFixed(2);
console.log(
`Bets: ${betCount} | Bal: ${balance.toFixed(4)} | Profit: ${profit.toFixed(4)} | BPS: ${bps} | ${progress}% | WLS: ${highestLosingStreak}`
);
}
}
// Shift results for next iteration
twoAgoResult = prevResult;
prevResult = currResult;
betCount++;
// Bust check
if(nextBet> balance){
bustLog();
process.exit();
}
}
// Final summary
summaryLog();
}
// -------------- Helpers --------------
function betDelay(ms) {
return new Promise(resolve=> setTimeout(resolve, ms));
}
function bustLog(){
const red = "\x1b[31m";
const green = "\x1b[32m";
const reset = "\x1b[0m";
console.log(`${red}BUST!${reset}`);
console.log(`Server Seed: ${serverSeed}, Client Seed: ${clientSeed}, Nonce: ${nonce}`);
console.log(`${red}##########################################${reset}`);
console.log(`${red}# Bet Summary:${reset}`);
console.log(`${red}# Total Bets: ${betCount}${reset}`);
console.log(`${red}# Total Profits: ${profit.toFixed(4)}${reset}`);
console.log(`${green}# Total Wager: ${wager.toFixed(4)}${reset}`);
console.log(`${red}# No. Banker Wins: ${dealerWinCount}${reset}`);
console.log(`${red}# No. Player Wins: ${playerWinCount}${reset}`);
console.log(`${red}# No. Ties: ${tieWinCount}${reset}`);
console.log(`${red}# Lowest Balance: ${lowestBalance.toFixed(4)}${reset}`);
console.log(`${red}# Largest Bet: ${largestBetPlaced.toFixed(4)}${reset}`);
console.log(`${red}# Closing Server Seed: ${serverSeed}${reset}`);
console.log(`${red}# Closing Client Seed: ${clientSeed}${reset}`);
console.log(`${red}# Closing Nonce: ${nonce}${reset}`);
console.log(`${red}##########################################${reset}`);
}
function summaryLog(){
const green = "\x1b[32m";
const reset = "\x1b[0m";
const red = "\x1b[31m";
console.log(`${green}##########################################${reset}`);
console.log(`${green}# Bet Summary:${reset}`);
console.log(`${green}# Total Bets: ${betCount}${reset}`);
console.log(`${red}# Highest Losing Streak: ${highestLosingStreak}${reset}`);
console.log(`${green}# Total Profits: ${profit.toFixed(4)}${reset}`);
console.log(`${green}# Total Wager: ${wager.toFixed(4)}${reset}`);
console.log(`${green}# No. Banker Wins: ${dealerWinCount}${reset}`);
console.log(`${green}# No. Player Wins: ${playerWinCount}${reset}`);
console.log(`${green}# No. Ties: ${tieWinCount}${reset}`);
console.log(`${green}# Lowest Balance: ${lowestBalance.toFixed(4)}${reset}`);
console.log(`${green}# Largest Bet: ${largestBetPlaced.toFixed(4)}${reset}`);
console.log(`${green}# Closing Server Seed: ${serverSeed}${reset}`);
console.log(`${green}# Closing Client Seed: ${clientSeed}${reset}`);
console.log(`${green}# Closing Nonce: ${nonce}${reset}`);
console.log(`${green}##########################################${reset}`);
}
// -------------- Kick off --------------
runBets();