Mastermind Has Entropy

Ali Rivera
Data Scientist

Brian Wright
Quantitative Foundation Associate Professor of Data Science, Director of Undergraduate Programs

Peter Alonzi
Assistant Professor of Data Science



University of Virginia School of Data Science logo features an orange rotunda and blue text.

Activity

Summary The goal of this assignment is for students to learn how to quantify missing information using Entropy. The method is to have them play the game Mastermind. This is a codebreaking game where the object is to determine a secret code by making a series of guesses and using the feedback from the other player to plan your next guess. As the student reduces the number of possibilities they track their progress and compute the Entropy, or, missing information. As they play they learn how to think about the relationship between their guess and their quantified benefit or information gain.

Topics Entropy, missing information, information gain, machine learning, state space

Audience Introduction to AI, cryptography, analytical thinking, could be adapted to K-12

Difficulty Moderate - Students are asked to describe the state space evolution over the course of a Mastermind game. However the connection to analyzing the number of available states in a logarithmic scale is challenging. This is mainly due to two factors. The major factor is the typical lack of familiarity with logarithmic work present in the American system. The second is that the students often think the state space description is sufficient and they do not see the value of the logarithmic analysis. That is brought out in the questions which often require assistance from the TA. This requires 1 hour in class.

Strengths Low Cost: This game is a commodity; it is easy to acquire and an individual set costs $15. In fact you can play the game without the game and just using pen and paper.
Well known: The game Mastermind is well known. There are many videos and tutorial students can watch and there is even a paper by Donald Knuth describing the game. These all provide amply supplemental materials.
Unplugged: This exercise uses physical objects. The students do not have to develop a mental model, rather they are manipulating objects in space. This lowers the overall cognitive load. Additionally it makes it easier for an Instructor to see where the students are at and assess their progress without getting right into their screen. Futhermore this allows for a follow on assignment to help reinforce the concepts where the students are asked to code. Document

Weaknesses The biggest weakness here is the concept of Entropy itself. It requires students to be familiar with probability and logarithms. Oftentimes the discussion of this lab requires the instructor to give a side explanation of logarithms.

Dependencies This activity assumes that students have some foundational prior knowledge of the following terms in the context of data science:
  • state space
  • probability
  • logarithms
Materials required for this activity are:
  • One copy of Mastermind board game (pen and paper can substitute)
  • Pen and Paper (digital option like a spreadsheet can substitute)

Variants This activity could be adapted as follows:
  • Historical Version: This game is based on an older game called "Bulls and Cows". Instructors could use the historical ruleset as a follow on assignment to assess if students can apply the concepts in a similar application.
  • Journal Club: Students could be assigned the article "The Computer As Master Mind" by Donald Knuth as a reading assignment and then discuss the article in class. (1976 Journal of Recreational Mathematics)
  • Code it up: As a follow on assignment students can code up the game and generalize the solution. Having mastered the concepts on a lab bench they now can bring them to the full computational scale. Students can compare heuristic and rules based solutions as well as practice implementing entropy based optimization.
  • New Context: As a follow on assignment students can asked to find a different application of information gain and report on it in class.

Materials

Student activity
The information that students are given - can be used as a digital or print hand-out. This contains the assignment description, instructions, questions, and rubric.