Algorithm
Development Kit 1.0

algs.model.problems.tictactoe.model
Class StraightLogic

java.lang.Object
  extended by algs.model.problems.tictactoe.model.Logic
      extended by algs.model.problems.tictactoe.model.StraightLogic

public class StraightLogic
extends Logic

Logic of the normal TicTacToe

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

Constructor Summary
StraightLogic()
           
 
Method Summary
 StraightLogic copy()
          Each logic must implement 'copy' to properly be used when evaluating future moves.
 Move interpretMove(IGameState gameState, int col, int row, Player player)
          Method to determine the type of move that the user has selected.
 java.lang.String rules()
          rules of Straight Tic Tac Toe Apply.
 java.lang.String toString()
          Return name for logic.
 
Methods inherited from class algs.model.problems.tictactoe.model.Logic
initializeState, maxNumberMoves, score, validMoves
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StraightLogic

public StraightLogic()
Method Detail

rules

public java.lang.String rules()
rules of Straight Tic Tac Toe Apply.

Specified by:
rules in class Logic

copy

public StraightLogic copy()
Each logic must implement 'copy' to properly be used when evaluating future moves. Note that we can avoid clone if the Logic is readonly; simply return singleton instance.

Specified by:
copy in class Logic
Returns:
a copy of the StraightLogic object.

interpretMove

public Move interpretMove(IGameState gameState,
                          int col,
                          int row,
                          Player player)
Method to determine the type of move that the user has selected. Subclasses should override this method so they will be able to properly construct the appropriate move given the context. Note: First iteration of this method had just 'char mark' as argument; but then we faced the Neighbor game, and it became clear that we need to know the player making the move.

Specified by:
interpretMove in class Logic
Parameters:
gameState - current board state
col - selected column
row - selected row
player - player making the move.
Returns:
null if move is invalid; otherwise a valid Move object.

toString

public java.lang.String toString()
Return name for logic.

Overrides:
toString in class java.lang.Object

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.