C M S C     2 1 4
C o m p u t e r   S c i e n c e   I I
F a l l   2 0 0 2


Project #2

Due Thursday, October 24, by 11pm

Read the FAQ for updates/corrections. Items that have changed from the previous version will be marked in red to make it easier to spot changes.

Checklist

Click here before submitting.

Project 2 Checklist

Project #2 Game Clarifications

Some students have come up with questions on how the game is played. These are clarifications.

Clarifications

Project #2 Updates

You are expected to read updates on a daily basis.

Updates

Project #2 FAQ

Some of your questions may be answered here. Read it to see before sending email.

You are expected to read FAQ on a daily basis.

Project #2 FAQ

Your Responsibility

Read this webpage often. Read the FAQ often. Read README.updates in the posting account often.

Get started right away.

The main part that's missing from the project as of today is the files in the posting account, and the rest of the BNF. However, you should be able to start Task 2, with information provided.

Purpose

  1. To templatize a class. In particular, convert ItemSortedList and ItemArrayList into template classes, SortedList and ArrayList.
  2. To write recursive functions. In particular, convert all loops in ItemSortedList to recursion.
  3. To extend the features of the ItemArrayList by adding an erase() and being able to call a sort on the list.
  4. To extend the features of the game.
  5. To gain experience with a "function object".
  6. To write documentation for the proposed classes for Project 4.
  7. To debug code from previous project, so that it doesn't give you problems on this one.
  8. To write unit testing classes with a templatized array list.

Academic Integrity Statement

Please note that *all* programming projects in this course (including this one) are to be done independently or with the assistance of the instructional staff of this course only.

Please review the policies outlined on the class syllabus concerning the use of class computer accounts and concerning the University's Code of Academic Integrity. The instructors of this course will review the programs submitted by students for potential violations of the Code of Academic Integrity and if it is believed that a violation has occurred it will be referred to the Office of Judicial Programs and the Student Honor Council.

Hardcoding is considered a violation of academic integrity

Checklist

Click here before submitting.

Project 2 Checklist

Overview

Files Provided

Project Description (BETA)

