blib/lib/Chess/Elo.pm

filter: Statementstmt 100% 25 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 30 / 30 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package Chess::Elo;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our @ISA = qw(Exporter);
9  
10 # Items to export into callers namespace by default. Note: do not export
11 # names by default without a very good reason. Use EXPORT_OK instead.
12 # Do not simply export all your public functions/methods/constants.
13  
14 # This allows declaration use Chess::Elo ':all';
15 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
16 # will save memory.
17 1 our %EXPORT_TAGS = ( 'all' => [ qw(
18 elo
19 ) ] );
20  
21 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
22  
23 1 our @EXPORT = qw(
24
25 );
26  
27 1 our $VERSION = '1.0a';
28  
29  
30 # Preloaded methods go here.
31  
32 1 our $factor = 32;
33 1 our $divisor = 400;
34  
35 6 ▶sub elo {
Subroutine elo: called CC=1 SCAR=0.0
Pod documented
36
37 6 my ($A, $result, $B) = @_;
38  
39 6 my $Aexp = 10 ** ( ($B - $A) / $divisor ) ;
40
41  
42 6 my $A2 =
43 $A + $factor * ( $result -
44 ( 1 /
45 ( 1 + $Aexp )
46 )
47 )
48 ;
49  
50 6 my $Bexp = 10 ** ( ($A - $B) / $divisor ) ;
51
52 6 $result = 1 - $result;
53  
54 6 my $B2 =
55 $B + $factor * ( $result -
56 ( 1 /
57 ( 1 + $Bexp )
58 )
59 )
60 ;
61  
62 6 ($A2, $B2)
63 }
64  
65 1 1;
66 __END__
↑ Summary