forked from Blaksmith/DiceBotScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreak-counter.lua
372 lines (338 loc) · 12.4 KB
/
streak-counter.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
-- *******************************************************
-- Martingale with logging
-- Use this ref link to support this code: http://faucetgame.com/r/6490808
--
-- Script name: Roxy-style.lua
--
--
-- *******************************************************
-- Default logging goes to the directory where DiceBot is run from.
-- To specify a different log location, you need to edit the 2 lines below.
-- The two files must be in the same directory!
filename = "streak.log"
csvfile = "streak.csv"
tempfile = "tempfile.log"
timeStart = os.time()
-- ************************************
-- 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, Multiplier, 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.
-- ************************************
-- initialize custom settings
slowdown = 0.5 -- In seconds. Set this to 0.0 to run at full speed. Need to slow down for FreeBitco.in
lossStreak = 3
winStreak = 4
stoploss = 5
basebet = 0.00000001 -- Your starting bet
lossBet = 0.00000010 -- What to bet after lossStreak bets
winBet = 0.00000050 -- What to bet after winStreak bets
multiplier = 2.0 -- What multiplier you want for the martingale
-- If you want to just play steady, put this at 2.0
basechance = 45 -- Might need to fine tune this one per site
winStreakCount = 0
lossStreakCount = 0
lastWinRollCount = 0
currentRollCount = 0
balanceLastWin = balance
startingBalance = balance
oppositeRolls = 0
oppositeArray = {}
oppositeArrayCount = {}
winCount = 0
rollHighHigh = 0
rollHighLow = 0
rollLowHigh = 0
rollLowLow = 0
roundSpent = 0
-- Initialize system settings
nextbet = basebet
chance = basechance
satoshi = 0.00000001
-- 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)
rollCountAverage = {}
rollAverageCount = 0
rollAverageIndex = 0
rollAverageMax = 3 -- Average roll count before a win. How many wins do you want to average?
-- Initialize the array
for i=0, rollAverageMax do
rollCountAverage[i] = 0
end
highLowAverage = {}
averageCount = 0
averageIndex = 0
averageMax = 8 -- High / Low average switching. How many rolls do you want to average?
rollCount = 0
rollSeedCount = 0
-- Initialize the array
for i=0, averageMax do
highLowAverage[i] = 0
end
local clock = os.clock
function sleep(n) -- seconds
local t0 = clock()
while clock() - t0 <= n do end
end
-- Start the actual betting
function dobet()
currentRollCount += 1
rollCount += 1
roundSpent += lastBet.Amount
-- Store statistics for high / low rolls
if(lastBet.Roll > 50 and bethigh == true) then -- High roll and was high
rollHighHigh += 1
end
if(lastBet.Roll <= 50 and bethigh == true) then -- High roll and was low
rollHighLow += 1
end
if(lastBet.Roll > 50 and bethigh == false) then -- Low roll and was high
rollLowHigh += 1
end
if(lastBet.Roll <= 50 and bethigh == false) then -- Low roll and was low
rollLowLow += 1
end
-- We got a win, let's store some averages
if(win) then
-- roundSpent -= lastBet.Amount -- You get your bet back on win
winCount += 1
winStreakCount += 1
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
rollAverageCount += 1
if(rollAverageCount >= rollAverageMax) then
rollAverageCount = rollAverageMax -- no need to keep this one climbing
end
if(rollAverageIndex >= rollAverageMax) then
rollAverageIndex = 0 -- reset
end
if(nextbet >= winBet or nextbet >= lossBet) then
-- 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, Multiplier, 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 = "Multiplier: replace / Slots: slots\r\n"
tempstr = string.gsub(tempstr1, "replace", multiplier)
tempstr = string.gsub(tempstr, "slots", maxSlots)
csvtemp = string.gsub(csvtemp, "Multiplier", multiplier)
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 + lastBet.Amount)
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)
end
if(winStreakCount== winStreak) then
nextbet = winbet
else
nextbet = basebet
end
rollCount = 0 -- reset for next rolling
oppositeRolls = 0
rollHighHigh = 0 -- reset counters
rollHighLow = 0 -- reset counters
rollLowHigh = 0 -- reset counters
rollLowLow = 0 -- reset counters
roundSpent = 0
chance = basechance
lossStreakCount =0
end
-- Let's use the averages from previous rolls to see if the bet needs to be changed
if(!win) then
lossStreakCount += 1
if(lossStreakCount == lossStreak) then
nextbet = lossBet
end
if(lossStreakCount > lossStreak) then
nextbet = nextbet * multiplier -- Increment bet
end
if(lossStreakCount >= stoploss) then
nextbet = basebet
end
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
-- Reset the seed if too long of a losing streak
rollSeedCount += 1
if(rollSeedCount > SeedResetMax) then
-- resetseed()
rollSeedCount = 0
seedResets += 1
-- nextbet = nextbet + basebet -- Increment bet
-- check to see if we are at our absolute max bet allowed
end
winStreakCount = 0
end
-- Calculate the average, and then change high / low accordingly
if(lastBet.Roll >= 50) then
highLowAverage[averageIndex] = 1
else
highLowAverage[averageIndex] = 0
end
averageIndex += 1
if(averageIndex >= averageMax) then
averageIndex = 0
end
if(averageCount < averageMax) then
averageCount += 1
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
sleep(slowdown)
end