Games::Go::Coordinate - represents a board coordinate in the game of Go
use Games::Go::Coordinate; my $c1 = Games::Go::Coordinate->new(x => 4, y => 3); my $c2 = Games::Go::Coordinate->new(x => 4, y => 10); if ($c2 gt $c1) { ... }
This class represents a board coordinate in the game of Go. Coordinate objects can be compared (as strings) to see whether two ranks are equal or whether one rank is higher than the other. Coordinate objects stringify to the SGF notation (for example, (4,10) stringifies to dj.
(4,10)
dj
Additionally, this class defines the following methods:
my $coord = Games::Go::Coordinate->new(x => 7, y => 12);
Constructs a new objects. The constructor accepts named arguments - that is, a hash - and will set the hash values on the accessor methods denoted by the keys.
$coord->x(19);
Sets or gets the horizontal part of the coordinate. No bounds checking is done as it is conceivable to have boards with more than 19 lines, and for it might be useful to have virtual negative coordinates.
Clears the horizontal part of the coordinate.
$coord->y(13);
Sets or gets the vertical part of the coordinate.
Clears the vertical part of the coordinate.
$coord->set_sgf_coordinate('cf');
Takes a coordinate in SGF notation and sets x() and y() from it.
x()
y()
my $cord = Games::Go::Coordinate->new_from_sgf_coordinate('cf');
Alternative constructor that accepts an SGF coordinate and sets x() and y() from it.
Returns the coordinate in SGF notation. This is also how the coordinate object stringifies.
Returns the coordinate in (x,y) notation. For example, it might return a string (16,17).
(x,y)
(16,17)
$coord->translate(2, -3);
Takes as arguments - in that order - a horizontal delta and a vertical delta and translates the coordinate by those deltas.
If you talk about this module in blogs, on del.icio.us or anywhere else, please use the gamesgocoordinate tag.
gamesgocoordinate
No bugs have been reported.
Please report any bugs or feature requests to bug-games-go-coordinate@rt.cpan.org, or through the web interface at http://rt.cpan.org.
bug-games-go-coordinate@rt.cpan.org
See perlmodinstall for information and options on installing Perl modules.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.
Marcel Grünauer, <marcel@cpan.org>
<marcel@cpan.org>
Copyright 2007 by Marcel Grünauer
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Games::Go::Coordinate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Go::Coordinate
CPAN shell
perl -MCPAN -e shell install Games::Go::Coordinate
For more information on module installation, please visit the detailed CPAN module installation guide.