# Card flipping without replacement, comparison expected value

Problem:
Suppose a standard deck of playing cards is shuffled and dealt into one card piles on a table.
Each player flips cards one by one.
The players compare the values of the cards (J=11, Q=12, K=13).
If a player has a card higher than the other player's, the difference represents money in dollars the player with the lowest card owes.
The revealed cards are removed from the game.
Any player can end the game after a round where cards have been flipped.

If both players are rational and count the cards that have been revealed, when would it be rational to stop the game if:
* Both want to maximize dollars earned
* Both want to lose as least as possible.

Using "+2" to mean P1 has earned a net of 2 dollars, and "-2" to mean P1 owes a net of 2 dollars.

ex.
Game begins.
P1 flips 7. P2 flips 9. Net: -2
P1 flips 4. P2 flips 1. Net: +1
...

Solution Ideas:
I do assume both players are greedy and will not cash out as soon as any amount is earned (ends at first draw), but it certainly is a practical strategy. (say the first round, P1 flips K and P2 flips 1)

Try with a smaller set of cards to try and find a pattern. (ex. 4 aces, 4 twos, 4 threes)
Calculate the expected value the game would earn and as soon as the value is reached for either player, end the game.
Try with replacement first as an estimate (cards wouldn't be removed from the game, but would be reshuffled)
Simulate the experiment through programming where draws are exhausted and identify the step for each experiment where the absolute value was the maximum for the entire game.

Ideas are appreciated. A full solution is not required.

#### romsek

MHF Helper
This is solely on intuition as yet but given any subset of the deck I believe the probabilities of player 1 winning the next round is equal to that of player 2.
Previously drawn cards definitely affect the contents of the subset but have no effect on the order of cards within drawn pairs.

To demonstrate my point suppose there are only 2 cards left (assume there is a winning card). Both players have observed 25 draws. Which card is optimal to pick?
Neither. Both have 50% chance of being the winning card. Both players know what the two cards are, but they don't know which is which, and both options are equally likely.

You don't mention what the rule is in your game when the two players wish to choose the same card. How is that situation handled?

This is solely on intuition as yet but given any subset of the deck I believe the probabilities of player 1 winning the next round is equal to that of player 2.
Previously drawn cards definitely affect the contents of the subset but have no effect on the order of cards within drawn pairs.

To demonstrate my point suppose there are only 2 cards left (assume there is a winning card). Both players have observed 25 draws. Which card is optimal to pick?
Neither. Both have 50% chance of being the winning card. Both players know what the two cards are, but they don't know which is which, and both options are equally likely.
I like the idea of using the case of two remaining cards to build some intuition.
Suppose the net amount player one made was N.
Even if the difference of the last two cards exceeded N, it might still be considered rational for a greedy player to take the 50/50 (about double or nothing)
I guess it depends on the player then.
If there was some expected value for the game, say X, as soon as a player made more than that, it could be consider 'rational' to stop, but hardly conclusive.

You don't mention what the rule is in your game when the two players wish to choose the same card. How is that situation handled?
Good catch. It wasn't.
Originally the game was setup so that the shuffled deck was split into two equal piles, and each player chooses one, and the players can't change the order of the deck.
I wanted to use the intuition that players still choose from the same pool of cards and the probability collapses upon revealing cards, but perhaps I can't.

I programmed a simulation and got an experimental maximum gained value for player 1 is about +18 over 10,000 trials (all draws are completed).
Note that this doesn't mean the other player will allow +18.
Runs in Online Python Compiler - online editor
There is also high variance. This game would have no appeal in casinos or on the street.

Python:
from random import choice

card_numbers = range(1,14)
trial_highest_value_list=[]
trial_count=10000

for trial_number in range(trial_count):
deck = {}
for number in card_numbers:
deck[number] = 4

# print(deck)
net = 0
net_list = []

while deck:
value1=choice(list(deck.keys()))
deck[value1] -= 1
deck = { k : v for k,v in deck.items() if v != 0}
# print(deck)
value2=choice(list(deck.keys()))
deck[value2] -= 1
deck = { k : v for k,v in deck.items() if v != 0}
# print(deck)
# print("Value 1 is "+ str(value1))
# print("Value 2 is "+ str(value2))
net += value1-value2
net_list.append(net)
if not deck:
break;
# print(net_list)
highest_value = max(net_list)
# print(highest_value)
trial_highest_value_list.append(highest_value)

# print(trial_highest_value_list)
print(sum(trial_highest_value_list)/len(trial_highest_value_list))