snapo / python-bustabit-and-bustadice-simulator Goto Github PK
View Code? Open in Web Editor NEWIt just generates numbers from Bust a Dice // Bust a Bit and you can try your strategy. It can handle without console output around 2.9 Seconds
It just generates numbers from Bust a Dice // Bust a Bit and you can try your strategy. It can handle without console output around 2.9 Seconds
I had looked more into this but forgot come back and tell you. you're actually using the v1 algorithm, I hadn't realized it before because I'm mostly used to javascript and I'm not as familiar with the equivalent python code which you used I just assumed it was v2.
I decided to have a go at implementing the v2 algorithm but got stuck trying to find the equivalent hmac sha256 code. The part that generates the results is working correctly, I just can't seem to get the results it generates to match with the official results when using the same hash and salt. Maybe you'll see where the issue is and can get it working..
This algorithm used in v2 produces the correct 1.98 median as it should, and I've heard back from daniel finally and he explained it and all seems to be in working as it should.. it's just that v1 algorithm is causing that, idk why, but I think in v1 there is times when it actually does bust at 0x ? I could be wrong but that's likely the reason for it.
import hashlib
import hmac
import time
import math
import statistics
import binascii
#Define the starting object Hash
salt = binascii.hexlify(bytes('0000000000000000004d6ec16dafe9d8370958664c1dc422f452892264c59526', 'utf-8'))
seed = binascii.hexlify(bytes('a767b5b64dd68d677a7b21508ca835e1d15a92b2b953885c66aa28ffe34a14fd', 'utf-8'))
hashobj = hmac.new(salt, seed, hashlib.sha256)
numberslist = []
start = time.time()
# Looperino starting here
for i in range(1):
number = 0
intversion = int(hashobj.hexdigest()[0:int(52/4)], 16) # parseInt(hash.slice(0,52/4),16);
X = 99 / (1 - (intversion / (2 ** 52))) # Math.pow(2,52);
number = max(1, math.floor(X) / 100)
numberslist.append(number)
print(number) ### PLEASE PLEASE if doing bigger tests comment this out! 20x speed increase
hashobj = hashlib.sha256(hashobj.hexdigest().encode('utf-8'))
end = time.time()
start2 = time.time()
resulthighest = max(numberslist)
resultmean = statistics.mean(numberslist)
resultharmonic_mean = statistics.harmonic_mean(numberslist)
resultmedian = statistics.median(numberslist)
resultmedian_low = statistics.median_low(numberslist)
resultmedian_high = statistics.median_high(numberslist)
resultmedian_grouped = statistics.median_grouped(numberslist)
end2 = time.time()
print("----------------------------------")
print("Time required Bust numbers: " + str(end - start))
print("Time required for Statistics: " + str(end2 - start2))
print("Highest Number: " + str(resulthighest))
print("Arithmetic mean (“average”) of data: " + str(resultmean))
print("Harmonic mean of data: " + str(resultharmonic_mean))
print("Median (middle value) of data: " + str(resultmedian))
print("Low median of data: " + str(resultmedian_low))
print("High median of data: " + str(resultmedian_high))
print("Median, or 50th percentile, of grouped data: " + str(resultmedian_grouped))
Hey! I'm trying to understand how the hash generation works, and got a question regarding this line
https://github.com/snapo/Python-Bustabit-and-Bustadice-Simulator/blob/master/numbergen.py#L26
why do we need to hash the seed everytime before calculating the hmac?
Maybe I'm missing something but it seems like here they don't do that step https://bitcointalk.org/index.php?topic=2807542.0
This isn't producting the correct values. When I generate 10 million results with it they have a median of 1.97. I don't know where the flaw is at and don't have time to fix it for you but this should be having a median of 1.98.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.