Created
August 17, 2011 08:17
-
-
Save forki/1151080 to your computer and use it in GitHub Desktop.
A basic model for Poker in F#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Rank = int | |
type Suit = | Spades | Hearts | Diamonds | Clubs | |
type Card = Rank * Suit | |
let value = fst | |
let suit = snd | |
let A,K,Q,J,T = 14,13,12,11,10 | |
let allRanksInSuit suit = [2..A] |> List.map (fun rank -> rank,suit) | |
let completeDeck = | |
[Spades; Hearts ; Diamonds; Clubs] | |
|> List.map allRanksInSuit | |
|> List.concat | |
let isPair c1 c2 = value c1 = value c2 | |
let isSuited c1 c2 = suit c1 = suit c2 | |
let isConnected c1 c2 = | |
let v1,v2 = value c1,value c2 | |
(v1 - v2 |> abs |> (=) 1) || | |
(v1 = A && v2 = 2) || | |
(v1 = 2 && v2 = A) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment