Last modified: 2Nov98 R.Levow
N.B. This program is bigger and more complex than the other programs you have written. It is worth 150 points. Incremental development and testing are critical to success. You will be able to complete it on time only if you make effective use to the time allotted. (While posting of the project has been delayed, the amount of time for the project is unchanged.)
Implement the Wumpus World program. Read the program description on the preceeding link carefully. To get a better idea of how the game is played, you may want to visit the following sites offering variations of the program.
For the preliminary version, you must hand in a hardcopy of your program files and a printout showing proper execution of the specified program elements. For the final version you must turn in hardcopy of the program files, printout from a winning game and from games in which involve each of the other possible endings. You must also electronically submit with the hwroy program copies of all the source files for your class implementation (named maze.h and maze.cc) and driver (wumpus.cc). You must use the class definition file (maze.h) and any classes provided by the Astrachan without alteration except that you may add helper functions to private section of maze.h. (Be sure to use this version of maze.h and not the one in bookcode.)
A note on Vectors. This program uses a vector instead of
an array to store the information about each "cave" in the maze.
Even though we will not be covering vectors in class until the 7th, you
should have no trouble using them here. Just remember the following
simple fact: You access an element of a vector in exactly the same
way that you access an element in an array. Indexing starts at 0
and you get an element by puting the subscript in square brackets.
Thus
myCaves[i].name = "Starting
point";
stores the string in the field name of the i-th element of
the vector myCaves and
if (myCaves[myCurrentLoc].contents
== WUMPUS)
tests the field contents of the cave in the position specified
by myCurrentLoc.
The thing that is special about vectors is that they can change size.
You set the size of a vector with the method SetSize() which takes
one int parameter specifying the size. You'll have to do
this in the constructor. Read the maze size from the caves.dat file,
say into a variable numCaves, and then use the statement
myCaves.SetSize(numCaves);
to set the vector to the right size. From this point on, use
the vector just as you would an array.
Compiling tactics. From now on, you don't need to compile each
class that you want to use in your programs. Instead, just link the Tapestry
library when you are creating your executables, by using the -L
and -l flags in your g++ command, as shown here.
g++ maze.o wumpus.o -L/usr/tools/cse.pub/roy/cot3002/TapestryCode
-ltapestry
or
g++ maze.o wumpus.o -Lbookcode -ltapestry
or the slightly simpler form
g++ maze.o wumpus.o bookcode/libtapestry.a
The -L/usr/tools/cse.pub/roy/cot3002/TapestryCode/ tells the
compiler to look for library files in that directory, as well as in all
the usual places. If you have created a link bookcode to this
directory in your current directory, you can simply write -Lbookcode.
The -ltapestry flag instructs the compiler to link the tapestry
library (actually /usr/tools/cse.pub/roy/cot3002/TapestryCode/libtapestry.a)
into your final executable. The library file holds the compiled definitions
of all the classes in Astrachan's book.
You will still need to use the include files, of course, but you can avoid specifying the path to these files in your program by using the -I flag when you compile. -Ibookcode, for example tells g++ to look for #include files in the directory bookcode in addition to the current and system directories. If you do this, you can simple use #include "CPstring.h" rather than #include "bookcode/CPstring.h" in your code files.
(some material from original by matt, with permission)