Project 5: Word ladder game


Due: 14 Nov 2003


Educational objectives: More experience using STL containers, including maps, queues, and stacks. Experience in implementing simple graphs and performing breadth first search.


Statement of work: You will write a program that implements word ladders on five-letter words. A word ladder is a sequence of words, where adjacent elements of the sequence differ in exactly one character. The goal is to construct a sequence that takes you from a source word to a destination word in as few steps as possible. For example, if the source is smart and the destination is bears, then the sequence: smart -> start -> stars -> sears -> bears is a ladder that takes you from the source to destination. In fact, this is a shortest ladder when using only words from the words.dat word list from the Stanford Graphbase, which we will use in this assignment.


Deliverables: Turn in a makefile and all header (*.h) and cpp (*.cpp) files that are needed to build your software, using the script. Typing 'make' should produce an executable called 'proj5'. Turn in hardcopies of your development log in class Monday, 17 Nov, or a softcopy along with your assignment submission. In addition, you will need to submit the following document: a project design, in which you specify the public interfaces to each of your classes and a pseudocode for your software. This should be submitted in class Nov 10 th.




         Write a main program that will take the name of a file containing a list of words, in the format of the words.dat file. It will then repeatedly prompt the user for input exactly as shown in the example below, then read pairs of words given by the user, and find a ladder between them. (The first word will be the source, and the second one the destination.) It will print the ladder on a line, terminated by a new line, with a '->' between words. If the user inputs 'quit', then the program will terminate. There should be no outputs other than those specified in this project description.


Sample session (User input is underlined)


Unix prompt> proj5 words.dat

Input source and destination:

spool shook

spool -> spook -> shook

Input source and destination:

spool qwert

Either no path from source to destination, or invalid source/destinations specified.

Input source and destination:


Unix prompt>


Bonus points: (Upto 10 points)


Turn this program into a full-fledged game, with an executable called ladders. The software will now repeatedly choose pairs of valid source/destination words such that there is, indeed, a ladder between them. It will then let the user type a ladder, verify that the user's ladder is valid, and then give the user a score based on the length of the user's ladder relative to the optimal one the software found. The software should also provide the user with the optimal solution, and the user's score. When the user quits the program, the software can give a final score too. You can feel free to implement other features for this game, and choose an interface that appeals to you. You should provide documentation for the interface on a web page, and also mention the exact scoring criteria.


Note: Even if you answer the bonus points questions, you should still implement the rest of the project, meeting the requirements specified above. If the 'make' process creates a file called 'ladders', we will take it as your answer to the bonus points question. You should still create a 'proj5' executable that will satisfy the regular project requirements. Please supply the web page for your documentation to us by email.