NAME
AI::Evolve::Befunge::Board - board game object
SYNOPSIS
my $board = AI::Evolve::Befunge::Board->new(Size => $vector);
$board->set_value($vector, $value);
$board->clear();
DESCRIPTION
This module tracks board-game state for AI::Evolve::Befunge. It is only used for board-game-style physics, like tic tac toe, othello, go, chess, etc. Non-boardgame applications do not use a Board object.
CONSTRUCTOR
new
AI::Evolve::Befunge::Board->new(Size => $vector);
AI::Evolve::Befunge::Board->new(Size => $number, Dimensions => $number);
Creates a new Board object. You need to specify the board-size somehow, either by providing a Language::Befunge::Vector object, or by specifying the size of the side of a hypercube and the number of dimensions it exists in (2 is the most likely number of dimensions). If the Size argument is numeric, the Dimensions argument is required, and a size vector will be generated internally.
METHODS
clear
$board->clear();
Clear the board - set all spaces to 0.
as_string
my $string = $board->as_string();
Returns an ascii-art display of the current board state. The return value looks like this (without indentation):
.ox
.x.
oxo
as_binary_string
my $binary = $board->as_binary_string();
Returns an ascii-art display of the current board state. It looks the same as ->as_string(), above, except that the values it uses are binary values 0, 1, and 2, rather than plaintext descriptive tokens. This is suitable for passing to Language::Befunge::LaheySpace::Generic's ->store() method.
output
$board->output();
Prints the return value of the ->as_string() method to the console, decorated with row and column indexes. The output looks like this (without indentation):
012
0 .ox
1 .x.
2 oxo
fetch_value
$board->fetch_value($vector);
Returns the value of the board space specified by the vector argument. This is typically a numeric value; 0 means the space is unoccupied, otherwise the value is typically the player number who owns the space, or the piece-type (for games which have multiple types of pieces), or whatever.
set_value
$board->fetch_value($vector, $value);
Set the value of the board space specified by the vector argument.
copy
my $new_board = $board->copy();
Create a new copy of the board.