- I'm building a game (kind of poker) in haskell but i'm new to haskell and generally get stuck when try to think how to implement a thing in purely functional language.*
Game is of 3 players(Just to make it easy to explain). Two players will play from the table cards and one will play from the stack. Both kinds of players will take one card and use it if useful(replace one of your card in hand) or just dump it(if not). Winning is just full-house or a straight.
The Two of them have some
understanding
, something they agree before to help each other. Like if i took K (lets say) from table and next hand i took a 4 from the table means i'm going for a full house and hence you should help if you can in any possible way. Each of these player should help each other so that one of them should win before the player playing with the stack but not at the cost of oneself.Table has total 5 cards and so does each player
Implement Understanding between two players :
I'm stuck how to track what other player have took from the table. I'm trying to do that by adding the cards to my hand itself (Virtually remembering the thing) and while dong calculations of my hand (real) i'm going to take only first five of cards and while doing calculation for helping him i'm going to drop five cards and then do calculations with that. Is there any better strategy to do the same?? It might be trivial but i'm amateur in world of haskell. If you want code I can just put it up.
basic set up of my Game :
data Card = Card {
c :: (Int, Char)
} deriving (Eq, Ord, Show)
data Deck = Deck {
d :: [Card]
} deriving (Show, Eq, Ord)
data Game = Game {
bact1Hand :: [Card],
bact2Hand :: [Card],
orgHand :: [Card],
tableCards :: [Card],
deck :: Deck
} deriving (Show, Eq, Ord)
type GameState a = State Game a`