Subject: | [Patch] off-by-one error in legal() usage example |
This patch against Games-Go-Referee-0.07 fixes an off-by-one error as
well as a wrong variable name in the POD documentation for the legal()
method, and it adds a clarification wrt this method's return values.
-Martin
Subject: | Games-Go-Referee-0.07-fixdoc.patch |
--- lib/Games/Go/Referee.pm.orig 2008-10-26 14:07:06.000000000 +0100
+++ lib/Games/Go/Referee.pm 2009-09-02 10:06:36.000000000 +0200
@@ -1131,14 +1131,15 @@
my @points = $referee->legal($colour); # $colour must be 'B' or 'W'
-Returns an array of a player's legal move co-ordinates.
+Returns an array of a player's legal move co-ordinates, not including pass.
Usage example -
+ my $colour = 'B';
my @legalpoints = $referee->legal($colour);
while ($#legalpoints >= 0){
# play a random legal move
- $referee->play($colour, @points[int(rand($#legalpoints))]);
+ $referee->play($colour, $legalpoints[int(rand(0+@legalpoints))]);
$colour = ($colour eq 'B') ? 'W' : 'B';
@legalpoints = $referee->legal($colour);
}