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
-
_alpha_openings
-
The top node of the frequency sorted opening nodes.
-
_board
-
Handles the drawing of the board.
-
_curr_lookup
-
The current board orientation lookup table.
-
_list_panel
-
Handles the updating and manipulation of the list.
-
_o1_lookup
-
The base orientation lookup table.
-
_o2_lookup
-
A lookup table for the second board orientation.
-
_o3_lookup
-
A lookup table for the third board orientation.
-
_o4_lookup
-
A lookup table for the fourth board orientation.
-
_opening
-
The current opening.
-
_openings
-
The root node of a hierarchical tree of nodes that is organized by move.
-
_played_moves
-
Stores the moves of the selected opening that have been made.
-
_player_thread
-
Thread object for playing the moves.
-
_unplayed_moves
-
Stores the moves of the selected opening that have not yet been made.
-
Othello()
-
-
_currMove()
-
Replays the current move of the selected opening.
-
_fillAlphaList()
-
Fills the list with all of the openings, sorted by frequency.
-
_fillContinuationsList()
-
Fills the list with the continuations of the currently selected opening.
-
_findTreeNode(String)
-
Returns the tree node for the given move sequence.
-
_getMovePos(String, IntHolder, IntHolder)
-
Translates a single move into a row/col pair for the currently selected
board orientation.
-
_lastMove()
-
Makes the remaining number of moves in the selected opening.
-
_makeMove(String)
-
Performs one move by translating the move into a row/col for the
currently selected board orientation.
-
_makeMoves(int)
-
Makes a number of moves and updates _unplayed_moves.
-
_nextMove()
-
Makes one additional move of the selected opening.
-
_parseName(StringTokenizer)
-
Parses the opening name from the string.
-
_parseOrientation(StringTokenizer, int[])
-
Parses the orientation array from a string.
-
_prevMove()
-
Resets the board and makes one fewer move of the selected opening than
previously was shown.
-
_prevOpening(OTNode)
-
Returns the parent opening of the given opening.
-
_readOpenings()
-
Reads and processes "openings.txt".
-
_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).
-
_resetBoard()
-
Clears the board, initializes the unplayed and played moves.
-
_translateMovesString(String)
-
Translates a move sequence to the current board orientation.
-
_translateRowColumn(IntHolder, IntHolder)
-
Translates a row/col pair into a new row/pair for the currently
selected board orientation.
-
_updateBtns()
-
Updates the push buttons' enabled/disabled states.
-
_updateMoveSequenceLabel()
-
Updates the on-screen label with the move string of the selected
opening that has been translated using the current board orientation.
-
atLastMove()
-
Returns whether or not the current move is the last of the selected
opening.
-
continuationsOnlyChangedCallback(boolean)
-
Updates the list when the user clicks on the Continuations Only
toggle button.
-
firstMove()
-
Sets the current move of the selected opening to the first move.
-
init()
-
Creates the user interface, reads "openings.txt" and "orientations.txt",
fills the openings list.
-
initialSetup()
-
Returns whether or not the current state of the board is the initial
setup that contains only the four inner discs.
-
listSelectCallback(OTNode, boolean)
-
Called when an opening is selected from the list, this method updates
the interface to display the new opening.
-
nextMove()
-
Sets the current move of ths selected opening to the next move.
-
previousOpening()
-
Finds the parent opening for the current opening and then displays
a list of all child openings of that parent opening.
-
stop()
-
Stops playing through the moves of the selected opening.
_alpha_openings
protected OTNode _alpha_openings
- The top node of the frequency sorted opening nodes. This node does not
itself contain data.
_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.
_opening
protected OTNode _opening
- The current opening.
_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.
_o2_lookup
protected int _o2_lookup[]
- A lookup table for the second board orientation. This table is
read from "orientations.txt".
_o3_lookup
protected int _o3_lookup[]
- A lookup table for the third board orientation. This table is
read from "orientations.txt".
_o4_lookup
protected int _o4_lookup[]
- A lookup table for the fourth board orientation. This table is
read from "orientations.txt".
_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.
_played_moves
protected String _played_moves
- Stores the moves of the selected opening that have been made.
_unplayed_moves
protected String _unplayed_moves
- Stores the moves of the selected opening that have not yet been made.
_board
protected Board _board
- Handles the drawing of the board.
_list_panel
protected ListPanel _list_panel
- Handles the updating and manipulation of the list.
_player_thread
protected PlayerThread _player_thread
- Thread object for playing the moves.
Othello
public Othello()
_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
_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
_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.
_readOpenings
protected void _readOpenings()
- Reads and processes "openings.txt".
_updateBtns
protected void _updateBtns()
- Updates the push buttons' enabled/disabled states.
_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.
_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
_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
_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
_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
_currMove
protected void _currMove()
- Replays the current move of the selected opening. This is only used
when the board orientation changes.
_prevMove
protected void _prevMove()
- Resets the board and makes one fewer move of the selected opening than
previously was shown.
_nextMove
protected void _nextMove()
- Makes one additional move of the selected opening.
_lastMove
protected void _lastMove()
- Makes the remaining number of moves in the selected opening.
_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
_fillAlphaList
protected void _fillAlphaList()
- Fills the list with all of the openings, sorted by frequency.
_fillContinuationsList
protected void _fillContinuationsList()
- Fills the list with the continuations of the currently selected opening.
_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
_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
_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.
init
public void init()
- Creates the user interface, reads "openings.txt" and "orientations.txt",
fills the openings list.
- Overrides:
- init in class Applet
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
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
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
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
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
firstMove
public void firstMove()
- Sets the current move of the selected opening to the first move.
nextMove
public void nextMove()
- Sets the current move of ths selected opening to the next move.
stop
public void stop()
- Stops playing through the moves of the selected opening.
- Overrides:
- stop in class Applet