views:

105

answers:

1

I'm trying to solve a variant of the dot game with dynamic programming.

The regular dot game is played with a line of dots. Each player takes either one or two dots at their respective end of the line and the person who is left with no dots to take wins.

In this version of the game, each dot has a different value. Each player takes alternate turns and takes either dot at either end of the line. I want to come up with a way to use dynamic programming to find the max amount that the first player is guaranteed to win.

I'm having problems grasping my head around this and trying to write a recurrence for the solution. Any help is appreciated, thanks!

+1  A: 

Take a look at this site: http://people.csail.mit.edu/bdean/6.046/dp/, especially problem number 10:

Optimal Strategy for a Game. Consider a row of n coins of values v(1) ... v(n), where n is even. We play a game against an opponent by alternating turns. In each turn, a player selects either the first or last coin from the row, removes it from the row permanently, and receives the value of the coin. Determine the maximum possible amount of money we can definitely win if we move first.

It's exactly what you want if I'm reading your post right. The solution is pretty simple and it's explained very well there in my opinion.

IVlad