Lab 8 - Hex-a-Pawn
Due: Monday, November 8, 2004 at 9:00 AM
Short Answers
Complete the following problems from the book, and the extra questions
below, and turn them in as a text file lab8.txt at the start of
lab.
Extra Questions:
- Under what circumstances would a get method as
described in question 10.13 be more useful than the existing contains method? Write a get method for OrderedVector.
- The OrderedList implementation described in the text has methods
that include the line
Comparable cValue = (Comparable)value;
Are these casts necessary? Do they restrict the usage of the
structure in any way?
Lab Program
Do the laboratory in Section 11.11 in the Bailey book.
- There are three files related to this lab on the book's web
site: HexBoard.java, HexMove.java, and Player.java.
Familiarize yourself with these classes.
- A significant part of your task is to design and implement the
GameTree class. This is a tree structure with potentially many
children instead of just two. Think about the methods you will need
in this class and how you can represent the structure. Bring a
handwritten sketch of GameTree to class on Wednesday morning.
This will allow me to look over your designs between class and lab so
I can get them back to you right at the start of lab.
- You can play a game of Hex-a-Pawn by running java HexBoard
after compiling the starter files.
- To use your three Player classes as described in the book,
implement the Hex-a-Pawn game as the main method of a class HexaPawn.java. This program should take four parameters. The first
two specify the number of rows and columns the board should have. The
third and fourth should be "humam", "comp", or "random" to
indicate what type of player should be used for the white and pieces,
respectively.
- Gardner's original paper describing this game is under labs/hexapawn in the CS136 common area on cortland and the FreeBSD
systems. Take a look, if you're interested. Notice the ad for a
"comparator" on the third page.
When you're finished, create and submit a tar file lab8.tar that
includes the following:
- Your well-documented source code for all Java files that you
write. You do not need to submit source code for starter
files, as you should not need to modify them.
- A README file that contains your answers to
thought questions 1 and 2.