Algorithm
Development Kit 1.0

algs.model.gametree
Interface IGameState

All Superinterfaces:
IGraphEntity
All Known Implementing Classes:
TicTacToeState

public interface IGameState
extends IGraphEntity

A valid representation of the state of a particular game with two players.

A game state is either in progress, has been won by a player, or is a draw.

For ease of debugging, each state has a reference counter that is incremented when a new state is computed via a move and never decremented. It can thus be used as a unique id when referencing states in the game tree later.

To support graphical drawing of state searches, this interface extends IGraphEntity.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Nested Class Summary
 
Nested classes/interfaces inherited from interface algs.debug.IGraphEntity
IGraphEntity.Formatter
 
Method Summary
 IGameState copy()
          Enable one to grab a copy of this game state.
 int counter()
          Debugging interface for retrieving counter.
 boolean equivalent(IGameState state)
          Determine if this game state is equivalent to the given state.
 void incrementCounter()
          Debugging interface for incrementing count of games.
 boolean isDraw()
          Determine if this game state is a draw.
 boolean isWin()
          Determine if this game state has a winner.
 
Methods inherited from interface algs.debug.IGraphEntity
nodeLabel
 

Method Detail

isDraw

boolean isDraw()
Determine if this game state is a draw.


isWin

boolean isWin()
Determine if this game state has a winner.


copy

IGameState copy()
Enable one to grab a copy of this game state.


equivalent

boolean equivalent(IGameState state)
Determine if this game state is equivalent to the given state.

The notion of equivalence is based upon the actual game. For games that exhibit symmetries in game state (such as board games), you can get great savings simply by reducing symmetrical positions.

Useful when attempting to reduce the search space. This method is defined separately from Object.equals(Object) to make sure there is no confusion with using equals by the JDK collection classes.

Parameters:
state - The game state being compared against.

incrementCounter

void incrementCounter()
Debugging interface for incrementing count of games.


counter

int counter()
Debugging interface for retrieving counter.


Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.