Dice Math Containment Thread

I think there may be something to this and I will look at it in the simulation. The thing is not about Nash Eq though I think, but imagine another situation: you are not competing against just one other player, but a billion players. You still get two rolls. Obviously now you reroll unless you get 100. So the number of players matters and it’s not just maximizing your score.

The chances of you winning with the best strategy are at least one in a billion and the chances of not one of the billion players beating 51 or 62 or whatever are much less than 1 in a billion.

Excel spreadsheet with frequency of each result, cumulative frequency of higher results for the opponent, odds of loss and tie for each final roll, multiply to get number of losses and ties for each final roll value, sum columns for overall record.

Well, if when you’re up for it, publish your Excel formulas or whatever goes into an Excel thingy. I will publish the python code tonight. I want to say “try to publish”, but as Yoda said, do or do not, there is no try.

?what is this talk of average roll?

If you re-roll you get the second roll result? If it’s lower, then sucks to be you.

If we roll twice and get to pick the higher roll is completely different than having to live with the second roll.

You don’t really need to code a full sim here to disprove the maximize EV theory. Focus on your strategy for one number (say, 51). Half the time, your opponent gets a number they will reroll. In those cases, you win 1% less often by rerolling, because you would win 51% of the time by staying, and you win half the times you both roll. The other half of the time, they have a number that is 51 or higher. In those cases, you increase your win rate from 1% to 25% by rerolling. Rerolling 51s is much, much better than staying on them. Half the time you go from infinitesimally better than a coinflip to a coinflip, and the other half of the time you go from a near-certain loss to a fighting chance. Your EV goes down a tiny bit, but it’s almost all in situations where you were already losing.

Does this link work? I’m getting old, I don’t know the best way to share files anymore. I don’t want to use my Google drive since it exposes my email. I could register a burner but if this free option works that would be easier. Hopefully it doesn’t attach a virus and/or steal bank logins somehow.

As a preliminary step towards solving this problem, it helps to write down the probability mass function (pmf).

Let N be the number of sides on the die, and T be the re-roll threshold, where you make a second roll if your first roll is <= T.

Then you get the following pmf:

P(X = x | N, T) = T/N*(1/N) for x = {1,…,T}

= 1/N + T/N*(1/N) for x = {T+1,…,N}

So for example, if the die has 100 sides and your rule is to reroll if you get 50 or less, then the pmf is

P(X = x | N=100, T=50) = 50/100*(1/100) = 1/200 for x = {1,…,50}

and = 1/100 + 50/100*(1/100) = 1/100 + 1/200 = 3/200 for x = {51,…,100}

1 Like

It did work and opened fine in Numbers (spreadsheet on my comp).

Bob,

I don’t think a full simulation will be that much more work than any program that does anything and I can vary the number of players too. I won’t do it in Rust though.

You only stay on 52 and your opponent stays on 51. It’s only one changed decision out of a hundred for you and how often is it wrong?

That’s the chances your opponent ends up with 51 or less, right?
50/100 * 51/100 = 2550/10000

which agrees with you - though not sure if that’s a proof or not.

If that reasoning works you can find the:
X/100 * (X+1)/100 that equals 50% for the answer I think.

X2 + X - 5000 = 0

This solves as 70.212

(reasoning for this (if the previous post is right) is ok 52 is better than 51, is 53 better than 52? etc)

I don’t know if your reasoning is wrong or my spreadsheet logic is wrong, but my W-L-T results for a 70 strat vs 62 strat:

70: 4887.1-4994.3-118.6
62: 4994.3-4887.1-118.6

I made a spreadsheet where you can change the strategy for both players to play around with different combos:

Not sure what else, if anything, I will do with it yet, but 58 seems to give the best results against an opponent’s level 0 strategy of “Reroll on 50.” 62 vs 50 gives an equity of 50.42%

I don’t have much time until later and without posting the results so as not to bias anyone - this program is meant to compare stopping at 2 vs 1 and then 3 vs 2 and then 4 vs 3 etc to see when the winner flips.

# python3

def get_score(player_stop_at, rolls):
  i, j = rolls
  if i >= player_stop_at:
    return i
  else:
    return j

def play(x):
  sum_a = 0
  sum_b = 0
  for i in range(1, 101):
    for j in range(1, 101):
      sum_a = sum_a + get_score(x+1, [i, j])
      sum_b = sum_b + get_score(x, [i, j])
  if sum_a > sum_b:
    print(f'{x+1} beats {x}')
  else:
    print(f'{x} beats {x+1}')

for stopping_point in range (1,100):
  play(stopping_point)


and it does show x+1 beating x for a while and then at some point and from then on x beats x+1.

1 Like

Reroll 62 vs Reroll 61 wins, but Reroll 63 vs Reroll 62 loses

Haha i never thought this would go this far. Never underestimate an old school 2+2er with a maths question i guess lol.

8 Likes

I made a change so I could roll numbers more than one apart from each other case by case and got a result. Not the same result as you…but I’m hoping people will look at the code/logic here without knowing results

# python3

def get_score(player_stop_at, rolls):
  i, j = rolls
  if i >= player_stop_at:
    return i
  else:
    return j

def play(x, y=0):
  if y == 0:
    y = x + 1
  sum_a = 0
  sum_b = 0
  for i in range(1, 101):
    for j in range(1, 101):
      sum_a = sum_a + get_score(x, [i, j])
      sum_b = sum_b + get_score(y, [i, j])
  if sum_a > sum_b:
    print(f'{x} beats {y}')
  else:
    print(f'{y} beats {x}')

for stopping_point in range (1,100):
  play(stopping_point)

play(62, 50)

Now that we have P(X = x | N, T), we can define P(X > x | N, T) = 1 - [P(X = 1 | N, T) + … P(X = x | N, T)]

E(w | N, T~, T) = P(X = 1 | N, T~)*P(X > 1 | N, T) + … + P(X = N | N, T~)*P(X > N | N, T)

Let T* = BR(N, ~T) be the value of T that maximizes E(w | N, T~, T)

Then if a pure strategy equilibrium exist it will be T** such that BR(N, T**) = T**

1 Like

I’m not sure what that first sentence means and would probably need a Ben Garrison explanation for it.

I’m not a coder so I can’t really comment intelligently on your python code, but the logic in my spreadsheet seems pretty sound to me, so I’d be curious to hear what’s wrong with the numbers if they indeed are wrong.

That’s what Newton thought too. We only know about his dice problem solution because the dude who asked wrote it up in his diary. Allegedly.

It looks like your program is effectively comparing the expected value of the dice rolls of the two strategies (that is what incrementing the sum_a and sum_b variables seems to be doing).

But that doesn’t necessarily correspond to how frequently each strategy wins against the other.

1 Like

Ah that makes sense, yeah it’s true that maximizing Die Roll EV is not the same as maximizing your chance of winning the game.

Die Roll EV is maximized by using the “Reroll 50” strategy (Die EV is then 63) and decreases in the same way whether you go up or down (“Reroll 60” has the same Die EV as “Reroll 40” etc), but the chance of winning the game doesn’t change equally in either direction (and is more complex to answer since it depends not only on the distribution of your own die rolls, but also the distribution of your opponent’s die rolls.)