Class Othello

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----Othello

public class Othello
extends Applet
Java Othello Openings Applet

Version:
1.00
Author:
Bill Lorton

Variable Index

 o _alpha_openings
The top node of the frequency sorted opening nodes.
 o _board
Handles the drawing of the board.
 o _curr_lookup
The current board orientation lookup table.
 o _list_panel
Handles the updating and manipulation of the list.
 o _o1_lookup
The base orientation lookup table.
 o _o2_lookup
A lookup table for the second board orientation.
 o _o3_lookup
A lookup table for the third board orientation.
 o _o4_lookup
A lookup table for the fourth board orientation.
 o _opening
The current opening.
 o _openings
The root node of a hierarchical tree of nodes that is organized by move.
 o _played_moves
Stores the moves of the selected opening that have been made.
 o _player_thread
Thread object for playing the moves.
 o _unplayed_moves
Stores the moves of the selected opening that have not yet been made.

Constructor Index

 o Othello()

Method Index

 o _currMove()
Replays the current move of the selected opening.
 o _fillAlphaList()
Fills the list with all of the openings, sorted by frequency.
 o _fillContinuationsList()
Fills the list with the continuations of the currently selected opening.
 o _findTreeNode(String)
Returns the tree node for the given move sequence.
 o _getMovePos(String, IntHolder, IntHolder)
Translates a single move into a row/col pair for the currently selected board orientation.
 o _lastMove()
Makes the remaining number of moves in the selected opening.
 o _makeMove(String)
Performs one move by translating the move into a row/col for the currently selected board orientation.
 o _makeMoves(int)
Makes a number of moves and updates _unplayed_moves.
 o _nextMove()
Makes one additional move of the selected opening.
 o _parseName(StringTokenizer)
Parses the opening name from the string.
 o _parseOrientation(StringTokenizer, int[])
Parses the orientation array from a string.
 o _prevMove()
Resets the board and makes one fewer move of the selected opening than previously was shown.
 o _prevOpening(OTNode)
Returns the parent opening of the given opening.
 o _readOpenings()
Reads and processes "openings.txt".
 o _readOrientations()
Reads "orientations.txt" which contains 3 rows of 64 integer values that form three of the orientation lookup tables (_o2_lookup,_o3_lookup, and _o4_lookup).
 o _resetBoard()
Clears the board, initializes the unplayed and played moves.
 o _translateMovesString(String)
Translates a move sequence to the current board orientation.
 o _translateRowColumn(IntHolder, IntHolder)
Translates a row/col pair into a new row/pair for the currently selected board orientation.
 o _updateBtns()
Updates the push buttons' enabled/disabled states.
 o _updateMoveSequenceLabel()
Updates the on-screen label with the move string of the selected opening that has been translated using the current board orientation.
 o atLastMove()
Returns whether or not the current move is the last of the selected opening.
 o continuationsOnlyChangedCallback(boolean)
Updates the list when the user clicks on the Continuations Only toggle button.
 o firstMove()
Sets the current move of the selected opening to the first move.
 o init()
Creates the user interface, reads "openings.txt" and "orientations.txt", fills the openings list.
 o initialSetup()
Returns whether or not the current state of the board is the initial setup that contains only the four inner discs.
 o listSelectCallback(OTNode, boolean)
Called when an opening is selected from the list, this method updates the interface to display the new opening.
 o nextMove()
Sets the current move of ths selected opening to the next move.
 o previousOpening()
Finds the parent opening for the current opening and then displays a list of all child openings of that parent opening.
 o stop()
Stops playing through the moves of the selected opening.

Variables

 o _alpha_openings
 protected OTNode _alpha_openings
The top node of the frequency sorted opening nodes. This node does not itself contain data.

 o _openings
 protected OTNode _openings
The root node of a hierarchical tree of nodes that is organized by move. This node does not contain any move data.

 o _opening
 protected OTNode _opening
The current opening.

 o _o1_lookup
 protected int _o1_lookup[]
The base orientation lookup table. This table is automatically generated and has values 1-64. The lookup table arrays are arrays of 64 integers which represent the 8x8 board. Row one of the board is index position 0-7 of the array, row two is 8-15, etc. The arrays are lookup tables that determine how discs are to be displayed in the applet. To determine what row/col a disc should be displayed in on the board, the disc's position is converted from a row/column value into a single value using _translateRowColumn(r,c). This single value is used to index _curr_lookup which is the pointer to the currently selected orientation array. The value that is returned is then converted back to a row and column value and the disc is drawn.

 o _o2_lookup
 protected int _o2_lookup[]
A lookup table for the second board orientation. This table is read from "orientations.txt".

 o _o3_lookup
 protected int _o3_lookup[]
A lookup table for the third board orientation. This table is read from "orientations.txt".

 o _o4_lookup
 protected int _o4_lookup[]
A lookup table for the fourth board orientation. This table is read from "orientations.txt".

 o _curr_lookup
 protected int _curr_lookup[]
The current board orientation lookup table. This points to the lookup table that cooresponds to the currently selected board orientation.

 o _played_moves
 protected String _played_moves
Stores the moves of the selected opening that have been made.

 o _unplayed_moves
 protected String _unplayed_moves
Stores the moves of the selected opening that have not yet been made.

 o _board
 protected Board _board
Handles the drawing of the board.

 o _list_panel
 protected ListPanel _list_panel
