Cribbage Discard Pro: Methodology
Here's the basic algorithm:
- Select two cards to discard from the user's hand.
- Select a turn card from the remaining deck.
- Select two cards from the remaining deck to act as the opponent's discard.
- Score the hand and the crib for this combination.
- If it's the user's crib, record the sum of the hand and the crib. If it's not, record the difference.
- If this combination produces a maximum or minimum hand score, crib score, or sum/difference of the two, record this value. (If it's a maximum hand or hand-crib sum/difference, also record the turn card and opponent's discards.)
- Repeat for all possible opponent discards, for all possible turn cards, and for all possible user discards.
- If it's the user's crib, suggest they discard the combination with the highest average value for the sum of the hand and the crib. If it's not, suggest the one with the highest average value for the difference between the hand and the crib.
Because it's more or less likely that your opponent will discard certain combinations (e.g. a pair of fives if it's your crib), a weighting system is used when calculating the average crib score and the average hand-plus-crib/hand-minus-crib score. To calculate these weights, the algorithm analyzed large batches of random six-card hands to develop static weighting tables of discard probabilities, iterating this process until the values stabilized. (The initial tables were based on the discard tables kindly provided by Michael Schell of cribbageforum.com.)
The scores are then re-weighted to reflect the probability of the opponent discarding two suited cards. Due to the statistical improbability of a flush in the crib, the average crib score increases by only 0.04 points with suited discards, so this second weighting factor is almost insignificant.
Since these weights are applied to the opponent's discards, the algorithm inherently assumes that the opponent is an expert-level cribbage player.
The algorithm does not at all consider pegging capabilities when selecting the best discards. For advice on discarding with pegging in mind, see for example DeLynn Colvert's "magic eleven" tip.