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 #1

Due Tuesday, October 1, 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.

Project #1 Updates

You are expected to read updates on a daily basis.

Updates

Project #1 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 #1 FAQ

Your Responsibility

The project should be posted in its entirety very soon. However, there may be clarifications/corrections to the project. So, don't (repeat: DON'T) just print it out and ignore the webpage until you submit. You should frequently check the webpage to make sure you have the latest updates. We will try to make as few updates as possible, and correct any errors as soon as possible.

We suggest you look at the webpage sometime in the evening to see if any updates have occurred. Common student errors and their solutions are often posted in the FAQ (this will be up soon, once some questions are available). Contact your TA for questions, and they can forward it to the instructors if necessary.

Purpose

  1. To learn when and when not to implement: copy constructor, assignment operator, and destructor.
  2. To understand what an abstract data type is, in particular, a Sorted List.
  3. To develop container classes: ItemSortedList and ItemArrayList using sorted doubly linked lists and dynamic arrays, respectively.
  4. To write test drivers to test the classes you implement.
  5. To learn how to write preconditions, postconditions, class invariants.
  6. To learn how to plan/design classes.
  7. To write classes with good programming and commenting style.
  8. To write documentation for classes.

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 1 Checklist

Overview

This project has many parts. Start on it soon.

Some students see the objective of programming as "get the project to work", and believe that getting it to work means writing as much code as possible. Planning code, testing code, and documenting code is seen as a hassle, something that is unimportant. Unfortunately, nothing could be further from the truth.

If you program for a living, you will eventually have to work in teams, and the code you write must be well thought out, otherwise, it will be hard to maintain, contain bugs, etc. Documentation is important because other people need to know what your code does, and you need to know what other people's code does. So, even if you believe it's "busy work", it serves a useful purpose.

This project consists of several exercises, which will be listed as tasks.

Files Provided

In addition to the primary input and primary output, the following files are in the posting account under Projects/P1.

The following are secondary files. You do NOT implement these (they are used for Task 3).

Files Submitted

(9/26) Please read the Checklist instead.

Project Description

You will implement a variation on the game called Sokoban (do a "google" search, and you can see how to play this game). Here are the rules of the game.

  1. The game is played on a 10x10 board.
  2. The coordinates of the board are written as (row,col). Thus, (2, 3) is row 2 and column 3.
  3. (0,0) is the northwest corner. (9,9) is the southeast corner.
  4. There is one player on the board.
  5. Each position on the board consists of exactly one of the following:
    • a box
    • a food item (doughnut, coffee, pickle, etc.)
    • the player
    • a wall
    • empty
    Each of these are located at some valid coordinate on the board.
  6. Each food item has a name. The name consists of alphanumeric characters, and may have upper or lowercase characters, possibly in combination.
  7. Initially, your program will read in information (through input redirection). The following information will be provided in the redirected input.

    • the coordinate of each box You may assume these are in valid coordinates, and that no two boxes are placed in the same coordinates)
    • the coordinate and name of each food item You may assume these are in valid locations, not occupied by a box, and that no two food items are located at the same coordinate).
    • the coordinate of walls (think of walls as boxes that can't be moved). Again, the walls are at valid coordinates and do not overlap food items, nor boxes.
    • the coordinate of the player You may assume the player is at a valid coordinate, which is not occupied by a box, wall, or food item.
    • a list of commands The commands will be described below.

  8. There are two kinds of walls: interior walls which are the ones provided in the input to your program, and outer walls which is the wall surrounding the 10 by 10 grid (immediately to its north, west, south, and east). The outer walls are NOT inside the 10 by 10 grid. They are not part of the input file, and are always there, regardless of the input file.
  9. A player can "push" a box. For example, suppose the player is located at (4,0) and a box is located at (3,0). If a player moves north 1 unit, then the player pushes a box (since the box is located at a position where the player wishes to move). After the move, the player is at coordinate (3,0), while the box has been moved to (2,0).
  10. To push a box, the player must be adjacent to the box and walking in that direction. Thus, a player moving north can only push a box that is one unit north of the player. If a player is at (4,0) and the box is at (2,0), and the player moves north 1 unit, then the box isn't pushed (the player successfully moves to (3,0)).
  11. The box can only move in the direction the player is moving.
  12. The player can only move: north, east, west, south. The player can not move diagonally.
  13. There are restrictions to moving boxes. The player can not move two boxes in a row. For example, if there is a box at (2,0) and (3,0) and the player is at (4,0), and attempts to move north, nothing will happen. Normally, the box at (3,0) can be moved north to (2,0) but another box is already located there.
  14. A box can not be moved off the playing board (there's a wall around the entire 10x10 board, not represented in the input file).
  15. A box can't not be moved through a wall. Thus, if there is a box at (3,0) and a wall at (2,0) and the player is at (4,0) trying to move north one unit, it will be unsuccessful. The wall blocks the box.
  16. If a player is moving a box, and there is a food item in the way, the box will crush the food item, and the food item no longer exists. Thus, if there is a box at (3,0) and a doughnut (which is a food item) at (2,0) and the player is at (4,0) trying to move north one unit, the move is successful The box will move to (2,0) and crush the doughnut. The player will be at (3,0).
  17. Once a food item is crushed, it is no longer on the board.
  18. If a player walks over a food item, the player automatically picks up the food item, and the item is no longer on the board.
  19. Unlike the real "Sokoban", there is no "target coordinate". Normally, the game is played by attempting to move boxes to a target coordinate. The game is completed when all boxes are successfully on some target coordinate. However, this is a multi-part project, so you may wish to think about how you will incorporate this feature for the next project.

Commands

The following are a list of commands you must implement. These commands will appear as part of the input to your program.

For each command, you should print out the command as follows:

 <out> := "(" <count> ") [" <cmmd> "]" <endl>
  <count> := <udigits>
where <cmmd> is any one of the commands listed in the next section, and <count> is the count of the command number, which begins numbering at 1.

This will be called the command echo.

You may assume:

However,

List of Commands

Input file format

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

<boxes> :=  % "<box>" % <endl>
              [ % <coord> [ %% <coord> ]* % <endl> ]*
              % "</box>" % <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> := <word>
<points>    := <udigits>

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

<cmmds> :=  % "<command>" % <endl>
                [ % "MOVE" %% <dir> %% <udigits> % <endl> |
                  % "DISPLAY" % <endl> |
                  % "DISPLAY_BACKWARD" % <endl> |
                  % "SHOW_FOOD" % <endl> |
                  % "QUIT" % <endl> ]*
            % "</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 // REQ1. 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 ItemSortedList).

Where We Might Be Headed

Two things to think about. Board size and target squares for boxes (to make it behave more like Sokoban).

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.

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

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 p1.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 p1.tar 1
where p1.tar can be replaced by whichever tar file you have created, and 1 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