|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.problems.tictactoe.model.Player
public abstract class Player
Represents a Player in a Tic Tac Toe variation.
For maximum flexibility, each player is associated with an IScore scoring function so different players can have different strategies for playing games. This enables an AlphaBeta player to go up against a MiniMax player, for example. The game tree algorithms would otherwise be more complicated.
Make sure that you assign an effective scoring function with each player, otherwise the move search algorithms will not perform effectively.
Field Summary | |
---|---|
protected Logic |
logic
Logic for game. |
protected char |
mark
Knows its character to play. |
static char |
OMARK
Global access to OMark. |
protected IGameScore |
score
Scoring method used. |
static char |
XMARK
Global access to XMark. |
Constructor Summary | |
---|---|
Player(char mark)
Creates a player with a certain mark. |
Method Summary | |
---|---|
abstract IGameMove |
decideMove(IGameState board)
Decide upon a move with the given board state. |
int |
eval(IGameState state)
Return the evaluation of this game state from the perspective of the given player. |
char |
getMark()
Return the mark for the player. |
char |
getOpponentMark()
Return opponent mark. |
int |
hashCode()
Enable Player objects to be used in hash table. |
Logic |
logic()
Returns logic. |
void |
logic(Logic logic)
Set the logic of the game being played. |
IGameScore |
score()
Returns scoring method. |
void |
score(IGameScore score)
Set the scoring method to use. |
java.lang.String |
toString()
Reasonable toString method, revealing logic for player. |
java.util.Collection<IGameMove> |
validMoves(IGameState state)
Return the valid moves for this player given the game state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected char mark
public static final char OMARK
public static final char XMARK
protected IGameScore score
protected Logic logic
Constructor Detail |
---|
public Player(char mark)
Installs default scoring method that evaluates all boards as 0.
mark
- Mark to be played (cannot be ' ')
java.lang.IllegalArgumentException
- if ' ' is used as the mark.Method Detail |
---|
public char getMark()
public char getOpponentMark()
public abstract IGameMove decideMove(IGameState board)
If the player decides to forfeit the game, return null; otherwise a valid Move object is returned that can be played on the given board state.
board
-
public java.lang.String toString()
toString
in class java.lang.Object
public int eval(IGameState state)
eval
in interface IPlayer
state
- The game statepublic Logic logic()
public void logic(Logic logic)
public IGameScore score()
public void score(IGameScore score)
score
in interface IPlayer
public int hashCode()
Note that equals is restricted to be '==' since we do not override .equals
hashCode
in class java.lang.Object
public java.util.Collection<IGameMove> validMoves(IGameState state)
validMoves
in interface IPlayer
state
- Current game state position
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |