This is a small project implementing dominos using the functional programming language, haskell.
-
Download and install GHCI (https://www.haskell.org/platform/)
-
Clone this repository.
-
Start GHCI in the root directory of this project (using command prompt), loading in the DomsMatch.hs file.
$ ghci DomsMatch.hs
OR
$ ghci
thenPrelude> :l DomsMatch.hs
-
Call the 'domsMatch' function with two players (listed below), the number of games to play and the random seed (e.g.
domsMatch hsdPlayer randomPlayer 100 42
) -
The result will show how many games each player won respectively (e.g. '(97, 3)' means that P1 won 97 games, P2 won 3 games.
The list of available players is:
- randomPlayer - plays any playable domino from hand
- hsdPlayer - plays the highest scoring playable domino from hand
- winPlayer - tries to play (5,4) if in hand, then plays like hsdPlayer until score is >=53, then tries to play domino to score 61, otherwise plays hsd
- getClosePlayer - same as winPlayer apart from including a tactic where if it is not possible to score 61 then try to get score 59, else play hsd
- blockPlayer - same as winPlayer apart from including a tactic where if the opposing player knocked on its last move, if possible, play a domino that will keep the ends of the board the same, blocking the opposing player
- superPlayer - implements all the tactics from blockPlayer, getClosePlayer and winPlayer
- blockOPWinPlayer - same tactics as winPlayer apart from including a tactic where if the opponent's score is 53 or above, if possible only play dominos that will block the other player from winning