Games-Ratings

 view release on metacpan or  search on metacpan

lib/Games/Ratings/Go/EGF.pm  view on Meta::CPAN

    elsif ($player_rating < 2600) {
        $con = 15 - ( 15-11 )*( $player_rating-2400 )/(2600-2400);
    }
    elsif ($player_rating == 2600) {
        $con = 11;
    }
    elsif ($player_rating < 2700) {
        $con = 11 - ( 11-10 )*( $player_rating-2600 )/100;
    }
    elsif ($player_rating == 2700) {
        $con = 10;
    }
    elsif ($player_rating > 2700) {
        $con = 10;
    }

    ## return parameter 'con'
    return $con;
}

1; # Magic true value required at end of module
__END__


=head1 NAME
 
Games::Ratings::Go::EGF - calculate changes to EGF ratings (GoR)
 

=head1 VERSION
 
This document describes Games::Ratings::Go::EGF version 0.0.1
 

=head1 SYNOPSIS
 
 use Games::Ratings::Go::EGF;

 my $player = Games::Ratings::Go::EGF->new();
 $player->set_rating(2240);
 $player->add_game( {
                      opponent_rating => 2114,
                      result          => 'win',   ## or 'draw' or 'loss'
                      handicap        => '+5',    ## got 5 handicap
                                                  ## or '-2': gave 2 h.
                                                  ## can be ommitted
                    }
                  );

 my $rating_change = $player->get_rating_change();
 my $new_rating = $player->get_new_rating();


=head1 DESCRIPTION

This module provides methods to calculate EGF rating (GoR) changes for one
player, having played one or more rated games. Gains and losses are calculated
according to the EGF rating rules (cmp. EGF Official ratings:
http://gemma.ujf.cas.cz/~cieply/GO/gor.html).

Basically EGF uses a formula to calculate scoring probabilities in dependence
from rating differences between players: Se(A) = 1/(e^[D/a] + 1).

Furthermore EGF uses a coefficient ('con') depending on the current
rating which reduces rating change for stronger players and increases rating
change for weaker players: Rnew - Rold = con * (Sa - Se).
 

=head1 INTERFACE 

This modules provides the following methods specific to EGF ratings. Other
(more generic) methods for rating calculation are provided by Games::Ratings.
Please check the documentation of Games::Ratings for those methods.

=head2 get_rating_change

  my $rating_change = $player->get_rating_change();

Calculate rating changes for all stored games and return sum of those
changes.

=head2 get_new_rating

  my $new_rating = $player->get_new_rating();

Calculate new rating after the given games.

=head2 get_points_expected

  my $points_expected = $player->get_points_expected();

Calculate expected points according to rating differences between own rating
and opponents ratings.


=head1 CONFIGURATION AND ENVIRONMENT

Games::Ratings requires no configuration files or environment variables.


=head1 DEPENDENCIES

This module relies on Games::Ratings which provides some generic methods, e.g.
  * new()
  * get_rating()
  * set_rating()
  * get_coefficient()
  * set_coefficient()
  * add_game()
  * remove_all_games()
  * DESTROY()


=head1 DIAGNOSTICS
 
At the moment, there are no error or warning messages that the module can
generate.

=for author to fill in:
    List every single error and warning message that the module can
    generate (even the ones that will "never happen"), with a full



( run in 1.255 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )