Class EndGame

java.lang.Object
  |
  +--EndGame

public class EndGame
extends java.lang.Object

This class handles the endgame database loading and querying. There are three private fields, one for each endgame database.


Method Summary
 boolean LoadDB(int np1)
          This loads the databse specified by np1.
 boolean LoadDB(int np1, int np2)
          This loads any two endgame databases specified by np1 and np2.
 boolean LoadDB(int np1, int np2, int np3)
          This loads all three endgame databases.
 int Query(CheckerBoard b)
          Given a CheckerBoard, the appropriate endgame database is queried and the result of the query is returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

LoadDB

public boolean LoadDB(int np1,
                      int np2,
                      int np3)
This loads all three endgame databases. The parameters np1, np2, and np3 must all be different and must be either 2, 3 or 4. If incorrect values are given, the method returns false and does not load any database.


LoadDB

public boolean LoadDB(int np1,
                      int np2)
This loads any two endgame databases specified by np1 and np2. np1 and np23 must be either 2, 3 or 4 and must be different. Otherwise no databases are loaded and false is returned.


LoadDB

public boolean LoadDB(int np1)
This loads the databse specified by np1. np1 must be 2, 3 or 4 (number of pieces in the database to be loaded). If np1 is not 2, 3 or 4 then no database is loaded and false is returned. We assume that the databases are files /afs/andrew/course/15/381/hw2/databases/simple_2.db /afs/andrew/course/15/381/hw2/databases/simple_3.db /afs/andrew/course/15-381/hw2/databases/simple_4.db If you have moved these databases to a local copy then you must change the code accordingly.


Query

public int Query(CheckerBoard b)
Given a CheckerBoard, the appropriate endgame database is queried and the result of the query is returned. The int returned is either

Returns:
0 if a WIN, 1 if a LOSS, 2 if a DRAW, 3 if INVALID, -1 if not a valid query -- too many or too few pieces