Début du mini-projet de Haskell !

This commit is contained in:
2022-01-09 00:24:34 +01:00
parent ac1d6b24e2
commit abea7be63b
8 changed files with 744 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
module Cartes where
import Data.Set as Set
data Figure = Valet | Cavalier | Dame | Roi deriving (Eq, Ord, Show)
data Couleur = Pique | Coeur | Carreau | Trefle deriving (Eq, Show, Ord)
data Carte = Valeur (Int, Couleur) | Tete (Figure, Couleur) | Atout Int | Excuse deriving (Eq, Ord)
instance Show Carte where
show (Excuse) = "Excuse"
show (Atout n) = (show n) ++ " d'atout"
show (Tete (f,c)) = (show f) ++ " de " ++ (show c)
show (Valeur (n,c)) = (show n) ++ " de " ++ (show c)
allFigures = [Valet, Cavalier, Dame, Roi]
allCouleurs = [Pique, Coeur, Carreau, Trefle]
deck :: Set Carte
deck = fromList ([Valeur (n,c) | n<-[1..10], c<-allCouleurs] ++ [Tete (f,c) | f<- allFigures, c<- allCouleurs] ++ [Atout n | n<-[1..21]] ++ [Excuse])
+4
View File
@@ -0,0 +1,4 @@
import Cartes
main :: IO ()
main = putStrLn (show (deck))
+8
View File
@@ -0,0 +1,8 @@
module Tarot where
import Cartes
class JoueurIA s where
-- Distrib crée l'état initial lorsque les cartes ont été distribuées.
distrib :: [Carte] -> s
jouer :: s -> [Carte] -> (Carte, s)