Authors: Xindi Wei, Nawaratt Tonrungroj
What is the problem?
Bingo is a game of probability which has many versions with different rules. The most popular ones are UK's 90-ball game and US' 75-ball . The most common Bingo card contains a grid with random numbers. A caller will be drawn one number at a time and a player needs to have matched numbers in a particular pattern on a grid to win the game.
Our Bingo game will be based on above common rule with following modifications:
- The player will play against AI/computer.
- The player can choose the number of dice rolling, e.g. 10, 15 or 20 times.
- The player and AI/computer take turns rolling a dice. The results of each roll will be recorded.
- The Bingo card is a 3x3 grid with different criterias. Here is an example:
|get “1” once||get odd number 4 times||get sum of 20|
|get same number three times||get Multiples of 4 three times||get even number once|
|get same number twice sequentially||get prime number twice||get “6” twice|
What is the something extra?
A Bingo star ✯ will be earned when the dice rolling results matches one of the following patterns
Our challenge is to find an algorithm to compute the number of bingo efficiently.
- Match one column
- Match one row
- Match one diagonal
- To win the game, the player needs to earn more Bingo stars than AI/computer.
What did we learn from doing this?
The most challenging issue we experienced in this project was importing System.Random for generating a random integer which is solved by using cabal. Since taking user’s input and showing them the result is the main interaction in our project, we have learned more about IO and using the do block in Haskell.
It is intuitive to put one task per one function when using a functional programming language like Haskell. This characteristic as well as pattern matching allow us to build a game structure that is clean, concise and easy to read. We are satisfied with using Haskell in this project as so far we are able to accomplish every task we aim to do.