The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Games::Go::SGF - 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";
  }

DESCRIPTION

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.

TODO

Better documentation is planned; as is the ability to write as well as read SGF files.

AUTHOR

Simon Cozens simon@cpan.org

SEE ALSO

Games::Go::Board, http://www.red-bean.com/sgf/