You will now add additional features to the game. Here are the list of new features:
  1. The board has arbitrary number of rows and columns. However, to keep things interesting, assume at least a 3 row, 3 column board.
  2. The player now has strength. This is an int value, and determines how much a player can push and/or carry.
  3. A player can potentially push more than one box at a time, assuming all boxes are adjacent in the direction being pushed.
  4. A box now has color. This is a single word. Each box has a unique color (case-INSENSITIVE).
  5. A box now has weight.
  6. If the player's strength is greater than or equal to the sum of the boxes being pushed, then the boxes can be moved.
  7. A player can place food items on TOP of a box. A box can have more than one food item on the box.
  8. In order for the player to drop the food item on the box, the player must be carrying the item, and the box must be within one square of the player (in any of the eight directions: north, south, west, east, northwest, northeast, southwest, southeast). The player will specify the box by color.
  9. In the "real" Sokoban game, there are target squares, which are certain designated squares.. The goal of the game is to move boxes to the target squares.
  10. There will be target squares on the board. You can assume the target squares are not the same squares as walls. However, target squares can initially have up to one food item, or a box on the square.
  11. Initially, no food items sit on top of a box. They are only on a box when placed there by the player.
  12. The game now stops under three circumstances. First, the player enters a QUIT command. Second, while processing the commands, you reach </command>;, or third, all target squares contain boxes.
  13. The number of target squares will be identical to the number of boxes.
  14. Initially, all boxes will NOT lie on target squares, i.e., at least one box is not on a target square.
  15. The player can query for where items are located, as well as what food items sit on top of a box.
  16. If a food item sits on top of a box, it can not be crushed.
  17. A player can pick the item off the top of a box by issuing a command, but must still pass over a square to pick it off the ground.
  18. Food items do not have any weight (at least, it's neglible compare to the box weight).
  19. Food items can now have multiword names (such as "chocolate chip cookie").
  20. Food item names are no longer unique. If the name appears twice in the input, the points and names should be updated. (The name will only change in case only, you can only update food items of the same name).

List of Commands

Input file format

(UPDATED)

The format of the input file looks like:
<all> := <dim> <boxes> <target-squares> <walls> <food-list> <player> <cmmds> 

<dim> := % "<size>" % <endl>
            % <udigits> %% <udigits> %
            % "</size>" % <endl>

<boxes> :=  % "<box>" % <endl>
              [ % <one-box> [ %% <one-box> ]* % <endl> ]*
              % "</box>" % <endl>
<one-box> := <coord> %% <box-color> %% <weight>
 <weight> := <udigits>

<target-squares> :=  % "<target>" % <endl>
                       [ % <coord> [ %% <coord> ]* % <endl> ]*
                       % "</target>" % <endl>

<walls> :=  % "<wall>" % <endl>
              [ % <coord> [ %% <coord> ]* % <endl> ]*
              % "</wall>" % <endl>

<food-list> :=  % "<food>" % <endl>
                 [ % <one-food-item> ]*
                 % "</food>" % <endl>
<one-food-item> := % <food-name> %% <points> %% <coord> % <endl>
<food-name> := <dquote> % <word> [ %% <word> ]* % <dquote>
<points>    := <udigits>

<player> :=  % "<player>" % <endl>
             % <coord> %% <strength> % <endl>
             % "</player>" % <endl>
<strength> := <udigits>

<cmmds> :=  % "<command>" % <endl>
                [ % "MOVE" %% <dir> %% <udigits> % <endl> |
                  % "DISPLAY" % <endl> |
                  % "DISPLAY_BACKWARD" % <endl> |
                  % "SHOW_FOOD" % <endl> |
                  % "DROP" %% <food-name>
                     %% <box-color> % <endl> |
                  % "PICKUP" %% <food-name> % <endl> |
                  % "BOX_INFO" %% <box-color> % <endl> |
                  % "BOX_INFO_SORTED" %% <box-color> % <endl> |
                  % "TARGET_INFO" % <endl> |
                  % "ITEM_INFO" %% <food-name> % <endl> |
                  % "QUIT" % <endl> |
                  <invalid-cmmd> ]*
            % "</command>" % <endl>
The BNF doesn't clearly show the following, but they do apply.

Assumptions

Requirements/Restrictions

For each of the REQ, put a comment in the code and/or header file where you have met these requirements. For example, you would write // REQ2-3. This way, the graders can easily find where you have met the requirements. If these are missing, we may deduct points, even if you have met the requirements.

Writing Classes

This project may require that you write your own classes. You should pick sensible classes, and you can write as many or as few as you want.

Here are some requirements/restrictions:

You may feel free to use whatever string methods or vector methods you can find in the book, etc., unless it is not in the spirit of the project (e.g., don't use vectors, when you are asked to use a SortedList).

Submit Reponsibilities

If your project successfully submits, there is still a small probability that your project IS NOT CORRECT, and therefore may lose points.

Therefore, you should NOT ASSUME that submitting successfully means you have passed primary input.

To best ensure that you HAVE passed primary, you should test your TAR file before submission. This means the following:

  1. Copy your tar file to a temporary subdirectory (which should be empty other than this file).
  2. Untar the file
  3. Copy the primary input and output to that directory.
  4. Type "make" with the appropriate project number.
  5. Input redirect the primary input to your executable and output redirect it to a file (e.g., my.out).
  6. Run diff -bwi between your output and the primary output.
  7. If the differences are only blank lines, you should be ready to submit.

Failing to follow these procedures may result in a project that "submits" (due to some glitch), but may not actually pass primary input.

Extra Credit

The project is worth 105 points. So, there's already 5 extra credit points. If you write a unit testing class for an additional class in this project, you may receive a few extra credit points (5 points or less).

How to Submit Your Project

In order to successfully submit your project, it must pass the primary input and produce the primary output. The primary input will be sent to your project using input redirection.

   p2 < primary.input
Your program MUST produce the executable p2, EXACTLY, when the command "make" is run with "p2" as argument. Thus, you must use a makefile named exactly "Makefile".

Your makefile must generate .o files , and you must not #include .cpp files (unless used for templates). You must link .o files to create your executable. You must also use macros in your makefile. Suffix rules are permitted.

We will use "diff -bwi" to test your code. This ignores case, treats N blanks as 1 blank, treats N blank lines as 1 blank line. We will also strip all blank lines from your input when matching to ours. However, diff is sensitive to punctuation, number of dashes, etc. so you should attempt to make your output match ours as closely as possible otherwise you may not be able to submit your program. If this is the case (that your program does not submit) you must fix your code until the output it produces matches that of the primary output. Note: "hardcoding" output is a violation of the University's Code of Academic Integrity.

To submit your project you must first combine the following files (and only these files) into a single tar file using the Unix tar command:

You may name your tarfile anything you want, but p2.tar is the suggested name.

NOTE! You should make a backup copy of all your files BEFORE attempting to create your tarfile!!!! You have been warned.

After creating the tar file you should submit that one file using the following command:

submit p2.tar 2
where p2.tar can be replaced by whichever tar file you have created, and 2 refers to the current project,

See the class syllabus for policies concerning email
Last Modified: Tue Feb 12 19:48:57 EST 2002
left up down right home