-
Notifications
You must be signed in to change notification settings - Fork 28
/
reverse-low.lua
399 lines (362 loc) · 14.5 KB
/
reverse-low.lua
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
-- Reverse Low strategy
startingBet = 1 -- Enter as whole satoshi
startingChance = 42
minimumChance = 0.45
lossChanceChange = 2.50 -- may need to change a little faster
maxBet = 500 -- Enter as whole satoshi. Also used for a reset after maxLosscount losses in a row at this value.
maxLossCount = 3 -- Used with maxBet. If maxBet has been bet this many times in a row, it resets.
multiplier = 1.75 -- multiplier to increment the bet per loss
useMult = false -- Set this to false to increment each bet by 1, true to use the above multiplier
autoTune = true -- Set to false to use the maxBet value defined above.
autoPercent = 0.0099 -- Percent of your current balance for maxBet for autoTune (x 100. 0.015 = 1.5%)
-- No need to change anything after this
filename = "reverse-low.log"
csvfile = "reverse-low.csv"
tempfile = "tempfile.log"
satoshi = 0.00000001
oppositeRolls = 0
oppositeArray = {}
oppositeArrayCount = {}
lastWinRollCount = 0
currentRollCount = 0
rollCount = 0
rollCountAverage = {}
rollAverageCount = 0
rollAverageIndex = 0
rollAverageMax = 4 -- Average roll count before a win. How many wins do you want to average?
maxLossCounter = 0
startingBet *= satoshi
maxBet *= satoshi
chance = startingChance
nextbet = startingBet
-- ************************************
-- Comment these next 3 lines if you want to append to the old file.
-- These 3 lines must be un-commented on the very first run, otherwise
-- the script will crash with a LUA error, due to the file not existing.
-- ************************************
fin = assert(io.open(filename, "w"))
fin:write("\n")
fin:close()
-- ************************************
-- Comment the above 3 lines if you want to append to the old file
-- These 3 lines must be un-commented on the very first run, otherwise
-- the script will crash with a LUA error, due to the file not existing.
-- ************************************
-- ************************************
-- Comment these next 3 lines if you want to append to the old file.
-- These 3 lines must be un-commented on the very first run, otherwise
-- the script will crash with a LUA error, due to the file not existing.
-- ************************************
fin = assert(io.open(csvfile, "w"))
fin:write("Rolls, Opposites, High Bets, High Rolls, Low Rolls, Low Bets, High Rolls, Low Rolls, Seed Resets, Last Bet, Winning Chance, Winning Roll, Spent, Win Amount, Win Profit, Balance, Run Profit\n")
fin:close()
-- ************************************
-- Comment the above 3 lines if you want to append to the old file
-- These 3 lines must be un-commented on the very first run, otherwise
-- the script will crash with a LUA error, due to the file not existing.
-- ************************************
-- set up the logging for this run.
-- timestamps are screwed up, otherwise I would have added them
fin = assert(io.open(filename, "r"))
content = fin:read("*a")
fin:close()
fout = assert(io.open(tempfile, "w"))
fout:write(content)
tempstr = "********************************** New run **********************************\r\n"
fout:write(tempstr)
tempstr1 = "Starting balance: replace\r\n"
tempcalc = string.format("%.8f", balance)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
fout:write(tempstr)
fout:close()
os.remove(filename)
os.rename(tempfile, filename)
function dobet()
currentRollCount += 1
rollCount += 1
roundSpent += lastBet.Amount
-- auto tuning routine
if(autoTune) then
maxBet = balance * autoPercent
end
-- Win
if(win) then
if(rollAverageCount == 0) then -- Initialize so we get a good starting average
for i=0, rollAverageMax do
rollCountAverage[i] = rollCount
end
rollAverageIndex += 1
else
rollCountAverage[rollAverageIndex] = rollCount
rollAverageIndex += 1
end
-- Write to the log file for review
fin = assert(io.open(filename, "r"))
content = fin:read("*a")
-- print(content)
fin:close()
fout = assert(io.open(tempfile, "w"))
fout:write(content)
oppositeTemp = ", , Roll #, Value, , , , , , , , , , , , , , , "
csvtemp = "Num Rolls, Opposites, High Bets, High High Rolls, High Low Rolls, Low Bets, Low High Rolls, Low Low Rolls, Seed Resets, Last Bet, Winning Chance, Winning Roll, Spent, Win Amount, Win Profit, Balance, Run Profit\r\n"
tempstr = "************************************ Win ************************************\r\n"
fout:write(tempstr)
tempstr1 = "Win #: replace\r\n"
tempstr = string.gsub(tempstr1, "replace", winCount)
fout:write(tempstr)
tempstr1 = "Rolls: replace\r\n"
tempstr = string.gsub(tempstr1, "replace", rollCount)
csvtemp = string.gsub(csvtemp, "Num Rolls", rollCount)
fout:write(tempstr)
tempstr1 = "Opposites: replace\r\n"
tempstr = string.gsub(tempstr1, "replace", oppositeRolls)
csvtemp = string.gsub(csvtemp, "Opposites", oppositeRolls)
fout:write(tempstr)
oppositeOut = ""
if(oppositeRolls > 0) then
for i=0, oppositeRolls - 1 do
oppositeOut = oppositeOut .. oppositeTemp
tempstr1 = "-- Roll#: rollcount, Value: opposite\r\n"
tempstr = string.gsub(tempstr1, "rollcount", oppositeArrayCount[i])
oppositeOut = string.gsub(oppositeOut, "Roll #", oppositeArrayCount[i])
tempstr = string.gsub(tempstr, "opposite", oppositeArray[i])
oppositeOut = string.gsub(oppositeOut, "Value", oppositeArray[i])
oppositeOut = oppositeOut .. "\r\n"
fout:write(tempstr)
end
end
tempstr = "High Bets: hightotal, High Rolls: highrolls, Low Rolls: lowrolls\r\n"
tempstr = string.gsub(tempstr, "hightotal", rollHighHigh + rollHighLow)
csvtemp = string.gsub(csvtemp, "High Bets", rollHighHigh + rollHighLow)
tempstr = string.gsub(tempstr, "highrolls", rollHighHigh)
csvtemp = string.gsub(csvtemp, "High High Rolls", rollHighHigh)
tempstr = string.gsub(tempstr, "lowrolls", rollHighLow)
csvtemp = string.gsub(csvtemp, "High Low Rolls", rollHighLow)
fout:write(tempstr)
tempstr = "Low Bets: lowtotal, High Rolls: highrolls, Low Rolls: lowrolls\r\n"
tempstr = string.gsub(tempstr, "lowtotal", rollLowHigh + rollLowLow)
csvtemp = string.gsub(csvtemp, "Low Bets", rollLowHigh + rollLowLow)
tempstr = string.gsub(tempstr, "highrolls", rollLowHigh)
csvtemp = string.gsub(csvtemp, "Low High Rolls", rollLowHigh)
tempstr = string.gsub(tempstr, "lowrolls", rollLowLow)
csvtemp = string.gsub(csvtemp, "Low Low Rolls", rollLowLow)
fout:write(tempstr)
tempstr1 = "Seed Resets: replace\r\n"
tempstr = string.gsub(tempstr1, "replace", seedResets)
csvtemp = string.gsub(csvtemp, "Seed Resets", seedResets)
fout:write(tempstr)
tempstr1 = "Last Bet: replace\r\n"
tempcalc = string.format("%.8f", nextbet)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Last Bet", tempcalc)
fout:write(tempstr)
tempstr1 = "Winning Chance: replace\r\n"
tempcalc = string.format("%.2f", chance)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Winning Chance", tempcalc)
fout:write(tempstr)
tempstr1 = "Winning Roll: replace\r\n"
tempcalc = string.format("%.2f", lastBet.Roll)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Winning Roll", tempcalc)
fout:write(tempstr)
tempstr1 = "Spent Out: replace\r\n"
tempcalc = string.format("%.8f", roundSpent)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Spent", tempcalc)
fout:write(tempstr)
tempstr1 = "Win Amount: replace\r\n"
tempcalc = string.format("%.8f", lastBet.Profit)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Win Amount", tempcalc)
fout:write(tempstr)
tempstr1 = "Win Profit: replace\r\n"
tempcalc = string.format("%.8f", lastBet.Profit - roundSpent)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Win Profit", tempcalc)
fout:write(tempstr)
tempstr1 = "Balance: replace\r\n"
tempcalc = string.format("%.8f", balance)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Balance", tempcalc)
fout:write(tempstr)
tempstr1 = "Run Profit: replace\r\n"
tempcalc = string.format("%.8f", balance - startingBalance)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Run Profit", tempcalc)
fout:write(tempstr)
fout:close()
os.remove(filename)
os.rename(tempfile, filename)
fin = assert(io.open(csvfile, "r"))
content = fin:read("*a")
-- print(content)
fin:close()
fout = assert(io.open(tempfile, "w"))
fout:write(content)
fout:write(csvtemp)
-- fout:write(oppositeOut)
fout:close()
os.remove(csvfile)
os.rename(tempfile, csvfile)
-- reset everything
chance = startingChance
nextbet = startingBet -- should never need to change for now
maxLossCounter = 0
rollCount = 0 -- reset for next rolling
oppositeRolls = 0
end
-- Loss
if(!win) then
oppositeTest = lastBet.Roll
if(oppositeTest > (100 - chance) and bethigh == false) then -- Test if we were rolling high
-- print(oppositeTest)
oppositeArray[oppositeRolls] = oppositeTest
oppositeArrayCount[oppositeRolls] = rollCount
oppositeRolls += 1
end
if(oppositeTest < chance and bethigh == true) then -- Test if we were rolling low
-- print(oppositeTest)
oppositeArray[oppositeRolls] = oppositeTest
oppositeArrayCount[oppositeRolls] = rollCount
oppositeRolls += 1
end
-- Check to see if the last bet was max.
-- This check must be before the check at the bottom for max bet
if(nextbet >= maxBet) then
maxLossCounter += 1
end
chance -= lossChanceChange
if(chance < minimumChance) then
chance = minimumChance
end
if(useMult == true) then
nextbet *= multiplier
else
nextbet += satoshi
end
if(nextbet > maxBet) then
nextbet = maxBet
end
-- Need to check for reset
if(maxLossCounter >= maxLossCount) then -- Reset. Too many losses
oppositeTemp = ", , Roll #, Value, , , , , , , , , , , , , , , "
csvtemp = "Num Rolls, Opposites, High Bets, High High Rolls, High Low Rolls, Low Bets, Low High Rolls, Low Low Rolls, Seed Resets, Last Bet, Winning Chance, Winning Roll, Spent, Win Amount, Win Profit, Balance, Run Profit\r\n"
tempstr = "*********************************** Loss ************************************\r\n"
fout:write(tempstr)
tempstr1 = "Rolls: replace\r\n"
tempstr = string.gsub(tempstr1, "replace", rollCount)
csvtemp = string.gsub(csvtemp, "Num Rolls", rollCount)
fout:write(tempstr)
tempstr1 = "Opposites: replace\r\n"
tempstr = string.gsub(tempstr1, "replace", oppositeRolls)
csvtemp = string.gsub(csvtemp, "Opposites", oppositeRolls)
fout:write(tempstr)
oppositeOut = ""
if(oppositeRolls > 0) then
for i=0, oppositeRolls - 1 do
oppositeOut = oppositeOut .. oppositeTemp
tempstr1 = "-- Roll#: rollcount, Value: opposite\r\n"
tempstr = string.gsub(tempstr1, "rollcount", oppositeArrayCount[i])
oppositeOut = string.gsub(oppositeOut, "Roll #", oppositeArrayCount[i])
tempstr = string.gsub(tempstr, "opposite", oppositeArray[i])
oppositeOut = string.gsub(oppositeOut, "Value", oppositeArray[i])
oppositeOut = oppositeOut .. "\r\n"
fout:write(tempstr)
end
end
tempstr = "High Bets: hightotal, High Rolls: highrolls, Low Rolls: lowrolls\r\n"
tempstr = string.gsub(tempstr, "hightotal", rollHighHigh + rollHighLow)
csvtemp = string.gsub(csvtemp, "High Bets", rollHighHigh + rollHighLow)
tempstr = string.gsub(tempstr, "highrolls", rollHighHigh)
csvtemp = string.gsub(csvtemp, "High High Rolls", rollHighHigh)
tempstr = string.gsub(tempstr, "lowrolls", rollHighLow)
csvtemp = string.gsub(csvtemp, "High Low Rolls", rollHighLow)
fout:write(tempstr)
tempstr = "Low Bets: lowtotal, High Rolls: highrolls, Low Rolls: lowrolls\r\n"
tempstr = string.gsub(tempstr, "lowtotal", rollLowHigh + rollLowLow)
csvtemp = string.gsub(csvtemp, "Low Bets", rollLowHigh + rollLowLow)
tempstr = string.gsub(tempstr, "highrolls", rollLowHigh)
csvtemp = string.gsub(csvtemp, "Low High Rolls", rollLowHigh)
tempstr = string.gsub(tempstr, "lowrolls", rollLowLow)
csvtemp = string.gsub(csvtemp, "Low Low Rolls", rollLowLow)
fout:write(tempstr)
tempstr1 = "Seed Resets: replace\r\n"
tempstr = string.gsub(tempstr1, "replace", seedResets)
csvtemp = string.gsub(csvtemp, "Seed Resets", seedResets)
fout:write(tempstr)
tempstr1 = "Last Bet: replace\r\n"
tempcalc = string.format("%.8f", nextbet)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Last Bet", tempcalc)
fout:write(tempstr)
tempstr1 = "Winning Chance: replace\r\n"
tempcalc = string.format("%.2f", chance)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Winning Chance", tempcalc)
fout:write(tempstr)
tempstr1 = "Spent Out: replace\r\n"
tempcalc = string.format("%.8f", roundSpent)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Spent", tempcalc)
fout:write(tempstr)
tempstr1 = "Balance: replace\r\n"
tempcalc = string.format("%.8f", balance)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Balance", tempcalc)
fout:write(tempstr)
tempstr1 = "Run Profit: replace\r\n"
tempcalc = string.format("%.8f", balance - startingBalance)
tempstr = string.gsub(tempstr1, "replace", tempcalc)
csvtemp = string.gsub(csvtemp, "Run Profit", tempcalc)
fout:write(tempstr)
fout:close()
os.remove(filename)
os.rename(tempfile, filename)
fin = assert(io.open(csvfile, "r"))
content = fin:read("*a")
-- print(content)
fin:close()
fout = assert(io.open(tempfile, "w"))
fout:write(content)
fout:write(csvtemp)
-- fout:write(oppositeOut)
fout:close()
os.remove(csvfile)
os.rename(tempfile, csvfile)
chance = startingChance
nextbet = startingBet
maxLossCounter = 0
end
end
-- Calculate the high/low roll result average, and then change high/low accordingly
-- The below variables need to be defined before the dobet() call
-- rollCountAverage = {}
-- rollAverageCount = 0
-- rollAverageIndex = 0
-- rollAverageMax = 4 -- Average roll count before a win. How many wins do you want to average?
if(lastBet.Roll >= 50) then
highLowAverage[averageIndex] = 1
else
highLowAverage[averageIndex] = 0
end
averageIndex += 1
averageCount += 1
if(averageIndex >= averageMax) then
averageIndex = 0
end
if(averageCount > averageMax) then
averageCount = averageMax
end
average = 0.00
for i=0, averageCount do
average += highLowAverage[i]
end
average = average / averageCount
-- print (average)
if average >= 0.5 then
bethigh = true
else
bethigh = false
end
end