Add cards packs
This commit is contained in:
parent
7de6040289
commit
59beaa5cc9
1 changed files with 11 additions and 2 deletions
13
CCard.hs
13
CCard.hs
|
@ -1,7 +1,7 @@
|
|||
module CCard where
|
||||
|
||||
import Data.Word (Word64)
|
||||
import Data.Bits (setBit, (.|.))
|
||||
import Data.Bits (setBit, (.|.), (.&.), shift, xor)
|
||||
|
||||
newtype Card = Card Int
|
||||
type Pack = Word64
|
||||
|
@ -44,8 +44,17 @@ ribbons = set [14, 18, 26, 41] .|. blue .|. poetry
|
|||
lights :: Pack
|
||||
lights = set [3, 11, 31, 43, 47]
|
||||
|
||||
lastIndex :: Int
|
||||
lastIndex = 47
|
||||
|
||||
plain :: Pack
|
||||
plain = pack `xor` (lights .|. ribbons .|. animals) .&. pack
|
||||
|
||||
pack :: Pack
|
||||
pack = 1 `shift` (lastIndex + 1) - 1
|
||||
|
||||
pair :: Card -> Card -> Bool
|
||||
pair card1 card2 = flower card1 == flower card2
|
||||
|
||||
cards :: [Card]
|
||||
cards = map Card [0..47]
|
||||
cards = map Card [0..lastIndex]
|
||||
|
|
Loading…
Reference in a new issue