Games::Go::SGF 0.01 review
DownloadGames::Go::SGF is a Perl module that can parse and dissect Standard Go Format files. SYNOPSIS use Games::Go::SGF; my $sgf
|
|
Games::Go::SGF is a Perl module that can parse and dissect Standard Go Format files.
SYNOPSIS
use Games::Go::SGF;
my $sgf = new Games::Go::SGF($sgfdata);
print "Game played on ".$sgf->date."n";
print $sgf->white. " (W) vs. ".$sgf->black." (B)n";
print "Board size: ".$sgf->size.". Komi: ".$sgf->komi."n";
while ($move = $sgf->move($move_no++)) {
print "$move_no: ".$move->move,"n";
}
This is a very simple SGF file parser, of currently limited functionality. It can read and step through SGF files, follow variations, and so on. It's good enough for getting simple statistics about games of Go, and building up Games::Go::Board objects representing games stored as SGF.
$sgf->move returns either a normal Games::Go::SGF::Node or a Games::Go::SGF::Variation object. They behave exactly the same, but the variation object has the additional methods mainline() to get the main line of the game, variation($n) to get the first node in the n'th variation, and variations to retrieve an array of variations. $variation->move will, by default, follow the mainline.
Requirements:
Perl
Games::Go::SGF 0.01 keywords