CPS 100E Fall 1999: Boggle

Due: Wednesday, December 8, by midnight

extra credit

You are to write a program that allows the computer to play boggle. Boggle is a trademark of Parker Brothers. It is a word game in which sixteen cubes (dice) have letters on each side. These are tossed, providing a 4 x 4 grid that is the playing field for Boggle. Words are formed by connecting cubes that are adjacent either horizontally, vertically, or diagonally. For example, a board is shown below on the left with the word TRADES shaded in the board on the right.


In Boggle, a letter cannot be re-used within a word. For example, the word SET can be formed in the board above, but the word SETS cannot be formed since the S cannot be re-used.


Your program should read a list of legal words from a file whose name is specified as the first argument on the command-line. Words in the file are separated by one or more white space characters. In boggle, a legal word must be at least three-letter words long and cannot be longer than sixteen letters.  However, the file may have words of any length, so your program should only store the words from the file that can be legal boggle words. 

Additionally, your program should read a list of boggle cubes from a file whose name is specified as the second argument on the command-line. The file contains sixteen six letter words, each of which represents a boggle cube. Your program should read in these sixteen words a choose a random letter from each one to create the initial boggle board.

Two files of legal words and a file of boggle cubes are available on the acpub system in ~rcduvall/cps100e/assign/boggle.


Your program should first print out the 4x4 grid that is the boggle playing field, then a list of legal words found within the grid according to the rules of boggle, one per line. Note that in the original game, players are allowed only two minutes to find as many words as possible. So it seems only fair to cut your program off after that time as well. Thus, we will only count the words printed by your program within two minutes of its start.