Course:CPSC312-2021/Mastermind

From UBC Wiki

Authors: Andy Dong, Madeline, Yang

What is the problem?

Mastermind is a logic-based code-breaking game. The program will pick a random sequence of four integers from 1-6 (no repeats) to be the code. The objective of the game is for the user to guess this code. The program will return clues after each guess (# of correct colours, # of correct colours in correct spots) to help the user find the sequence. The user will be given 10 attempts of guessing the sequence before it is revealed.

What is the something extra?

We included graphics, randomness and user input in our code as the "something extra". We also created a menu of different game options in Prolog (level of difficulty, relating to the number of guesses, and a game instructions page). We used backtracking to keep track of the total number of guesses.

What did we learn from doing this?

We found that logic programming with Prolog can successfully be used for recreating a version of Mastermind. In this project we learned how to use backtracking, user input and randomness to create a turn-based game. However, Prolog's syntax and variable tracking, while very well-suited to databases, is less natural for interactive games than functional programming is. In the future, we would like to update the game board with to show the user's guesses in order as they come up.

Links to code etc

https://github.com/ayyydong/Mastermind