Project 5: DarkGrayBox

CSE 143
Summer 1998

This assignment deals with a game called Dark Gray Box. It is a puzzle game where the player tries to figure out the contents of a box by sending rays of light into the box and observing if and where they emerge. Various objects inside the box the bend light in different ways.

Intermediate turnin

By Tuesday, August 11, at 8pm, you must submit the files gameboar.h and gameboar.cpp. The turnin form will include the specification of your partner, if any. This should implement Step 5 as described below. The intermediate turnin will be worth roughly 2 points out of the 25 points alloted for the assignment. Use the intermediate turnin form when you are ready to turn in this part of the assignment.

Step 1: Play the game

You should begin by playing the version of the game that we provide (Windows executable or linux executable) at least a few times right away to make sure you understand it. Any questions you have about why the game does what it does should be asked on the cse143@cs.washington.edu mailing list. Feel free to post answers to classmates' questions on the same list. This step is all you should do for the next for the next day or two. Do it, it will really help and its Lots o' Fun.

Here is a sample run of the game (the linux executable, so trying the same random seed on Windows may produce a different game), annotated with explanatory comments. When the game is begun, it looks like this:

DarkGrayBox is a puzzle game. The board consists of an N x M rectangle
in which are hidden a number of objects.  Your task is to figure out which
objects are where by sending rays of light into one of the slots around
the edge of the board, and seeing where they come out.  Rays going in are
marked with a capital letter, and rays coming out are marked with the
matching lowercase letter.  If the ray does not emerge from the box, only
the capital letter will appear, and if it emerges from the same slot into
which it was sent, only the lowercase letter is printed.  Each object b
affects the ray of light in a different way. The objects available in the
current game are:
 /     A mirror slanted bottom-left to top-right
 \     A mirror slanted top-left to bottom-right
 @     A block which absorbs any ray that hits it.
There will be at most 2 blocks in the game.  You specify the values of N and
M, as well as the number of objects in the box, the number of tries you get
(26 is the maximum you should provide for this), and a random seed. A good
set of values is 7 7 26 7 , where  is some integer seed.

Enter: rows cols tries gizmos seed

I type in the line
5 5 20 5 1
and see the following:

Type 'h' for a list of available commands

    0 1 2 3 4 
   -----------
 0|           |0 
 1|           |1 
 2|           |2 
 3|           |3 
 4|           |4 
    -----------
    0 1 2 3 4 

Enter command: 
I enter the commmand h to get the list of available commands:
Available commands are:
h: display this message
s <dir> <slot>: shoot a ray in direction <dir> in slot <slot>
g <row> <col> <symbol>: guess the symbol <symbol> at location <row>,<col>
g <row> <col>: erase a guess at location <row>,<col>
G: see if your guesses are correct
q: quit the program

    0 1 2 3 4 
   -----------
 0|           |0 
 1|           |1 
 2|           |2 
 3|           |3 
 4|           |4 
    -----------
    0 1 2 3 4 



Enter command: 
Now I want to start finding objects in the box, so I pick a slot to fire a ray. Let's say I choose to fire a ray down slot 1. I enter the command s d 1 and see the following:

Shot 'A' disappeared!

      A       

    0 1 2 3 4 
   -----------
 0|           |0 
 1|           |1 
 2|           |2 
 3|           |3 
 4|           |4 
    -----------
    0 1 2 3 4 



Enter command: 
Notice that I am told that the shot disappeared, and this is represented visually by the letter 'A' above slot 1 in the top, with no corresponding 'a'. I try a few more shots like so:
Enter command: s u 1

Shot 'B' disappeared!

      A       

    0 1 2 3 4 
   -----------
 0|           |0 
 1|           |1 
 2|           |2 
 3|           |3 
 4|           |4 
    -----------
    0 1 2 3 4 

      B       


Enter command: s l 0
       A       

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|           |1 
  2|           |2 
  3|           |3 
  4|           |4 
     -----------
     0 1 2 3 4 

       B       


Enter command: s l 1
       A       

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|           |1 D
  2|           |2 
  3|           |3 
  4|           |4 
     -----------
     0 1 2 3 4 

       B   d   


Enter command:
Shot 'B' also disappeared, so I suspect that there is a '@' in column 1, but I don't know where. Shot 'C', which was sent to the left on row 0 goes straight across row 0, which is shown visually by the 'c' character to the left of the row. Shot 'D' went in going left on row 1 and came out slot 3 at the bottom! This leads me to suspect a mirror '/' at position (1,3), which i specify like so:
Enter command: g 1 3 /
       A       

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|       /   |1 D
  2|           |2 
  3|           |3 
  4|           |4 
     -----------
     0 1 2 3 4 

       B   d   

Enter command:
Now I continue to send in rays and make guesses:
Enter command: s l 2
       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|       /   |1 D
  2|           |2 E
  3|           |3 
  4|           |4 
     -----------
     0 1 2 3 4 

       B   d   


Enter command: g 2 4 \
       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|       /   |1 D
  2|         \ |2 E
  3|           |3 
  4|           |4 
     -----------
     0 1 2 3 4 

       B   d   

Enter command: s l 3 
       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|       /   |1 D
  2|         \ |2 E
