Permalink
Browse files

refactored naming in duplicates (pairs, three-of-kinds etc.) hand mat…

…ching
  • Loading branch information...
1 parent ee2a05c commit a47a69d6b0ec7d38a7f50dcb82ffcd58b4667c45 @ramik committed Sep 10, 2011
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/PokerCardEvaluator/PokerCardEvaluator.fs
@@ -22,15 +22,15 @@ type Hand = | OnlyShark of Shark
let EvaluatePairs (hand : seq<Card>) =
let sortedpairs = hand |> Seq.countBy (fun c -> c.FaceValue) |> Seq.sortBy (fun (b, a) -> -a * 20 - b) |> Seq.toList
match sortedpairs with
- | (a, b) :: (c, d) :: (e, f) :: _ when b = 2 && d = 2 ->
- Some(TwoPairs(Pair({ value = a; shark = None }),
- Pair({ value = c; shark = None }), Some(e)))
- | (a, b) :: (c, d) :: _ when b = 2 -> Some(Pair({ value = a; shark = Some(c) }))
- | (a, b) :: (c, d) :: _ when b = 3 && d = 2 ->
- Some(FullHouse(ThreeOfKind({ value = a; shark = None }),
- Pair({ value = c; shark = None })))
- | (a, b) :: (c, d) :: _ when b = 3 -> Some(ThreeOfKind({ value = a; shark = Some(c) }))
- | (a, b) :: (c, d) :: _ when b = 4 -> Some(FourOfKind({ value = a; shark = Some(c) }))
+ | (firstValue, countA) :: (secondValue, countB) :: (thirdValue, _) :: _ when countA = 2 && countB = 2 ->
+ Some(TwoPairs(Pair({ value = firstValue; shark = None }),
+ Pair({ value = secondValue; shark = None }), Some(thirdValue)))
+ | (firstValue, count) :: (secondValue, _) :: _ when count = 2 -> Some(Pair({ value = firstValue; shark = Some(secondValue) }))
+ | (firstValue, countA) :: (secondValue, countB) :: _ when countA = 3 && countB = 2 ->
+ Some(FullHouse(ThreeOfKind({ value = firstValue; shark = None }),
+ Pair({ value = secondValue; shark = None })))
+ | (firstValue, count) :: (secondValue, _) :: _ when count = 3 -> Some(ThreeOfKind({ value = firstValue; shark = Some(secondValue) }))
+ | (firstValue, count) :: (secondValue, _) :: _ when count = 4 -> Some(FourOfKind({ value = firstValue; shark = Some(secondValue) }))
| _ -> None
let EvaluateHand (hand : seq<Card>) =

0 comments on commit a47a69d

Please sign in to comment.