new Record(width, height)
Create a go game record that can handle plays and variations. A Board
object is created that will reflect the current position in game record.
Parameters:
Name | Type | Description |
---|---|---|
width |
int | Board width. |
height |
int | Board height. |
Methods
createNode(clearParentMarks, info) → {Node}
Create new empty node under current one.
Parameters:
Name | Type | Description |
---|---|---|
clearParentMarks |
bool | True to clear parent node marks. |
info |
Object | Node information - ko coordinate, comment, etc. |
Returns:
New, current node.
- Type
- Node
createSnapshot()
Create a snapshot of current Record state. Will contain board state and
current node.
Returns:
Snapshot to be used with restoreSnapshot().
first() → {Node}
Go to the beginning of the game tree.
Returns:
New current node.
- Type
- Node
getBoard() → {Board}
Get board object.
Returns:
Board object.
- Type
- Board
getCurrentNode() → {Node}
Get current node.
Returns:
Current node.
- Type
- Node
getRootNode() → {Node}
Get root node.
Returns:
Root node.
- Type
- Node
getVariation() → {int}
Get current variation number (zero-based).
Returns:
Current variations.
- Type
- int
getVariations() → {int}
Get number of variations for current node.
Returns:
Number of variations.
- Type
- int
next(variationopt) → {Node}
Advance to the next node in the game tree.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
variation |
int |
<optional> |
parameter to specify which variation to select, if there are several branches. |
Returns:
New current node or null if at the end of game tree.
- Type
- Node
normalize(node)
Normalize record so the longest variation is the first.
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | The node to start with. Defaults to root if unset. |
Returns:
int Length of longest subsequence.
previous() → {Node}
Back up a node in the game tree.
Returns:
New current node or null if at the beginning of game tree.
- Type
- Node
restoreSnapshot(raw)
Restore the Record to the state contained in snapshot. Use only if you
REALLY know what you are doing, this is mainly for creating Record
quickly from SGF.
Parameters:
Name | Type | Description |
---|---|---|
raw |
Object | Snapshot created with createSnapshot(). |
setVariation(variationopt)
Go to a variation. Uses previous() and next().
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
variation |
int |
<optional> |
parameter to specify which variation to select, if there are several branches. |