edu.lhup.ai.tictactoe
Class Evaluator
java.lang.Object
|
+--edu.lhup.ai.tictactoe.Evaluator
- All Implemented Interfaces:
- IEvaluator
- public class Evaluator
- extends Object
- implements IEvaluator
An evaluator that is capable of evaluating a tic-tac-toe game.
This is done by evaluating terminal and non-terminal states. For example,
this evaluator will return 0 if the current state is a tie, 1 if the current
state is a victory, and -1 if the current state is a defeat. If the current
state is not an end state, the board is analyzed to see if anyone is about
to win. If the "maxPlayer" is about to win, 1 is returned, if the
"maxPlayer" is about to loose, -1 is returned. If no player is about to
win, 0 is returned. This evaluator works well even when a cutoff is
specified because it can evaluate non-terminal states.
This software is for educational purposes only.
- Author:
- Mark Cohen
Evaluator
public Evaluator()
evaluate
public int evaluate(IBoard board,
IPlayer maxPlayer)
- Provides a mechanism for evaluating the current state of a game.
- Specified by:
evaluate in interface IEvaluator
- Parameters:
board - the game that will be evaluated.maxPlayer - the player whos perspective will be used when
evaluating the specified game.
- Returns:
- 0 if the current state is a tie, 1 if the current
state is a victory, and -1 if the current state is a defeat.
If the current state is not an end state, the board is analyzed to
see if anyone is about to win. If the "maxPlayer" is about to win,
1 is returned, if the "minPlayer" is about to win, -1 is returned.
If no player is about to win, 0 is returned.
toString
public String toString()
- Overrides:
toString in class Object