general-games 1.0.2 → 1.0.3
raw patch · 5 files changed
+37/−33 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +1/−1
- general-games.cabal +2/−2
- src/Game/Implement/Card.hs +2/−0
- src/Game/Implement/Card/Standard.hs +4/−2
- test/Spec.hs +28/−28
README.md view
@@ -1,7 +1,7 @@ general-games ============= -[](https://travis-ci.org/cgorski/general-games)+[](https://hackage.haskell.org/package/general-games) [](https://www.stackage.org/package/general-games) [](https://travis-ci.org/cgorski/general-games) * [Description](#description) * [Contribute](#contribute)
general-games.cabal view
@@ -1,5 +1,5 @@ name: general-games-version: 1.0.2+version: 1.0.3 synopsis: Library supporting simulation of a number of games homepage: https://github.com/cgorski/general-games bug-reports: https://github.com/cgorski/general-games/issues@@ -45,7 +45,7 @@ , HUnit , hspec , MonadRandom- ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N -O+ ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N1 -O default-language: Haskell2010 source-repository head
src/Game/Implement/Card.hs view
@@ -168,6 +168,8 @@ lowestCardBy o cl = minimumBy (compareCardBy o) cl sortCardsBy o cl = sortBy (compareCardBy o) cl +-- |+-- Orderings dependent on the specific value type of a Card class (OrderedCard c o) => OrderedValuedCard c o vt where -- | -- Return an Int based on a card, an ordering and a value type.
src/Game/Implement/Card/Standard.hs view
@@ -111,7 +111,7 @@ return $ toEnum randomn -- |--- Return a list of unique numbers of length n, within range r and s.+-- Return a list of unique numbers, of length s, drawn without replacement from the set [n..m] uniqueNumList :: RandomGen g => Int -> Int -> Int -> Rand g (Maybe [Int]) uniqueNumList numToReturn n m = if (numToReturn > ((m-n)+1)) || (numToReturn < 0)@@ -120,7 +120,9 @@ do deck <- shuffleM [n..m] return $ Just $ take numToReturn deck-+ +-- |+-- Return lists of lists of unique numbers, of length [s], drawn without replacement from the set [n..m] uniqueNumLists :: RandomGen g => [Int] -> Int -> Int -> Rand g (Maybe [[Int]]) uniqueNumLists numToReturn n m = if ((sum numToReturn > ((m-n)+1)) || (length $ filter (\x -> x <= 0) numToReturn)>0)
test/Spec.hs view
@@ -27,8 +27,8 @@ allTwoPairCountExpected = 123552 allPairCountExpected :: Int allPairCountExpected = 1098240--- allHighCardCountExpected :: Int--- allHighCardCountExpected = 1302540+allHighCardCountExpected :: Int+allHighCardCountExpected = 1302540 royalFlush :: [PlayingCard] royalFlush =@@ -81,28 +81,28 @@ [PlayingCard Three Clubs, PlayingCard Four Clubs]) --- confirmDisjoint :: (Int, Bool)--- confirmDisjoint =--- let mfunc1 hand = [mkRoyalFlush hand,--- mkStraightFlush hand,--- mkFourOfAKind hand,--- mkFullHouse hand,--- mkFlush hand,--- mkStraight hand,--- mkThreeOfAKind hand,--- mkTwoPair hand,--- mkPair hand,--- mkHighCard hand]--- maybem (Just _) = 1--- maybem Nothing = 0--- countJust hand = sum $ map maybem $ mfunc1 hand--- allSums = map countJust allPossibleHands--- collect _ (outsum, False) = (outsum, False)--- collect (x:xs) (outsum, _) =--- collect xs (x+outsum, if x==0 || x==1 then True else False)--- collect [] output = output --- in--- collect allSums (0, True)+confirmDisjoint :: (Int, Bool)+confirmDisjoint =+ let mfunc1 hand = [mkRoyalFlush hand,+ mkStraightFlush hand,+ mkFourOfAKind hand,+ mkFullHouse hand,+ mkFlush hand,+ mkStraight hand,+ mkThreeOfAKind hand,+ mkTwoPair hand,+ mkPair hand,+ mkHighCard hand]+ maybem (Just _) = 1+ maybem Nothing = 0+ countJust hand = sum $ map maybem $ mfunc1 hand+ allSums = map countJust allPossibleHands+ collect _ (outsum, False) = (outsum, False)+ collect (x:xs) (outsum, _) =+ collect xs (x+outsum, if x==0 || x==1 then True else False)+ collect [] output = output + in+ collect allSums (0, True) isUnique :: Eq a => [a] -> Bool isUnique lst = f lst True where@@ -298,8 +298,8 @@ describe "Game.Game.Poker allPossibleHands / mkHand / isHand functions" $ do--- it "confirms that sets of each hand are disjoint and that total count correct" $ do--- confirmDisjoint `shouldBe` (allHandsCountExpected, True)+ it "confirms that sets of each hand are disjoint and that total count correct" $ do+ confirmDisjoint `shouldBe` (allHandsCountExpected, True) it "confirms the total number of poker hands" $ do allHandsCount `shouldBe` allHandsCountExpected it "confirms the total number of royal flushes" $ do@@ -320,8 +320,8 @@ (length allTwoPair) `shouldBe` allTwoPairCountExpected it "confirms the total number of pairs" $ do (length allPair) `shouldBe` allPairCountExpected--- it "confirms the total number of high card hands" $ do--- (length allHighCard) `shouldBe` allHighCardCountExpected+ it "confirms the total number of high card hands" $ do+ (length allHighCard) `shouldBe` allHighCardCountExpected