Created
March 11, 2010 06:37
-
-
Save timothypratley/328912 to your computer and use it in GitHub Desktop.
This file contains 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
;; Mike Erickson | |
(def cards (ref nil)) | |
(defn build-test-deck | |
[] | |
[[8 \S] [2 \C] [6 \C] [8 \D] [6 \H] [\A \H] [8 \C] [7 \H] [\A | |
\C] [2 \D] [\K \H] [10 \D] [4 \H] [6 \S] [2 \H] [\Q \H] [3 \D] [10 \S] | |
[3 \S] [1 \S] [\A \D] [9 \H] [\J \S] [4 \D] [1 \C] [\K \D] [2 \S] [1 | |
\H] [5 \C] [\K \C] [10 \H] [9 \D] [9 \C] [\J \D] [\Q \C] [7 \S] [7 \D] | |
[9 \S] [1 \D] [\J \H] [10 \C] [6 \D] [\K \S] [5 \H] [\J \C] [7 \C] [4 | |
\C] [\Q \D] [\Q \S] [5 \D] [\A \S] [3 \C] [3 \H] [4 \S] [8 \H] [5 | |
\S]]) | |
(defn deal | |
([] | |
(dosync | |
(alter cards assoc | |
:deck (build-test-deck) | |
:house (list) | |
:player (list))) | |
(deal 2 :player) | |
(deal 2 :house)) | |
([n hand] | |
(dosync | |
(alter cards assoc | |
hand (concat (get @cards hand) (take n (get @cards :deck))) | |
:deck (take-last (- (count (get @cards :deck)) n) (get @cards :deck)))))) | |
(deal) | |
(deal 2 :player) | |
(deal 2 :house) | |
(deal 2 :player) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment