Finding the best/optimal strategy for this game My friend posed this question to me which he was unsure if there was a solution (it was an intervew question I think):
It went along the lines of:
The game is the following: You are player $1$ and you are versing another person player $2$. You and player $2$ choose any integer from $1$ to $30$. A $30$ sided die is rolled and whoever's number is the closest to the die's number is the "winner" of the game and gains points according to what they guessed.
e.g. Player $1$ picks number $20$ and player $2$ picks number $15$.
The die lands on the number $18$ so player $1$ wins and gets $20$ points.  
(Note that you can choose whether or not to go first or second in picking a number (you will know the other player's number if you go second)).  
What is the optimal strategy for this game? (Optimal wasn't really defined from my friend, but I assume it is something like "highest number of points" by the $n$'th round)?  
 A: I'll also use the names Alice and Bob, with Alice going first.

I'll assume that at the end of each round, the losing player pays the winning player a dollar amount equal to the winning player's score for that round.

For simplicity, I'll assume no score is awarded if Alice and Bob choose numbers which are equally close to the value of the roll.

Also, I'll assume the rules require Bob to choose a number other than the one already chosen by Alice.

Claim: Alice has the advantage and should always choose $16$.

Alice is trying to maximize not her expected score, but rather, the expected value of her score minus Bob's score.

With Alice choosing $16$, Bob's optimal reply is $15$, but for those choices, the expected value of Alice's score minus Bob's score is $+0.5$, so Alice will win more points, on average, than Bob.

If Alice chooses any number other than $16$, Bob has a reply which can force the expected value of Alice's score minus Bob's score to be negative, so in those cases, Bob will win more points, on average, than Alice.

If Alice chooses $16$, and Bob chooses any number other than $15$, the expected value of Alice's score minus Bob's score will be greater than $0.5$, so Bob's best choice is $15$, since it minimizes Bob's expected loss.

Optimal strategies for Bob:

If Alice chooses $k$ with $k < 16$, Bob's best reply is $31-k$, which yields a positive expectation for Bob.

If Alice chooses $k$ with $k > 16$, Bob's best reply is $k-1$, which yields a positive expectation for Bob.

Finally, if Alice chooses $16$, all choices by Bob yield a negative expectation for Bob, but to minimize the expected loss, Bob should choose $15$.

Bottom line: You want to be Alice!
A: Edited to add, Tues. Aug 15, 13:58 GMT: I got the rules of the game wrong, I think.  Keeping this for posterity.
Original answer: Let's call the players Alice and Bob.  Alice goes first, because her name is alphabetically first.  I'll assume that Bob gets to know what number Alice picked.
First, let's work out what Bob should pick, and how much he'll win if he does so.  If Alice picks $n$, Bob hould pick either $n-1$ or $n+1$.   If Bob picks $n-1$, he wins with any number up to $n-1$; if he picks $n-k$ he wins with any number up to $n - k/2$, which is at most $n-1$.  So Bob should prefer picking $n-1$ to any smaller number.  Similarly he should prefer picking $n+1$ to any bigger number.
Now, if Bob picks $n-1$, he has probability $1/30$ of winning $1$, probability $1/30$ of winning $2$, and so on up to $n$.  So Bob's expected winnings in this case are 
$$ {1 \over 30} \left( 1 + 2 + 3 + \cdots + (n-1) \right) = {1\over 30} {n(n-1) \over 2}. $$
Similarly if Bob picks $n+1$, he has probability $1/30$ of winning $n+1, n+2, \ldots, 30$.  So his expected winnings are
$$ {1 \over 30} \left( (n+1) + (n+2) + \cdots + 30 \right) = {1 \over 30} {(31+n)(30-n) \over 2}. $$
Bob should pick $n-1$ or $n+1$ according to which of these is larger.  That is, he should pick $n-1$ if
$$ {{n(n-1) \over 2}} > {(31+n)(30-n) \over 2} $$
and $n+1$ if the inequality goes the other way.  We can solve the inequality.  Expanding the numerators gives
$$ n^2 - n = 930 - n - n^2 $$
and we can cancel out the $-n$ and rearrange to get $930 = 2n^2$, or $n = \sqrt{465} \approx 21.56$.
So Bob should pick $n-1$ if $n > \sqrt{465}$ (i. e. $n \ge 22$) and $n+1$ otherwise (if $n \le 21$).  His expected winnings will be $n(n-1)/60$ if $n \ge 22$ and $(31+n)(30-n)/60$ if $n \le 21$.
Now, what will Alice choose?  Alice chooses in such a way as to minimize Bob's expected winnings, because minizing Bob's expected winnings is the same as maximizing her own.  This is because the sum of Alice's expected winnings and Bob's expected winnings is the expected number that comes up when you roll a 30-sided die.  (This is 15.5, but that's irrelevant right now.)   The function $n(n-1)/60$ is increasing with $n$, so Bob does better as $n$ increases above 22.  And $(31+n)(30-n)/60$ decreases with $n$, so Bob does better as $n$ decreases below 21.  Bob's worst number is therefore either 21 or 22.  Explicitly computing, Bob's expected winnigs are $22(22-1)/60 = 7.7$ if Alice picks $n = 22$, and $(31+21)(30-21)/60 = 7.8$ if Alice picks $n = 21$.  Therefore Alice will pick $n = 22$, shd expected to win $15.5 - 7.7 = 7.8$, and Bob expects to win $7.7$.    
Finally, a player given the choice of going first or second will choose to go first (that is, to be Alice).  This depends on the fact that the number of sides of the die is $k = 30$, and in particular on where $\sqrt{k(k+1)/2}$ falls relative to the integers on either side of it.
