# 30-sided die, 2-player game

Two players play a game. Player 1 goes first, and chooses a number between 1 and 30 (inclusive). Player 2 chooses second; he can't choose Player 1's number. A fair 30-sided die is rolled. The player that chose the number closest to the value of the roll takes that value (say, in dollars) from the other player. Would you rather be Player 1 (choose first) or Player 2 (choose second)? Also, what integer should that player choose?

After doing some trial-and-error calculation, I now know the correct player and the integer he should choose, but what is a faster way to determine which player to be, and which number he should choose?

Let $x_1$ and $x_2$ be the player's choices. To maximize his chances of winning, player 2 will select a number a close as possible to player 1's but must choose whether to select a number above or below $x_1$. The expected payoff for choosing above $x_1$ is greater if:

$\frac{1}{30}\sum_{i=x_1+1}^{30}i\geq\frac{1}{30}\sum_{i=1}^{x_1-1}i$

Computation provides:

$x_1\leq21.56$

Thus, if player 1 chooses 21 or less, 2 chooses $x_1+1$. If player 1 chooses 22 or more, player 2 chooses $x_1-1$.

Given this behavior of player 2, choosing 21 gives player 1 an expected payoff of $\frac{77}{10}$ while choosing 22 gives player 1 an expected payoff of $\frac{78}{10}$. Thus, player 1 chooses 22 and player 2 chooses 21 (other choices give player 1 a lower payoff).

Player 1 with expected payoff $\frac{78}{10}$ does slightly better than player 2 with expected payoff $\frac{77}{10}$. Note that the sum of these expected values is $\frac{155}{10}=\frac{30*29}{2*30}$ which is the expected value of a dice roll.

• Great answer, but when computing the payoffs, why don't you include the losses? If your number happens to be farther, you must pay the other player the amount indicated by the dice, or at least that's what's in the original statement. Aug 28, 2023 at 20:52

Here is some Python code that simulates this game using Monte Carlo and then uses CommonerG's method to solve for the optimal strategy for any n-sided die. Note that the Monte Carlo strategy sometimes converges to a local maximum, but with enough iterations it is usually correct.

https://github.com/arcaputo3/algorithms/blob/master/dice_game/two_player_game.py