edu.lhup.ai
Class RandomPlayer

java.lang.Object
  |
  +--edu.lhup.ai.RandomPlayer
All Implemented Interfaces:
IPlayer

public class RandomPlayer
extends Object
implements IPlayer

A concrete player that plays any game by selecting a random move from the set of currently legal moves.

This software is for educational purposes only.

Author:
Mark Cohen

Constructor Summary
RandomPlayer()
           
 
Method Summary
 String getDescription()
           
 String getShortDescription()
           
 void setCutoff(int cutoff)
          Provides a mechanism for specifying the point at which a player's abandons the search for the best move.
 void setEvaluator(IEvaluator evaluator)
          Provides a mechanism for specifying a player's evaluation strategy.
 void takeTurn(IBoard board)
          Selects a random move from the set of currently legal moves.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RandomPlayer

public RandomPlayer()
Method Detail

getDescription

public String getDescription()
Specified by:
getDescription in interface IPlayer
Returns:
a description of this player.

getShortDescription

public String getShortDescription()
Specified by:
getShortDescription in interface IPlayer
Returns:
a short description of this player.

setEvaluator

public void setEvaluator(IEvaluator evaluator)
Description copied from interface: IPlayer
Provides a mechanism for specifying a player's evaluation strategy. By implementing the IEvaluator interface programmers can create their own custom evaluators and request that a player use the evaluator by calling this method.

Specified by:
setEvaluator in interface IPlayer
Parameters:
evaluator - the strategy used by this player in order to evaluate the current game state.

setCutoff

public void setCutoff(int cutoff)
Description copied from interface: IPlayer
Provides a mechanism for specifying the point at which a player's abandons the search for the best move.

Specified by:
setCutoff in interface IPlayer
Parameters:
cutoff - an integer limiting the duration of a player's search for the best move

takeTurn

public void takeTurn(IBoard board)
              throws TurnException
Selects a random move from the set of currently legal moves.

Specified by:
takeTurn in interface IPlayer
Parameters:
board - the IBoard object that this player will make a move on.
Throws:
TurnException - if for some strange reason the selected move turns out not to be legal.

toString

public String toString()
Overrides:
toString in class Object