edu.rice.comp440.player
Class RandomPlayer

java.lang.Object
  |
  +--edu.rice.comp440.player.RandomPlayer
Direct Known Subclasses:
SwingDriver.SwingRandomPlayer

public class RandomPlayer
extends java.lang.Object
implements Player

Class which implements a random player. This player will get the list of all available moves and return a random one.


Field Summary
protected  java.util.Random random
           
 
Constructor Summary
RandomPlayer()
           
 
Method Summary
 void lost()
          Upcall to indicate that this player has lost the current game
 Move move(Backgammon backgammon)
          Requests that the player make a move using the given backgammon setup.
 void won()
          Upcall to indicate that this player has won the current game
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

random

protected java.util.Random random
Constructor Detail

RandomPlayer

public RandomPlayer()
Method Detail

move

public Move move(Backgammon backgammon)
Requests that the player make a move using the given backgammon setup. The player should return a valid and complete move. The list of valid moves can be found by calling backgammon.getAllMoves().
Specified by:
move in interface Player
Parameters:
backgammon - The current backgammon situation

won

public void won()
Description copied from interface: Player
Upcall to indicate that this player has won the current game
Specified by:
won in interface Player

lost

public void lost()
Description copied from interface: Player
Upcall to indicate that this player has lost the current game
Specified by:
lost in interface Player