net.sourceforge.cilib.games.game.tictactoe
Class TicTacToe

java.lang.Object
  extended by net.sourceforge.cilib.games.game.Game<GridGameState>
      extended by net.sourceforge.cilib.games.game.GridGame
          extended by net.sourceforge.cilib.games.game.tictactoe.TicTacToe
All Implemented Interfaces:
Serializable, StateGame, Cloneable

public class TicTacToe
extends GridGame
implements StateGame

This is an implimentation of the game of Tic Tac Toe

Author:
leo
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.cilib.games.game.Game
agentMeasurement, currentPlayer, players
 
Constructor Summary
TicTacToe()
           
TicTacToe(TicTacToe other)
          Copy constructor
TicTacToe(TicTacToe other, GridGameState newState)
          
 
Method Summary
 void display()
          Print the game to the console, is useful during testing.
 boolean gameOver()
          check if the game should terminate
 List<GameState> generateStates(int currentPlayer)
          This method generates every possible from the current state for a specific player
 Game<GridGameState> getClone()
          Create a cloned copy of the current object and return it.
 Game<GridGameState> getClone(GridGameState newState)
          Get a clone with the given GameState This method should typically be used by the StateTraversalStrategy and Agent with regards to decision making when playing the game.
 AbstractGameResult getGameResult()
          Get the result of the game (Win/Lose/Draw)
 void initializeGame()
          perform any game specific initialization
 
Methods inherited from class net.sourceforge.cilib.games.game.GridGame
getHeight, getWidth, setHeight, setWidth
 
Methods inherited from class net.sourceforge.cilib.games.game.Game
addMeasurement, assignPlayerScore, clearMeasurementData, clearMeasurements, getAgentMeasurements, getCurrentIteration, getCurrentPlayer, getCurrentState, getDecisionState, getDomainForPlayer, getNextPlayerID, getPlayer, getPlayerCount, getPlayerIDList, getPlayerScore, getScoringStrategy, initializeAgent, playGame, playGame, setAgent, setAgent, setCurrentGameState, setCurrentPlayer, setEntityScore, setScoringStrategy, setSeedingStrategy, setStartPlayer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TicTacToe

public TicTacToe()

TicTacToe

public TicTacToe(TicTacToe other)
Copy constructor

Parameters:
other -

TicTacToe

public TicTacToe(TicTacToe other,
                 GridGameState newState)

Method Detail

display

public void display()
Print the game to the console, is useful during testing.

Specified by:
display in class Game<GridGameState>

gameOver

public boolean gameOver()
check if the game should terminate

Specified by:
gameOver in class Game<GridGameState>
Returns:
the endgame flag

getClone

public Game<GridGameState> getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in class Game<GridGameState>
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

getClone

public Game<GridGameState> getClone(GridGameState newState)
Get a clone with the given GameState This method should typically be used by the StateTraversalStrategy and Agent with regards to decision making when playing the game. Since this process includes making alot of copies of the game a seperate, faster, method is neccesary that does not waste time by making unneccesary copies of the game state and player logic.

Specified by:
getClone in class Game<GridGameState>
Parameters:
newState - the new sate to use
Returns:
the copy

getGameResult

public AbstractGameResult getGameResult()
Get the result of the game (Win/Lose/Draw)

Specified by:
getGameResult in class Game<GridGameState>
Returns:
the relevant AbstractGameResult object

initializeGame

public void initializeGame()
perform any game specific initialization

Specified by:
initializeGame in class Game<GridGameState>

generateStates

public List<GameState> generateStates(int currentPlayer)
This method generates every possible from the current state for a specific player

Specified by:
generateStates in interface StateGame
Parameters:
currentPlayer - the player whos turn it is
Returns:
a list of possible game states


Copyright © 2009 CIRG. All Rights Reserved.