In particular, this project will cover the following concepts we have discussed in class:
Word Bulls and Cows is a word game where one player attempts to guess the secret word of the other player. The game is similar to Mastermind.
First the players decide on the length of the words to be used in the game, between three and seven. One player chooses a secret word of that length, and the other player tries to guess this word.
When the guessing player chooses a word, the other player gives them feedback in the form of Bulls and Cows.
When the guessing player chooses the secret word, the game is over. Players try to guess the word in the least number of guesses.
An example game for four letter words is shown below, where the secret word is BATH.
Round | Word | Bulls | Cows |
---|---|---|---|
1 | DART | 1 | 1 |
2 | PART | 1 | 1 |
3 | ROMP | 0 | 0 |
4 | READ | 0 | 1 |
5 | TANK | 1 | 1 |
6 | RATS | 2 | 0 |
7 | BATS | 3 | 0 |
8 | BATH | 4 | 0 |
Note: out of kindness, if the user tries to guess a word that consists only of known dud letters (letters that were previously part of a word that had neither bulls nor cows) they are given another chance without penalty.
You must create a python program
called moo.py
. It will:
Your code should make good use of functions, as there are clear pieces of the game which are repeated. Using functions will reduce the amount of code you need to write as well as make your program easier to debug. However, do not write spaghetti code, where functions call each other back and forth to continue execution of the program; let your functions naturally return values and use loops to repeat the game turns.
Your code must check all user input for validity and reprompt them for correct input if any mistakes are made.
Make sure you have followed the Python Style Guide, and have run your project through the Automated Style Checker.
You must hand in: