/* * ------------------------------------- * AutoPlayer.java * * A player for the game of Mancala. The * player makes moves from the leftmost pit * the contains stones. * * @author John Paxton * @version 1.0 * -------------------------------------- */ public class AutoPlayer extends Player { /* * ----------------------------------------------------------- * Player (Constructor) * * @param b an instance of the Mancala board * @param name the player's name * @param playerNumber used to identify the player * @return an instance of the Player class * ------------------------------------------------------------ */ AutoPlayer (Board b, int playerNumber) { super(b, playerNumber); } /* * * makeMove * * Selects the leftmost pit belonging to the player * that contains stones and sows the stones from this pit. * * @return void * */ public void makeMove () { int pitToEmpty = super.startingPit; // the pit to sow stones from // find the leftmost pit that contains stones while (super.mancalaBoard.getStones(pitToEmpty) == 0) { pitToEmpty = (pitToEmpty + 1) % Board.NUMBER_PITS; } super.lastMove = pitToEmpty; super.mancalaBoard.sowStone ( pitToEmpty ); } }