|
AGATourn - Perl extensions to ease the pain of using AGA tournament data files. |
AGATourn - Perl extensions to ease the pain of using AGA tournament data files.
use Games::Go::AGATourn;
my $agaTourn = Games::Go::AGATourn->new (options);
An AGATourn object represents a round or several rounds of an American Go Association tournament. There are methods for parsing several type of AGA file format:
A note on IDs: in general, hashes in an AGATourn object are keyed by the AGA ID. An AGA ID consists of a three letter country specifier (like USA or TMP for temporary IDs) concatenated to an integer. Here we specify the three letter country specifier as the 'country' and the integer part as the 'agaNum'. The country concatenated with the agaNum is the ID. My ID for example is USA2122. IDs should be normalized (capitalize the country part and remove preceding 0s from the agaNum part) with the NormalizeID method (below).
Note also that some programs may accept limited integers in the agaNum part of the ID. Accelerat, for example, seems to accept only up to 32K (someone used a signed short somewhere?)
Default: undef
Default 'register.tde' (in the current directory)
Default: 0
The tdlist file does not include country information in the ID, so the ParseTdListLine method returns country => defaultCountry.
Default: 'USA'
If the line is not parsable, prints a warning and returns undef.
Returns 0 if $fileName couldn't be opened for reading, 1 otherwise.
# this line is a comment. the following line is a directive:
## HANDICAPS MAX
# the following line is a name line:
USA02122 Augustin, Reid 5.0 CLUB=PALO # 12/31/2004 CA
The return value is a reference to a hash of the following values: agaNum => just the number part of the ID country => just the country part of the ID (default ='USA') name => complains if name doesn't contain a comma agaRating => rating for the player agaRank => undef if line contains a rating and not a rank club => if there is a club association, '' if not flags => anything left over (excluding comment) comment => everything after the #, '' if none
If the line is a directive, the return hash reference contains only: directive => the directive name value => the directive value ('' if none)
If the line is a comment, leading and trailing whitespace is removed and the hash contains only: comment => comment contents (may be '')
If the line is empty, returns undef.
If the line is not parsable, prints a warning and returns undef.
Sets the current Round number to the digit part of fileName.
Returns 0 if fileName couldn't be opened for reading, 1 otherwise.
Complains if either player, or both, are not registered via AddRegisterLine.
TMP18 TMP10 b 0 7 # Lee, Ken -28.5 : Yang, John -28.5
# wID bID result handi komi comment
The return value is a reference to a hash of the following values: wcountry => combine with wagaNum to get complete ID wagaNum => the number part of white's AGA number bcountry => combine with bagaNum to get complete ID bagaNum => the number part of black's AGA number result => winner: 'b', 'w' or '?' handi => handicap game was played with komi => komi game was played with comment => everything after the #
If $line is empty, returns undef.
If $line is a comment, returns only: comment => everything after the #
If the line is not parsable, prints a warning and returns undef.
Since some directives (like BAND) may occur several times, all directives are stored as a list in the order added (either from ReadRegisterFile or AddRegisterLine). Certain directives (HANDICAPS ROUNDS RULES TOURNEY) keep only the last directive added.
Some directives have no associated value.
Directive returns undef if $directive has not been added, or a list (possibly empty) if $directive has been added.
If called with no arguments (or $directive is undef), returns a reference to a hash of all the current directives.
If $id is undef, returns a reference to the entire Name hash (keyed by ID).
$id can also be a rank ('4d', or '5k'), or a rating (4.2 or -5.3, but not between 1.0 and -1.0). This form is simply a converter - $newRating is not accepted.
If $id is defined but not registered (via AddRegisterLine), complains and returns undef.
If $id is not defined, returns a reference to the entire Rank hash (keyed by IDs).
(k - 0.3) / 6
for 8k and weaker. If the line contains a rating of the form '-4.5' or '3.4', sigma is 0.6 for -8.0 and stronger, and
(-rating - 4.4) / 6
for weaker than -8.0.
Complains and returns undef if $id is undefined or unregistered.
If no $id parameter is passed, returns a reference to the entire Club hash (keyed by IDs).
Returns undef if $id is not registered (via AddRegisterLine). If no $id parameter is passed, returns a reference to the entire Flags hash (keyed by IDs).
If no $id argument is passed, returns a reference to the entire Comments hash (keyed by IDs).
Games are added via the ReadRoundFile or the AddRoundLine methods.
Entries in the returned list are comma separated strings. They can be parsed with:
my ($whiteID, $blackID, $result,
$handicap, $komi, $round) = split(',', $agaTourn->GamesList[$index]);
If no $id argument is passed, returns a reference to the entire Wins hash (keyed by IDs).
If no $id argument is passed, returns a reference to the entire Losses hash (keyed by IDs).
If no $id argument is passed, returns a reference to the entire NoResults hash (keyed by IDs).
If no $id argument is passed, returns a reference to the entire Played hash (keyed by IDs).
See also BandName below.
Scoring bands are specified via AddRegisterLine with ##BAND directives.
AGATourn complains if bands are specified with holes between them.
The bands are sorted (by strength) and indexed. BandName returns the original name (as specified in the ##BAND directive) from a band index.
If player1 is stronger than player two, the handicap is a positive number. If player1 is weaker than player2, (players need to be swapped), the returned handicap is a negative number. If the handicap would normally be 0 and the players need to be swapped, the returned handicap is -1.
A handicap of 1 is never returned. The returned handicap and komi are always integers (you may assume that komi needs a additional half-point if you like).
If either player1 or player2 is invalid, Handicap complains (during the call to Rating for the player) and returns (-1, -1).
Handicap uses the following table (same as the AGA handicap practice):
rating handi Ing AGA diff Komi Komi 0.000-0.650 0 7 6 even, normal komi 0.651-1.250 0 -1* 0 no komi (* black wins ties under Ing) 1.251-2.200 0 -7 -6 reverse komi 2.201-3.300 2 -2 0 two stones 3.301-4.400 3 -3 0 three stones ...
All $ids used as hash keys should be normalized.
tdfind(1) - prepare register.tde for an AGA Go tournamentaradjust(1) - adjust pairings and enter results for a roundtscore(1) - score a tournamentsend2AGA(1) - prepare tournament result for sending to AGA
Reid Augustin, <reid@netchip.com>
Copyright (C) 1999, 2004, 2005 by Reid Augustin
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
|
AGATourn - Perl extensions to ease the pain of using AGA tournament data files. |