Learn to Program: The Fundamentals // Assignment 3

Preface

Required Preparation

This handout assumes that you have watched all the week 6 videos and also done the week 6 exercise. If you read this handout before you've done all of that, please come back and re-read it after you've passed the week 6 exercise.

No printing!

Don't call print anywhere in your code. By now, you should be using the visualizer or the debugger to figure out what your code is doing.

Frequently-Asked Questions

We have started a FAQ for A3. Check this first if you have a question about A3.

A3 Problem Domain: Word Search Game

For A3, you will implement a word search game. The game involves an rectangular board of uppercase letters that is read from a file. For example, here are the file contents representing a (tiny) 2 row by 4 column board:

ANTT
XSOB

The game also involves a non-empty words list read from a file. For example, here are example file contents for a words list:

ANT
BOX
SOB
TO

To make it a bit more challenging, there may be words in the words list that do not appear in the board, and the word list is not shown to the players.

The object of the game is for the players to view the board and find words (remember that the words list is unknown to the players). Words may be contained in rows (from left to right) or columns (from top to bottom), but not backwards. When a player correctly guesses a word that occurs in the words list, that player is awarded points according to a scoring system described in the starter code. The game ends when all words on the board that appear in the words list have been guessed.

The player with the highest score wins.

The words from the words list and the letters of the board are made up of alphabetic, uppercase characters.

Terminology in this handout


What to do

Step 1: Download the starter code

In this assignment, we are providing starter code:


Step 2: Complete the functions in a3.py.

The starter code contains a header and a docstring for each function in the list below, so the descriptions are not repeated here. Each docstring contains one example call. Before implementing a function, you should add additional examples in order to gain a better understanding of that function.

We recommend that you work on the functions in the order that they are listed in the starter code. (Unless you're stuck on one: you may want to move on and come back later.) As usual, once you finish writing a function, in IDLE, choose Run -> Run Module and test that function by calling some example function calls in the shell. You can also submit your assignment at any point to see whether you're on the right track: remember, you can submit once every hour up until the deadline. If the example calls return the expected results and you pass all the tests when you submit, move on to the next function. Otherwise, modify your code and repeat the tests.

It will be useful to call some of these functions when implementing other functions. Here is some information about how the functions relate to each other and how they are used in the game:


Step 3: Submit your work

Go to the Assignments page and click the appropriate Submit button. Choose your completed a3.py file. It should be marked within a few minutes. You can see your results by clicking on your Score.

You can submit a3.py once every hour. Notice that this means that you can submit a lot of times before the due date if you start early. You can even submit before you've finished all of the functions. We will take the highest score out of all of your submissions.


Fun stuff: play the game!

This will not work correctly until you have finished the rest of the assignment!

We provide a driver for the game. Download a3_driver.py. Save it in the same directory as your a3.py file. In IDLE, run a3_driver.py and play your game!