-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.hs
More file actions
39 lines (28 loc) · 1.22 KB
/
Main.hs
File metadata and controls
39 lines (28 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module Main (main) where
import CardDeck (Deck,createOrderedDeck,getCard)
import Card (Card)
import Hand (Category(..),Hand(..),mkHand)
import Choose (combinations)
import SimpleEvaluator (NaiveEvaluator(..), naiveEvaluator)
import CactusKevEvaluator (CactusKev(..), cactusKevEvaluator)
import HandEvaluator (Evaluator(..))
import Data.Map (Map)
import qualified Data.Map as M
import Data.List (foldl')
type HandCounts = Map Category Int
insertCategory :: HandCounts -> Category -> HandCounts
insertCategory handCounts category = M.insertWith' (+) category 1 handCounts
tupleUp :: Deck -> [Int] -> (Card,Card,Card,Card,Card)
tupleUp dk [a,b,c,d,e] = (getCard dk a,getCard dk b,getCard dk c,getCard dk d,getCard dk e)
tupleUp _ _ = error "Only works with lists of size 5"
getCategories :: (Evaluator a) => a -> [Hand] -> HandCounts
getCategories ev hands = foldl' insertCategory M.empty (map (getCategory ev) hands)
main :: IO ()
main = do
let d = createOrderedDeck
cards = map (mkHand . tupleUp d) $ combinations (5 :: Int) 52
-- naiveCategories = getCategories naiveEvaluator cards
cactusKevCategories = getCategories cactusKevEvaluator cards
-- print naiveCategories
print cactusKevCategories
return ()