|
Internet Chess ToolKit v0.2.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This class facilitiates the branching aspect of the History tree. There are three main features the "departure move", which is the the move from which all the continuations originate. There is the "main-line", which is the primary continuation from the "move". And then there are "variations". These are auxilery or alternate continuations.
This class allows the variations to be promoted in their order and all the way up to the main-line, which, though not a "variation" in the sense used for this class, is the top most variation in regards to the ordered variations. In other words: if you promote a variation high enough it will become the main-line.
Note: the main-line is the only continuation that is allowed to be null. this is often used when the game ends with the departure move and the variations show possible continuations.
Method Summary | |
void |
add(Move m)
This adds the move to the continuation list. |
void |
add(Move m,
boolean isMain)
adds a move to the continuation list. |
int |
demote(Move move,
int num)
demotes the variation moving it down the variation list. |
void |
dispose()
reclaims all resources and recursively deletes all branch moves. |
java.lang.String |
dump()
for debugging |
boolean |
exists(int variation)
this does not throw ArrayOutOfBoundsException if your ask an index out of range, you just get false returned. |
boolean |
exists(Move move)
determines if the move is in the current list of continuations |
Move[] |
find(Move m)
searches the continuation list for moves that are equal to the move submitted. |
int[] |
findIndex(Move m)
searches the continuation list for moves that are equal to the move submitted. |
Move |
get(int i)
|
Move |
getDepartureMove()
gets the departure move, that is the move that comes before all of these variations. |
int |
getIndex(Move m)
gets the index of this Move object in the variation branches. |
Move |
getMainLine()
get the next move in the game history. |
boolean |
hasMainLine()
calls exists(0). |
boolean |
hasVariations()
|
boolean |
isTerminal()
no main line and no variations exist. |
int |
promote(Move move,
int num)
promotes the move up the list of continuations. |
void |
remove(int i)
removes a variation from the continuation list. |
void |
remove(Move m)
removes the move from the continuation list. |
void |
removeAll()
makes this move a terminal node. |
void |
removeAllVariations()
All variations are destroyed as Move.dispose() is called recusively down the line for each variation. |
boolean |
setMainLineTerminal()
set the mainline to null. |
int |
size()
gets the number of continuation (variations + the main-line) that exist after this move. |
int |
sizeOfVariations()
much more useful than size(), this function returns the number of variations (continuations minus the main-line). |
Method Detail |
public Move getDepartureMove()
public boolean isTerminal()
public boolean setMainLineTerminal()
public boolean exists(int variation)
variation
- which branch to look at (0) is the main line
public boolean exists(Move move)
move
- is this move in the list of continuationpublic boolean hasMainLine()
public Move getMainLine()
public boolean hasVariations()
public Move get(int i)
public int size()
public int sizeOfVariations()
public void add(Move m, boolean isMain)
isMain
- If true then the move added will be the first
continuation. All other moves will be bumped down (if the
mainline wasn't null to begin with). LIFO
if isMake is not true then the move will be the last branch,
in otherwords, appended to the list. FIFOpublic void add(Move m)
public int getIndex(Move m)
public Move[] find(Move m)
public int[] findIndex(Move m)
public void remove(int i)
may
- throw ArrayIndexOutOfBoundExceptionpublic void remove(Move m)
may
- throw ArrayIndexOutOfBoundExceptionpublic void removeAll()
public void removeAllVariations()
public void dispose()
public int promote(Move move, int num)
num
- how many places to displace the variations.
If 0 the variation will be promoted to the main line.
IndexArrayOutOfBoundException
- if you promote past the main line
java.lang.NullPointerException
- if the move is not in the variation listpublic int demote(Move move, int num)
num
- how many places to displace the variations.
If 0 the variation will be demoted to last variation
IndexArrayOutOfBoundException
- if demoted past the last variation
java.lang.NullPointerException
- if the move is not in the variation listpublic java.lang.String dump()
|
Submit a bug or feature Visit the Website Internet Chess ToolKit is licensed under the GPL v2 . |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |