NAME

Game::Go::Board - a readable view of a position, in columns and rows

VERSION

Version 0.01

SYNOPSIS

my $board = $game->board;

$board->at(3, 3);          # EMPTY, BLACK or WHITE
$board->libs(3, 3);        # the liberties of the chain there
print $board->to_text;

DESCRIPTION

Read-only, and it speaks in columns and rows.

Game::Go::Engine speaks in the C engine's padded indices, which are opaque on purpose: an index is not row * size + col, and the sentinel ring around the board is the only thing that makes the engine's neighbour arithmetic safe, so an index a caller worked out for itself would walk off the board. Nothing in this class's public interface takes or returns one.

Columns and rows are both 0-based and row 0 is the top, matching the engine's ordering and SGF's. Human coordinates number rows from the bottom and skip the letter I; converting between the two belongs to the notation layer and to nothing else.

METHODS

size

at

$board->at($col, $row)

The colour at a point: EMPTY, BLACK, WHITE, or BORDER for anything off the board.

libs

The exact liberties of the chain at a point, or -1 where there is no stone.

chain_size

chain_at

The chain at a point, as an arrayref of [$col, $row] pairs. Empty where there is no stone.

rows

The whole position, as an arrayref of arrayrefs of colours, row by row from the top.

stones

$board->stones(Game::Go::Rules::BLACK)

empties

How many points hold no stone.

hash_hex

The position's key, as sixteen hex characters. Hex and not a number, because a 64-bit value on a perl with 32-bit integers goes through an NV and loses bits. Two positions are the same position when their keys and their stones agree; the key alone is a filter and never the verdict.

zobrist_hex

$board->zobrist_hex($colour, $col, $row)

One point's contribution to that key, or undef off the board. It is public so the whole key can be recomputed from scratch and compared against the one the engine maintains a move at a time.

to_text

The position as text: X for black, O for white, a dot for empty, one line per row from the top. The same spelling the tests draw their positions in, so a failure reads against the diagram that caused it.

SEE ALSO

Game::Go, Game::Go::Engine.

AUTHOR

LNATION <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION <email@lnation.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)