TITLE: What's the optimal strategy of this dice game?
QUESTION [5 upvotes]: I'm working on a dynamic programming problem. I want to find the optimal strategy and simulate it.
The game's description: 
The player rolls two dice. 

If the numbers shown by the two dice are different then the player will add the sum given ($2+3$ for example) to the cumulative rewards he has.
If the numbers shown by the two dice are equal then the player will loose all his reward.

I started modeling the problem. The state of the system is as follow: 
I chose one random number (300 for example) that may be the maximum reward for $N$ rounds game. The state is $V_k(S,D)$ where $S$ is the cumulative sum and $D$ is the sum of the two numbers shown on the two dice.
If we suppose that the numbers of rounds is finite, what will be the optimal strategy in a simple form?
In the case of infinite game what's the mean of the reward?
Reference : 
http://people.brandeis.edu/~igusa/Math56aS08/Math56a_S08_notes041.pdf
Thank you in advance guys :)

REPLY [4 votes]: I will assume that when you lose all your money the game is over and you are not allowed to play anymore. Under this assumption, you should not keep rolling even with unlimited rolls available, because if you play too long, you'll eventually hit zero and lose everything.   
Starting with $S$ dollars, the expected amount after rolling the dice one more time is
$$0\,{6\over 36}+(S+3){2\over 36}+(S+4){2\over 36}+(S+5){3\over 36}+\cdots+(S+11){2\over 36}= {5\over 6}S+{35\over 6}.$$
The first term, with value zero, corresponds to rolling doubles and losing all your money. 
Otherwise, your money increases by anything from 3 to 11 dollars.  
The optimal strategy is to play until either you run out of rolls, or the current amount $S$ is greater than or equal to ${5\over 6}S+{35\over 6}$, i.e. $S\geq 35.$ 
In the latter case, the risk in losing your fortune outweighs the potential gains, so it is better to stop.
For $S\geq 1$, the value function for the game with $N\geq 0$ rolls is 
$$v^N(S)=\cases{35-(5/6)^N(35-S)&for $S\leq 35$\cr S&for $S\geq 35$.}$$
This is the expected payoff when you start with $S$ dollars and follow the optimal strategy.