f 3|           |3 F
  4|           |4 
     -----------
     0 1 2 3 4 

       B   d   


Enter command: s l 4
       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|       /   |1 D
  2|         \ |2 E
f 3|           |3 F
  4|           |4 G
     -----------
     0 1 2 3 4 

     g B   d   


Enter command: g 4 0 /
       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|       /   |1 D
  2|         \ |2 E
f 3|           |3 F
  4| /         |4 G
     -----------
     0 1 2 3 4 

     g B   d   

Enter command: s r 2
       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
  1|       /   |1 D
H 2|         \ |2 E
f 3|           |3 F
  4| /         |4 G
     -----------
     0 1 2 3 4 

     g B   d h 


Enter command: s r 1

Shot 'I' disappeared!

       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
I 1|       /   |1 D
H 2|         \ |2 E
f 3|           |3 F
  4| /         |4 G
     -----------
     0 1 2 3 4 

     g B   d h 


Enter command: g 1 1 @
       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
I 1|   @   /   |1 D
H 2|         \ |2 E
f 3|           |3 F
  4| /         |4 G
     -----------
     0 1 2 3 4 

     g B   d h 

Enter command: s u 2

Shot 'J' disappeared!

       A     e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
I 1|   @   /   |1 D
H 2|         \ |2 E
f 3|           |3 F
  4| /         |4 G
     -----------
     0 1 2 3 4 

     g B J d h 


Shot 'J' disappeared, and there are two reasonable explanations for this. The first is that there is a '@' somewhere in column 2, and the only location in that column that is consistent with our previous guesses is location (1,2). The second is that there is a '\' mirror at location (1,2), which would bend the light ray into the '@' at location (1,1). We can test which is correct by firing one more ray down column 2.
Enter command: s d 2
       A K k e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
I 1|   @   /   |1 D
H 2|         \ |2 E
f 3|           |3 F
  4| /         |4 G
     -----------
     0 1 2 3 4 

     g B J d h 


This makes me think that the correct guess was a '\' at (1,2), so i guess this, and see if my guesses are correct:
Enter command: g 1 2 \
       A K k e 

     0 1 2 3 4 
    -----------
c 0|           |0 C
I 1|   @ \ /   |1 D
H 2|         \ |2 E
f 3|           |3 F
  4| /         |4 G
     -----------
     0 1 2 3 4 

     g B J d h 

Enter command: G
Correct!
I have solved the puzzle! Yay!

Step 2: Play the game again... and again...

Note that if you are stuck, you can quit the game and see the actual solution... compare it with your guesses to learn how to improve your Dark Gray Box solving skills!

Step 3: Read the code base. Code is coming soon

We will give you much of the code needed to get the game working. We will require to do some implementation before the code we give you will run, and before you do this you should understand the code we give you. This code will include:

Step 4: Read the code base again... and again...

You should really understand the code. 'Nuff said.

Step 5: Implement the minimal parts to get a working executable

This basically means implementing Gameboard::fireRay.

Step 6: Finish providing the game options provided in the sample executable.

This means implementing the g and G options from the command prompt.

Step 7: Finish providing the gizmos provided in the sample executable.

This means making a block gizmo, which causes all rays hitting it to disappear, and changing the implementation of gizmogrifier to sometimes return these objects. You should be able to implement a block gizmo by following the examples given in the distributed code, but the necessary features (inheritence and virtual functions) will be covered soon in lecture.

Step 8: Make new gizmos.

Create gizmos of your own. A gizmo which is biased in a particular direction (such as the '/' gizmo) should be paired with additional gizmos biased in the other possible directions (in this case, the '\' gizmo), and the set will be considered one gizmo for the purposes of needing to implement two gizmos.

Restrictions on gizmos

Gizmos behavior may NOT be random. You may have gizmos which change behavior over time, but the way in which that behavior changes over time MUST be deterministic. A clever player should be able to figure out where everything is, and that is just too unlikely in the presence of gizmos that roll dice and do weird things.

Step 9: Add whistles and bells.

Some whistles and bells include better graphics, a better user interface, and a good scoring function. Check with your TA or the head TA if you have other ideas of whistles and/or bells.

Grading

You will essentially be graded on three things. The first is the implementation of the basic game, that which mimics the sample executable. The second is the additional gizmos you provide, which will be graded based on the playability of the new game, and the imagination that went into creating them. The third is whistles and bells, which will count toward extra credit.

Final Submission

There is no electronic turn-in form for this assignment. However, you are required to submit a floppy disk containing your source files and an executable. Please read the turnin instructions for this assignment carefully; they differ from previous assignments.

If You Get Stuck

If you're having problems, there are a number of resources available for you.

If you need help with the lab environment or the online resources, go talk to a consultant in the IPL.

If you can't make progress in the actual assignment, please talk to the instructor or a TA. They are available during posted office hours, and sometimes by appointment. They will also occasionally help you out over email. You are invited to seek help from any available TA, not just your own.

You can discuss the assignment in general terms with other students. You can ask general questions on the student discussion list for this course, cse143@cs. But any code you write must be your own (i.e. that of you or your partner). For more details about what is and is not allowed, see the Software hygiene page.


cse143-webmaster@cs.washington.edu