/** * OthelloRules Interface * Interface for the Rules classes for use with Othello, * a project by Sam Rebelsky's CSC 152 class. * * The purpose of this interface is to declare the methods used * by all versions of the rules. It serves to provide a generic method call * for these common methods as well as to provide other groups a list of * methods they can expect to use. * * * @author Alex Ford, Jonathan Emmons, Rob Park, Arrel Gray * @version 1.0 of February 2000 * */ public interface OthelloRules { /** * startingPieces * * This method provides the board class with information on where to * place the initial pieces before the game starts. These positions will * be determined by the version of the game selected by the player through * the GUI or TUI. There are no parameters. The method returns an array * of integers to the board representing the player number and (x,y) * coordinates on the board for every piece that is to be created. * */ public int[] startingPieces(); /** * setTurn * * This method is used to initialize the field that tells whose turn * it is. This field will be used to determine the color of the piece to * be played as well as to determine whether a particular move will be * legal. This field will need to be initialized, and different sets of * rules may state that player one does not always go first. Also, in the * event of a player being unable to make a legal move or a rule variation * which affects whose turn it is, it will be necessary to set this field. * This field will provide more flexibility than simply initializing it * upon declaration of the field. The method will not take parameters and * will return an integer value representing the player number. * */ public int setPlayer(); /** * numberPlayers * * At some point in the game it will become necessary for other classes * to know the number of players playing the game. This method will * provide this information by returning the integer corresponding to the * number of players. It will not take any parameters. * */ public int numberPlayers(); /** * legalMove * * This method provides a test to see whether or not a move the player * requests is a legal move. The method will need parameters including * which player is requesting the move as well as which space he wishes * to place his piece. This method is also dependant upon a method in * the board class that will return whether or not a given space on the * board is occupied and who has that space. It will return a boolean * value indicating whether or not a move is legal. Alternate versions * of the game's rules may include different definitions of a legal move. * * Assume the player is represented by an integer and a square on the * board can be expressed as a column number and row number. * */ public boolean legalMove(int player, int column, int row); /** * anyMove * * This method is designed to determine whether or not a player has * a legal move available. There are times in the game in which a player * does not have a space he can move into that will surround one of his * opponent's pieces, and he will be forced to pass. The method will need * to know which player is attempting a move. It will then check all * empty spaces on the board and test whether or not it is a valid option * using legalMove. If there is at least one legal move available, the * method will return the boolean value true. If not, it will return * false. * * This method can be implemented before every turn or whenever a * player suspects he is "stuck," depending on the preference of the * designers of the appropriate class. * */ public boolean anyMove(int player); /** * endOfGame * * The program will have to have some way of determining whether or not * the game is over. endOfGame will return a boolean value describing * whether or not the game is over. The game should end when either * 1) there are no spaces open on the board, or 2) no player is capable * of making a legal move. No paramters are required to run this method. * Again, this assumes that there is some method in the board class that * will report on whether or not a space is occupied. * */ public boolean endOfGame(); } // interface OthelloRules