CS112_15_assignment 2B

# CS112_15_assignment 2B - CS 112 Handout#15 Spring 2003...

This preview shows pages 1–4. Sign up to view the full content.

CS 112 Handout #15 Spring 2003 Yinglin Wang CS112 Homework 2B (Boggle game) Due Thursday, March 27. Electronic submission by 5:00pm This assignment was originally developed by Todd Feldman and then enhanced by Julie Zelenski. Your mission is to write a program to play the game of Boggle™, which should help you get over any lingering doubts about the power of recursive techniques. 1. What is Boggle? The game of Boggle is played with a set of sixteen letter cubes, which are standard six-sided dice except that they are marked with letters of the alphabet instead of numbers. The cubes are rolled and arranged into a 4 x 4 square that might look like this: The object of the game is to start at one cube and then work through a chain of letters to form a word that meets the following conditions: • The word must be at least four letters long. • The path traced out by the letters in the word must be connected horizontally, vertically, or diagonally. You can ’ t skip over intervening cubes to get the next letter. • Each cube may be used only once in a given word. For example, the sample pattern contains the word PEACE as follows:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
The pattern, however, does not contain the word PLACE , which would require jumping from the P to the L and then back to the A . Similarly, it is not possible to make the word POPE , because doing so would require reusing the P . Because the computer has a complete dictionary and you do not, we ’ve tried to make the game a little more interesting by letting you find as many words as you can and then turning the computer loose to find the rest. If you ’ re thorough, you can beat the computer because it is not allowed to count words you ’ve already found. Most games, however, still end up as a rout, as illustrated by the following diagram of the Boggle display at the end of a game: The numbers on the top line represent the scores for the human and computer players, respectively. Four-letter words score 1 point, five-letter words score 2, and so forth, with each additional letter contributing one additional point. The human player in this example has found eight four-letter words and one five-letter word for a total of 9 points. 2. Overview of the requirements
Your job in this assignment is to implement the Boggle game, which requires extensive use of recursive backtracking. Because we want you to concentrate on the strategy section, we have given you the following two modules to start with: 1. The gboggle.h interface implemented by gboggle.c , which is responsible for maintaining the graphical display. 2. The lexicon.h interface implemented by lexicon.lib , which is responsible for keeping track of a list of legal words. The interfaces for these modules appear in section 3. Even though these modules are given to you, the remaining part of the Boggle code contains most of the interesting programming. Your code, for example, must accomplish the following tasks: • Set up the faces of the various letter cubes by reading data from a file. For each game, there are two options for setting up the cubes. The user can ask for a random board (true

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

CS112_15_assignment 2B - CS 112 Handout#15 Spring 2003...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online