Post
Topic
Board Gambling
Re: bustabit.com -- The Social Gambling Game (formerly moneypot.com)
by
dooglus
on 17/06/2016, 19:13:12 UTC
   return Math.floor(((100 * e) - h) / (e - h));

That's the only really interesting line. We can ignore the "0x crash 1-in-101 games" part, because that is only used to fund the 1% bonus that it paid out on the other 100-in-101 games. It has no effect on the house edge at all.

We can even lose the Math.floor bit, because that just makes sure the result has no more than 2 decimal places. And divide the top by 100, because that function is returning the crash point times 100 (so it's an integer).

So the crash point is simply:

Code:
 e - h/100
  ---------
    e - h

e is a big number, but it doesn't really matter what it is (it's 2^52)
h is a random number between 0 and e-1 inclusive

Let's look at three cases:

1. If h is at its minimum, 0, the crash point is 1x

The house edge is 0%. (We can ignore the 1-in-101 0x crashes, because on the other 100-in-101 games we get a 1% bonus, assuming we're the only player, or that all the other players are also playing at a 1x cashout).

2. If h is half way through its range, e/2, the crash point is 1.99x

So we have a 50% chance of winning 1.99x. That gives an RTP of 50%*1.99 = 99.5% and so a house edge of 0.5%

3. If h is at its maximum, e-1, the crash point is 0.99e+0.01 (ie. very high, since e is a big number)

So we have a 100/e% chance of winning 0.99e+0.01. That gives an RTP of (99e+1)/e% ~= 99% and so a house edge of a tiny bit under 1%.

So you can see that the house edge ranges from 0% to 1% as your payout multiplier ranges from 1x to high numbers.

i just don't know how i would go about calculating the house edge for a certain multiplier

The payout multiplier for any particular h is (from the code you pasted):
  m = (e - h/100) / (e-h)   [1]
and the probability p of hitting that payout is:
  p = (e-h)/e   [2]
  h = e-ep
the RTP for that h is [1]*[2]*100:
  (e - h/100) / (e-h) * (e-h)/e * 100
  = (e - h/100) * 100/e
  = 100 - h/e
and so the house edge is simply:
  edge = 100 - RTP
  = h/e
  = (e-ep)/e
  = 1-p

Now you want the house edge for a given multiplier, m. Let's find h in terms of m:
  m = (e - h/100) / (e-h)
  (e-h)m = e - h/100
  em - hm = e - h/100
  em - e = hm - h/100
  e(m-1) = h(m-0.01)
  h = e(m-1)/(m-0.01)

And so the house edge:
  edge = h/e
  = e(m-1)/(m-0.01)
  = (m-1)/(m-0.01)

And there's your answer. The house edge for a probability of p is 1-p, and for a multiplier of m is (m-1)/(m-0.01)

Examples:

  the house edge when you have a 0.5 probability of winning is 1 - p = 1-0.5 = 0.5%
  the house edge for a multiplier of 2x is (m-1)/(m-0.01) = (2-1)/(2-0.01) = 0.50251256%

Edit: if all you want to do is change the house edge so that it goes from 0% to N% instead of 0% to 1%, I think you only need to replace the 100 in the Math.floor line by 100/N. Don't change the insta-crash logic unless you want to unbalance the bonus system. Looks like you already changed it to insta-crash every 51 games (without changing the corresponding comment), but that's a bad idea. People won't want to play a game that insta-crashes so often. Adjust the edge using the Math.floor line instead.

Example:

>>> e = 2**52
>>> h = e * 0.75
>>> 100 - (e - h/100) / (e-h) * 25 # the bustabit setting - house edge is 0.75% when we have 25% chance of winning
0.75
>>> 100 - (e - h/20) / (e-h) * 25 # increase the house edge by a factor of 5 - house edge is 3.75% when we have 25% chance of winning
3.75