Giter Club home page Giter Club logo

the-moon-game's Introduction

Algodetial

The player finally decides to run at x + x_delta when he sees the curve to x

The odds

0.99 / [1 - (x + x_delta)]

Conditional probability

[1- (x+x_delta)] / [1- x]
=
(1-x-x_delta)/(1-x)
=
1- x_delta/(1- x)

Conditions for EV value
=
Probability * conditional probability
=
0.99/[1- (x+x_delta)] * [1-x_delta/(1-x)]
=

EV value = conditional EV value * the probability that the player sees x
=
0.99 / [1 - (x + x_delta)] * [1 - x_delta/(1 - x)] * (1 - x)
=
0.99/(1-x-x_delta) * (1-x-x_delta)
=
0.99

Source Code

To prove our fairness we have generated a chain of 100,000,000 SHA256 hashes where each hash is the hash of the hexadecimal representation of the previous hash.

The formula for generating the game result:

//hashChain is the chain of 100,000,000 SHA256 hashes which are already generated.
//get the last hash of the chain
const gameHash = hashChain.pop();

const crashpoint = gameResult(gameHash);

//update the hash is used
hashChain.update({
  gameHash: gameHash,
  used: true
})

function gameResult(seed) {
  const nBits = 52; // number of most significant bits to use
  // 1. r = 52 most significant bits
  seed = seed.slice(0, nBits / 4);
  const r = parseInt(seed, 16);
  // 2. X = r / 2^52
  let X = r / Math.pow(2, nBits); // uniformly distributed in [0; 1)
  // 3. X = 99 / (1-X)
  X = 99 / (1 - X);
  // 4. return max(trunc(X), 100)
  const result = Math.floor(X);
  return Math.max(1, result / 100);
};

To verify our fairness just run the below function in order to generate the previous hash and crash point

function generatePrevHash(prevHash, length=10){
  for (let i = 0; i < length; i++) {
    let hash = String(CryptoJS.SHA256(String(prevHash))); //We're using the CryptoJS javascript library https://www.npmjs.com/package/crypto-js
    let bust = gameResult(hash); //the gameResult calculation function above
    console.log(`HASH: ${hash}, crash point: ${bust}, index: ${i}`); //printing the result to the console
    prevHash = hash;
  }
}

Simply, you can verify and generate the previous hash of the chain in here: https://freedogeon.github.io/the-moon-game/ You can find the source at index.html file.

the-moon-game's People

Contributors

freedogeon avatar

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.