A simple CL program that counts cards and advises on whether to hit or not in a game of 十點半.
The program keeps track of a deck and your hand. There are two modes
- Hit Mode: card codes result in the corresponding card being added to the hand and removed from the deck
- Normal Mode: card codes result in the corresponding card being removed from the deck only While in Hit Mode, the program will advise you on whether to hit or not when a new card is added to the deck. Normal Mode is used to keep the deck up to date when cards are dealt to other players.
The program uses a distribution monad to model the probabilistic computation following Oleg Kiselyov's lecture at FLOLAC'16.
Make sure you have stack
installed on your system, then run
stack build
to install the necessary dependencies and create the executable. Start the CL program with
stack exec cardcounter-cl
A
Toggle between Hit Mode or Normal ModeR
Restart DeckF
Flush HandD
Show DeckH
Show HandU
Undo previous command
1
A2
2- ...
9
90
10j
Jq
Qk
Kingl
Joker