CSCI 150 - Project 2
Word Bulls and Cows

Assigned Oct 20th
Due October 29th 5 p.m.


Overview

For this project, we will explore more complex interactions with the user by implementing control statements and loops. We will create a program for one user to play the game Word Bulls and Cows.

In particular, this project will cover the following concepts we have discussed in class:

Description

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.

RoundWordBullsCows
1DART11
2PART11
3ROMP00
4READ01
5TANK11
6RATS20
7BATS30
8BATH40

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.

Coding

For this assignment we will be writing a Python program to let a user repeatedly play Word Bulls and Cows against the computer.

You must create a python program called moo.py. It will:

  1. Tell the user about the game.
  2. Ask the user how long the words will be for this game.
  3. Select a random word of the right length from the dictionary.
  4. Tell the user the current round, and have the user guess a word.
  5. If the word consists of only dud letters, let them have another chance.
  6. When the user enters the correct word, the game is complete.
  7. Otherwise, count the number of bulls and cows in the word and tell the user their score.
  8. If none of the letters scored, then add all of the letters of the guess to the dud pile.
  9. As long as the player is not correct, have them guess another word and repeat.
  10. When correct, ask the user if they would like to play again. If so, start all over.

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.

What to Hand In

Handin your code via Moodle.

Make sure you have followed the Python Style Guide, and have run your project through the Automated Style Checker.

You must hand in:

and any other files necessary to run your code.
© Mark Goadrich, Hendrix College