CSE 332 Lab 4: Scrabble Solitaire

Lab dates: Wednesday October 21, Wednesday October 28, and Wednesday November 4, 2009
Due by Friday November 13 at 11:59 pm (note new deadline)
Final grade percentage: 10 percent

Objective:

This lab is intended to extend your use of basic C++ language features from the previous labs, and to make more extensive use of the C++ STL. To do this, you will extend your C++ programs from the previous labs to (1) maintain and display a game board with letter tiles played in interlocking vertical columns and horizontal rows, (2) repeatedly draw and display sets of letter tiles for a single player, (3) accept a string from the player and check that the letters in it can be made from the set of tiles the player has, (4) accept a board position and orientation with which to play the string and confirm that the tiles will fit into open squares based on that information, and (5) confirm that all newly contiguous sequences of tiles resulting from the play are words found in a dictionary. In this lab and in the subsequent labs, you are encouraged to re-use and modify code from your previous lab solutions - if you choose do this, please put a completely new copy of any header and source files from your previous lab(s) in the new lab project directory you create. This can avoid some potential for error or confusion within Visual Studio, and also ensures you have a backup copy that you could go back to if a modification you try doesn't pan out.

In the next (and final) lab assignment for the course you will build on these features to allow a user to play a multi-player version of the game, with other live and/or artificial players.

Assignment:

    Part I - Readings:

  1. The following readings in the optional text books and reference web pages may be useful as reference material while working on this lab assignment.

  2. The constructor, destructor, operator, accessor, and mutator method examples in the C++ classes lecture slides give an overview of class syntax and structure you may need for this lab.

  3. The STL algorithm examples in the C++ C++ functions, classes, and templates lecture slides also may be helpful when implementing parts this lab.

  4. Please read the following CSE 332 Programming Guidelines which relevant to the previous labs and please follow them as you implement your solution: A.1-A.17, B.1-B.7, B.9-B.13, B.15, B.16, B.18, B.20-B.23, B.25, B.30, B.33, B.34, C.1-C.9.

    Part II - Program Design and Implementation:

    Note: the details of this assignment are again intentionally somewhat under-specified, leaving you some room to choose what you think is the best way to implement them, as long as what you do is reasonable and you explain your design decisions in comments in the code and in your Readme.txt file.

  5. Open up Visual Studio, and create a new Win32 Console Application Visual C++ project for lab 4.
  6. Please modify your code from lab 3 that reads in lines from the dictionary file so that it ignores any lines that begin with a //, like the first two lines of the following sorted_dictionary_example.txt file.
  7. If you have not done so already in lab 3, please modify your word collection class so that it generates all permutations of all lengths (not just the ones of the same length as the original) that can be created from the letter tiles in the given letter tile collection object, and stores exactly one copy of any that are found in the given dictionary object.

  8. Declare an enumerated type for the direction that sequence of letter tiles can be played, that can have either of two values: vertical or horizontal.

  9. Declare and define a class to represent a GameBoard with a private member variable that represents a 15 by 15 grid of squares, where each square can have 0 or 1 letter tiles associated with it, and the squares are indexed in the vertical and horizontal dimensions with (0,0) denoting the center of the board, (-7,-7) denoting the bottom left corner of the board, (-7,7) denoting the top left corner of the board, (7,7) denoting the top right corner of the board, and (7,-7) denoting the bottom right corner of the board.

    How you implement the member variable is up to you, but one idea is to use an STL container whose key type is an STL pair of integers and whose data type is a pointer to a letter tile (so that empty squares can be denoted by the pointer being 0), e.g., of type map<pair<int,int>,LetterTile*> >.

    The public interface for this class should be:

  10. In your project's main function:

  11. Build your project, and fix any errors or warnings that occur. Please be sure to note all of the different kinds of errors or warnings you ran into (though you don't have to list every instance of each kind) in your ReadMe.txt file. If you were fortunate enough not to run into any errors or warnings, please note that instead, where you would have listed errors or warnings in your ReadMe.txt file.

  12. Open up a Windows console (terminal) window and change to the directory where your program's executable file was created by Visual Studio (see the first studio exercises document for more details on this, if you don't remember them).

  13. Run the executable program through a series of trials that test it with good coverage of cases involving both well formed and badly formed inputs. For this lab one especially useful test is to check whether the output printed by your program consistently represents the contents of valid dictionary and tile definition files it was given. In your ReadMe.txt file please document which cases you ran (i.e., what the command lines were) and summarize what your program did and whether that is correct behavior, in each case.

  14. In your ReadMe.txt file, make sure that your name and the lab number (lab 4) are at the top of the file, and that you've documented whether you ran into any errors or warnings while developing your solution (and if so what they were) and what the executable program did for each of the trials you ran. Be sure to save your changes to your ReadMe.txt file, as well as those to your source (and header) file(s) before preparing your solution zip file.

  15. Prepare a zip file that contains your project's source, header, and ReadMe.txt files (except for stdafx.h, stdafx.cpp or other Windows-generated files you did not modify), by:

    Send the zip file containing your lab 4 solution as an e-mail attachment to the course e-mail account (cse332@cec.wustl.edu) by the submission deadline for this assignment. If you need to make changes to your lab solution you are welcome to send a new zip file, and we will grade the latest one received prior to the deadline (according to the time stamp the server puts on the e-mail).

    Part III - Helpful hints: (optional, worth up to 5% extra credit)

    The goal of this optional part of the assignment is to have you provide an additional feature, which is to suggest another position, direction, and/or sequence of tiles that the player could try if they attempted a play that is not valid:

  16. If the user tries to play a sequence with a starting position and direction that does not work, see whether any other combination of starting position and direction with that same sequence would result in a valid play.

  17. In your readme file, please add a section clearly marked "extra credit" and in it explain how you implemented those features, and also cut and paste output from your game with it printing out the appropriate helpful hint for each of the two cases above.

Posted 1:50pm Wednesday November 11 2009 by
Chris Gill

Changes since original posting: