Please read through the entire lab before starting! Also, as always, run update21
to create your cs21/labs/07
directory. Create your programs for lab 7 in this directory. Note that this is a two-part lab, split over two weeks.
For the first week you will focus on using top-down design to create the overall structure of the program. Once your proposed structured has been reviewed and approved by your professor, you will use bottom-up implementation and unit testing to complete the full program.
You have two weeks to complete the full program. The first week is for the design, and the second for the full game. Your initial top-down design is due this Saturday (Nov 4) and the full implementation the following week (Nov 11). It is highly recommended that you submit your top-down design a few days before the due date so that we have time to give you feedback, before you start your full game implementation. If you submit your design on Sat, Nov 4, at midnight, it might take us a few days get to it and send you comments on your design.
See below for the design requirements.
When my kids were younger, it was always a challenge to keep them occupied (i.e., not screaming and kicking) in a restaurant, while waiting for the food to arrive. We used to play word games on the napkins, and one of our favorites was making and solving 3x3 word squares, like this:
The clues above are for the words. If there are three clues, that means the words are all three letters long. And each word must fit both horizontally and vertically in a 3x3 box (i.e., word 1 fills in row 1 and column 1 of the box, word 2 fills row 2 and column 2, etc). Here's the solution for the above puzzle (note: we are not using graphics for this lab...all output is just to the terminal):
The goal is to solve the word square, given the clues. Our program will read the clues and answers from a file, present the clues to the user, and allow them to solve the puzzle by making guesses for each word.
Here are a few examples of the running program, to help you see how things should work. Pay attention to how the game proceeds, and how input from the user is handled.
You have some freedom in how you want your game to look. Here are our requirements for the game:
puzzle.txt
)puzzle.txt
file has one line for each clue/answer, where the clue and answer are separated by a colon (:
)str
and list
methods, now that you know how objects workYou should complete your top-down design (TDD), submit it, and obtain feedback on it before beginning the full game implementation. Special procedures for this two-week lab:
design-3square.py
firsthandin21
to turn it in! After running handin21
, send your professor a short email, letting them know your design is done. We will take a look at each design and send you comments (usually within a day or two).3square.py
(ex: cp design-3square.py 3square.py
) and implement the full game in 3square.py
(i.e., leave design-3square.py
as is)main()
should be completely written, and should perform high-level steps without focusing on detailsmain()
should call the functions you create in your design, in the appropriate order, and with arguments that match parameters. Return values should be saved in main(), even if you don't do anything with them yet.Here is a simple example of a top-down design.
And here is an example of a running 3square top-down design.
Your design doesn't have to match this exactly, but should allow the user to input some choices, and should show the (fake) game progress.
I enjoy making the puzzles as much as solving them. Try making your own puzzle.txt
files (puzzle1.txt, puzzle2.txt, etc). Allow the user to input the puzzle file name, or ask them if they want to play again and use a different file.
Or create a 4x4 puzzle, and modify your program to work with both 3x3 and 4x4 puzzles.
After you have turned in the full program, please edit the QUESTIONS-07.txt
file in your cs21/labs/07
directory and answer the questions in that file.
For this lab, run handin21
to turn in your design and then send your lecture professor a quick email letting them know you turned in your design. We will take a look at each design and send you comments (usually within a day or two). Once you have our comments, copy the file (cp design-3square.py 3square.py
), finish implementing the game (in 3square.py
) and then run handin21
again.