CS 261 Lab K - Mind Reading

Due Wed Dec 03 at 3:00pm

Overview

In this lab, you will program the computer to read the user's mind (why didn't software developers do this a long time ago?) Your program will guess in advance whether the user will choose heads or tails, then get the actual response from the user. If your program guesses correctly, it gets a point; otherwise the user gets a point. The first one to 15 points wins. When run, your program might look something like this:

I am the Mind Reader!
****************************
I've made my prediction about what you will enter. Input 'h' or 't' below. 
Enter 'h' or 't': h
Fooey. My prediction was wrong.
Score is now human 1, computer 0
****************************
I've made my prediction about what you will enter. Input 'h' or 't' below. 
Enter 'h' or 't': t
I was right!
Score is now human 1, computer 1
****************************
I've made my prediction about what you will enter. Input 'h' or 't' below. 
Enter 'h' or 't': t
I was right!
Score is now human 1, computer 2

Underneath the hood, your program will be using a HashMap to track the user's responses, using that history to predict their guesses. The "mind reading" will be implemented by remembering the last four responses and the last response that followed such a "response history". Humans are not very good at producing genuinely random output, and this simple method is surprisingly effective at predicting their actions.

This lab will be completed in pairs. Partner assignments for this lab can be found on Moodle

Objectives

Necessary Files

No classes are provided; you'll need to write this up from scratch! But there is guidance below.

Assignment Details

You will need to make three (3) different classes for this program:

And that's about it! Be careful to try and keep functionality appropriately separated between classes and methods: use good coupling and cohesion!

Also be sure and test your game thoroughly: giving guesses of HTHTHTHT... or HHTTHHTT... should allow the computer to easily guess your future decision!

Extensions

There are a number of ways to improve your program's pyschic abilities, which may be worth up to 2 points extra credit:

Submitting

Make sure your name is in a class comment at the top of all your classes and upload them to the LabK submission folder on vhedwig. Make sure you upload your work to the correct folder! The lab is due at the start of class on the day after the lab.

After you have submitted your solution, log onto Moodle and submit the Lab K Partner Evaluation. Both partners need to submit evaluations.

Grading

This assignment will be graded out of 18 points: