Board class
Represents a Go board state and operations.
The board is stored as a 2D list state[y][x] where null means empty,
and Stone.black/Stone.white represent stones.
Note:
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
↔ List<
List< Stone?> > -
Two-dimensional board state
state[y][x].nullrepresents an empty point.getter/setter pair - width → int
-
no setter
Methods
-
clear(
) → void - Resets the board to an empty state (keeps dimensions).
-
clone(
) → Board - Returns a deep copy of this board.
-
copyWith(
{List< List< ? state, Map<Stone?> >Stone, int> ? captures, KoInfo? koInfo}) → Board -
Returns a new Board with optionally replaced
state,captures, orkoInfo. -
diff(
Board board) → List< Vertex> ? -
Returns the list of coordinates that differ from
board, ornullif sizes differ. -
get(
Vertex vertex) → Stone? -
Returns the stone at
vertex, ornullif empty or out of board. -
getCaptures(
Stone player) → int -
Returns the number of stones captured by
player. -
getChain(
Vertex vertex) → List< Vertex> -
Returns the connected component (chain) of same-colored stones containing
vertex. Ifvertexis empty or out of board, returns an empty list. -
getConnectedComponent(
Vertex vertex, bool predicate(Vertex vertex), [List< Vertex> ? result]) → List<Vertex> -
Collects a connected component via
predicatestarting atvertex. Returns an empty list ifvertexis out of board. -
getDistance(
Vertex v1, Vertex v2) → int -
Manhattan distance between
v1andv2. -
getHandicapPlacement(
int count, {bool tygem = false}) → List< Vertex> - Returns candidate handicap placements.
-
getLiberties(
Vertex vertex) → List< Vertex> -
Returns the unique liberties (adjacent empty points) of the chain at
vertex. Returns an empty list for out-of-board or emptyvertex. -
getNeighbors(
Vertex vertex) → List< Vertex> -
Returns orthogonal neighbors (up, down, left, right) on the board.
Returns an empty list if
vertexis out of board. -
getRelatedChains(
Vertex vertex) → List< Vertex> -
Returns all stones of the same color as
vertexthat are reachable through paths consisting of same-colored stones and empty points. Returns an empty list for out-of-board or emptyvertex. -
has(
Vertex vertex) → bool -
Returns whether
vertexlies on the board (0 ≤ x < width and 0 ≤ y < height). -
hasLiberties(
Vertex vertex, [Map< Vertex, bool> ? visited]) → bool -
Returns whether the chain at
vertexhas at least one liberty. Returns false for out-of-board or emptyvertex. -
isEmpty(
) → bool -
isSquare(
) → bool -
isValid(
) → bool - Returns true if every chain on the board has at least one liberty.
-
makeMove(
Vertex vertex, Stone stone, {bool preventOutOfBoard = false, bool preventSuicide = false, bool preventOverwrite = false, bool preventKo = false}) → Board -
Returns a new Board with
stoneplayed atvertex. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parseVertex(
String coord) → Vertex? -
Parses a Go coordinate string like "D16" to a Vertex.
Returns
nullif invalid or out of board. -
set(
Vertex vertex, Stone? stone) → Board -
Sets
stoneatvertex. Usenullto clear a point. -
setCaptures(
Stone stone, int value) → Board -
Sets the capture count for
stonetovalue. Returnsthisfor chaining. -
stringifyVertex(
Vertex vertex) → String -
Converts
vertexto a Go coordinate string like "D16". Returns an empty string ifvertexis out of board. -
toString(
) → String -
Returns a human-readable textual representation of the board.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited