Code Monkey home page Code Monkey logo

python-bustabit-and-bustadice-simulator's People

Contributors

cclauss avatar snapo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

km1290tty cclauss

python-bustabit-and-bustadice-simulator's Issues

Algorithm

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))

This is faulty

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.