Mastermind Game

From UBC Wiki

What is the problem?

Mastermind is a simple logic 'code-breaking' game, where a player must attempt to guess the order and colour of four pegs. The other player (the program, in this case) gives feedback after every guess that lets the player know the number of pegs that are in the correct spot, and how many are the correct colour in the wrong location. We will implement either a terminal or UI-based application that lets a user play this game against the program.

What is the something extra?

We implemented customization options to the game, so that the user is able to choose how many colours the game is played with, and how long the winning sequence is. This allows the user to control the level of difficulty of the game. Additionally, we implemented a hint feature to give players a hint, telling them the correct location of a peg if they are struggling with the regular feedback.

What did we learn from doing this?

(This should be written after you have done the work.) What is the bottom-line? Is functional programming suitable for (part-of) the task? Make sure you include the evidence for your claims.

Logic programming was well suited for this task. While we had a bit of a learning curve in adapting how we would write code in Prolog versus object-oriented languages, Prolog was ultimately very good for this game.

One thing we did learn was that GUI's are quite difficult to work with in Prolog. For a time we had hoped to create a GUI for the game, but due to the limited libraries available (and our challenges with using the pce library on macOS), we ultimately decided that this would not be feasible.

Work division

How was the workload divided? Who did what? (This can be in a private communication to the TA if you do not want it to be public).

Sofia: Wrote all code for basic game (I/O, gameplay, feedback, etc), customization feature for number of colours, testing/bug fixing, worked on GUI before we decided it was not feasible.

Rudy: Wrote the code to implement the hint system. Experimented with different ways to provide hints and what kind of hint to give. Settled on a system that gives player the location of a correct colour, up to a certain number of allowed hints.

Justin: Wrote specification, and the customization functionality for the game where we can change the number of pins, testing/bug fixing, did investigation into GUI and decided not to go with it.

Links to code

https://github.com/sedaschle/mastermind