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

SYNOPSIS

    use Games::Go::AGA::BayRate;

    my $bayrate = Games::Go::AGA::BayRate->new(
        players => $tournament->players,    # ref to array of players
        games   => $tournament->games,      # ref to array of games
    };

    # assuming we don't have carryover sigma info:
    $bayrate->initSeeding($tdList);

    # caclulate new ratings
    $bayrate->calc_ratings;

    for (my $bay_player (@${bayrate->players}) {
        # transfer adjusted ratings back to tournament players
        my $tourn_player = $tournament->find_player($bay_player->id);
        $tourn_player->set_adj_rating($bay_player->rating);
    }

DESCRIPTION

The American Go Association (AGA) provides a rating system for the go players of the nation. The algorithm is described in detail in a paper on their web-site (http://usgo.org): AGARatings-Math.pdf. They also provide a C++ implementation example: bayrate.zip.

This package implements a perl version of bayrate, both the executable and the support objects (Game, Player, etc). Note: only bin/bayrate is included here, singlerate and check are left as an excersise for the student.

bayrate, and this module, require a fairly recent version of the GNU Scientific Library (GSL), including the devel portion (containing header files, etc). If you are using Fedora (linux), "yum install gsl gsl-devel" should be sufficient. Version 1.14 and later should work, earlier versions may not. To find your current version, run:

    pkg-config --modversion gsl

Work is being done to provide a full perl interface to GSL, but it is not complete as of this writing. I have used Inline::C to hook to the specific GSL functions used by bayrate.pl. The missing parts needed by bayrate.pl are the Multimin functions (f_minimizer and fdf_minimizer). Tests for the Inline::C interface to these functions (as well as the C versions as called out in the Gnu GSL documentation) are included in the 'extra' subdirectory of this package.

This module interfaces between a Games::Go::AGA::DataObjects objects and a Games::Go::AGA::BayRate::Collection object. A new BayRate object subclasses the Collection object and copies information from a list of Games::Go::AGA::DataObjects::Players and a list of Games::Go::AGA::DataObjects::Games (such as the lists provided by the players and games methods of a Games::Go::AGA::DataObjects::Tournament object) to the Collection. After calling the $bayrate->calc_ratings method to run the Collection rating algorithm, The adjusted ratings are available to copy back into the adj_ratings of the Tournament players.

IMPLEMENTATION

Given a collection of players, each with a rating and a sigma, and given a collection of games the players may or may not have participated in (including the outcomes of those games), this module uses Bayesian statistical mathods to determine an adjusted rating for each player so that the observed outcomes are considered to be 'most likely'.

In practice, what this means is that if player A defeats player B, but because of the difference in rating, this is the expected outcome, then the adjustments to the ratings of player A and player B will be rather small. On the other hand, if player B is expected to defeat player A, then the rating of player A should be raised rather significantly, and player B should be correspondingly lowered.

To use this in a tournament, enter the players and all the games after each round (NOTE: use the players' initial ratings, not their adjusted ratings, and add all the games from all rounds). For example, after round 3 is complete, enter all the games from rounds 1, 2, and 3. Then use the adjusted ratings to help find pairings for the next round (See Games::Go::Wgtd using the Best pairing method).

The effects of wins and losses propagate so that the adjustment to player A (who played against player B in the first round) can be affected by the outcome of player B's game against player C (in a subsequent round).

SEE ALSO

Games::Go::AGA::BayRate::Collection
Games::Go::AGA::BayRate::Game
Games::Go::AGA::BayRate::Player
Games::Go::Wgtd