Handles the updating and manipulation of the list.

 o _player_thread
 protected PlayerThread _player_thread
Thread object for playing the moves.

Constructors

 o Othello
 public Othello()

Methods

 o _parseName
 protected String _parseName(StringTokenizer st)
Parses the opening name from the string.

Parameters:
st - the string to parse
Returns:
the name of the opening
 o _parseOrientation
 protected void _parseOrientation(StringTokenizer st,
                                  int array[])
Parses the orientation array from a string.

Parameters:
st - the string tokenizer to parse
array - the resulting array
 o _readOrientations
 protected void _readOrientations()
Reads "orientations.txt" which contains 3 rows of 64 integer values that form three of the orientation lookup tables (_o2_lookup,_o3_lookup, and _o4_lookup). The fourth lookup table (_o1_lookup) is automatically generated as values 1-64. The current lookup table is initialized to _o1_lookup.

 o _readOpenings
 protected void _readOpenings()
Reads and processes "openings.txt".

 o _updateBtns
 protected void _updateBtns()
Updates the push buttons' enabled/disabled states.

 o _resetBoard
 protected void _resetBoard()
Clears the board, initializes the unplayed and played moves. The played and unplayed moves are used so that the user can traverse through an opening's individual moves.

 o _translateRowColumn
 protected void _translateRowColumn(IntHolder row,
                                    IntHolder col)
Translates a row/col pair into a new row/pair for the currently selected board orientation.

Parameters:
row - the row to translate. this parameter will be modified
col - the column to translate. this parameter will be modified
 o _getMovePos
 protected boolean _getMovePos(String move,
                               IntHolder row,
                               IntHolder col)
Translates a single move into a row/col pair for the currently selected board orientation.

Parameters:
move - the move to translate
row - the resulting row
col - the resulting column
Returns:
true if the move would result in placing a white disc, false if a black disc would be placed
 o _makeMove
 protected void _makeMove(String move)
Performs one move by translating the move into a row/col for the currently selected board orientation. The played moves is updated to reflect the "playing" of this move.

Parameters:
move - the move to make
 o _makeMoves
 protected void _makeMoves(int num_to_make)
Makes a number of moves and updates _unplayed_moves.

Parameters:
num_to_make - the number of moves to make
 o _currMove
 protected void _currMove()
Replays the current move of the selected opening. This is only used when the board orientation changes.

 o _prevMove
 protected void _prevMove()
Resets the board and makes one fewer move of the selected opening than previously was shown.

 o _nextMove
 protected void _nextMove()
Makes one additional move of the selected opening.

 o _lastMove
 protected void _lastMove()
Makes the remaining number of moves in the selected opening.

 o _findTreeNode
 protected OTNode _findTreeNode(String moves)
Returns the tree node for the given move sequence.

Parameters:
moves - the move sequence to find
Returns:
the tree node for the move sequence
 o _fillAlphaList
 protected void _fillAlphaList()
Fills the list with all of the openings, sorted by frequency.

 o _fillContinuationsList
 protected void _fillContinuationsList()
Fills the list with the continuations of the currently selected opening.

 o _prevOpening
 protected OTNode _prevOpening(OTNode opening)
Returns the parent opening of the given opening.

Parameters:
opening - the node of the opening to query
Returns:
the node of the opening that is the parent of the given opening's node
 o _translateMovesString
 protected String _translateMovesString(String moves)
Translates a move sequence to the current board orientation.

Parameters:
moves - move sequence for the base orientation
Returns:
a new move sequence for the current board orientation
 o _updateMoveSequenceLabel
 protected void _updateMoveSequenceLabel()
Updates the on-screen label with the move string of the selected opening that has been translated using the current board orientation.

 o init
 public void init()
Creates the user interface, reads "openings.txt" and "orientations.txt", fills the openings list.

Overrides:
init in class Applet
 o initialSetup
 public boolean initialSetup()
Returns whether or not the current state of the board is the initial setup that contains only the four inner discs.

Returns:
true if the current opening is the initial setup
 o listSelectCallback
 public void listSelectCallback(OTNode n,
                                boolean continuations_only)
Called when an opening is selected from the list, this method updates the interface to display the new opening. If the continuations only toggle is set, the list is also updated to just show the child openings of the newly selected opening.

Parameters:
n - the node of the opening that was selected
continuations_only - the current state of the continuations only toggle
 o continuationsOnlyChangedCallback
 public void continuationsOnlyChangedCallback(boolean continuations_only)
Updates the list when the user clicks on the Continuations Only toggle button. If the previously selected item in the list is in the new list, that item selected will be selected in the new list.

Parameters:
continuations_only - the new value of the continuations toggle
 o previousOpening
 public boolean previousOpening()
Finds the parent opening for the current opening and then displays a list of all child openings of that parent opening. Updates the display to indicate the newly selected opening. If the previously selected opening was a top level opening then display "Initial Setup" as the new selection. This method can only be called in "Continuations Only" mode.

Returns:
non-zero if the new opening exists, zero if the it is the initial setup
 o atLastMove
 public boolean atLastMove()
Returns whether or not the current move is the last of the selected opening.

Returns:
non-zero if the current move is the last of the selected opening
 o firstMove
 public void firstMove()
Sets the current move of the selected opening to the first move.

 o nextMove
 public void nextMove()
Sets the current move of ths selected opening to the next move.

 o stop
 public void stop()
Stops playing through the moves of the selected opening.

Overrides:
stop in class Applet