CSC207 - Project 2
The Word of the Day
Assigned Oct 19th 12 p.m.
Due October 28th 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 COMBINATION.
In particular, this project will cover the following concepts we have discussed in class:
- Booleans
- Functions
- Control Statements
- Sentinel Loops
- Definite Loops
- Lists
- File input
- Time
Description
The game of COMBINATION is a timed exercise similar to
Boggle. A player is given a word and a time limit, and the player must write down all
possible words of three letters or more that can be made using the individual letters in the original word. At the end of the time limit,
a player's score is the number of unique words they found divided by the total number of possible
words. A letter can only be used once, unless
there are multiple copies of the letter in the original word.
For example the player is given the word JUDGING. In the course of a minute, the player identifies
dig
gun
jug
ding
The player missed the following words:
din
dug
dun
dung
gig
gin
gnu
jig
for a score of 4 / 12 = 33%
Coding
For this assignment we will be writing a Python program to let a user play a timed version of
COMBINATION.
Download the text file english-words.txt
and the python module
dictionary.py
files.
You must create a python program
called combination.py
. It will:
- Tell the user about the game.
- Ask the user what level of difficulty they would like to play. Easy difficulty is with
starting words of length 5-6, medium is with starting words of length 7-10, and hard is with
starting words of length 11 or greater.
- Generate a random starting word of the proper difficulty, and start the timer. Our implementation will give the player 1 minute.
- While there is still time left, tell the user how much time is left and ask the user for a word. If it is possible to create this word
using letters from the starting word, it is a valid word, it is long enough, and has not been
given before by the user, accept it and add it to the list of found words.
- When time is up, print the player's score (i.e. the number of unique valid subwords they found divided by the total number of possible words)
- Tell the user which words they missed.
- Finally, ask the player if they would like to play again. If so, play the game again.
Your code should make good use of functions, as there are clear pieces of the game which
are common to all the above variants. Additional dictionary functions should be added
to dictionary.py
. 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
Log in to cs.centenary.edu
through either Secure FTP or WinSCP using your
cs login and password. Create a subdirectory from csc207
called project2
. Copy your combination.py
project into this directory, along with any other files
you need to run your code. Make sure
you have followed the Python Style Guide, and
have run your project through the Automated Style Checker.
You must hand in:
- combination.py
- dictionary.py
and any other files necessary to run your code.
© Mark Goadrich 2009, Centenary College of Louisiana