Something's wrong. House can't win almost 2/3 of the time if it has 0% edge. It would mean that it is possible for the house to lose 2/3 time with 0% player edge. Something like that would be exploited by now.
You're correct, something's wrong. But what is it?
Something in the code. I'm reviewing it right now, gut feeling is something like the way those variables are incremented inside those while loops. If the code is OK (which I doubt), then we stumbled onto something very interesting.
No, it's not the code. The code is right, in that it does what I intended it to do:
It starts with a balance of 15, and martingales from 1 unit, doubling on loss, resetting on win, and stopping either when the bankroll has doubled, or when it can not afford to make the next bet.
There's a prize of 15 CLAM tipped to your Just-Dice account for the first person to post a correct explanation of how it is possible that your chance of doubling up using that strategy can be less than 50%, and for the casino's expectation to still be zero...
The answer is the site is rigged.