studentacct.mancala
Class MancalaSoln

java.lang.Object
  extended by studentacct.mancala.MancalaSoln
All Implemented Interfaces:
game.Game

public class MancalaSoln
extends java.lang.Object
implements game.Game

This represents the solution to the Mancala game and this class is written by the student. Note that it is not necessary to write a constructor - the system-defined default constructor is sufficient.

Author:

Constructor Summary
MancalaSoln()
           
 
Method Summary
 java.lang.String getPlayerName()
          Specifies the name of the player playing this game.
 void move(game.GameState state)
          Generates the next move for the game by modifying the game state.
 void setPlayerNum(int playerNum)
          Lets the game know which player number they are (always either 0 or 1).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MancalaSoln

public MancalaSoln()
Method Detail

getPlayerName

public java.lang.String getPlayerName()
Specifies the name of the player playing this game. This is the name that will be identified publicly on the web, so this should be unique, friendly and anonymous (or not), as you choose.

Specified by:
getPlayerName in interface game.Game
Returns:

setPlayerNum

public void setPlayerNum(int playerNum)
Lets the game know which player number they are (always either 0 or 1). Called once before game play starts. It is your job to remember your player number so that later on when the move() method is called, you will know which kind of piece to play. (Player #0 always plays the bottom half of the board, and player #1 always plays the top half.)

Specified by:
setPlayerNum in interface game.Game
Parameters:
playerNum - The player number (0 or 1).

move

public void move(game.GameState state)
Generates the next move for the game by modifying the game state. Gets called many times by the gaming engine, once every time it is the player's turn. You must play for the player number specified by the setPlayerNum() method. NOTE: The parameter is of type GameState, but in practice, it will always be an instance of a class that implements the MancalaStateInterface interface, so you can access the board from the state with these two lines of code:
                MancalaStateInterface mancalaState = (MancalaStateInterface)state;
                int[] board = mancalaState.getBoard();
                

Specified by:
move in interface game.Game
Parameters:
state - The current game state before this move is played.