X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Findex.pl;h=580ad658d040da70b5da15c635fb93da7a8baf79;hb=707f9416afa19e2c92a0bd94d34fb4d5d1ba3f0e;hp=4c826086bad28b01f66252c093f8bea7d2d45d13;hpb=7b7702bef38ce6e8275338a6f3972134cc56f143;p=wloh diff --git a/www/index.pl b/www/index.pl index 4c82608..580ad65 100755 --- a/www/index.pl +++ b/www/index.pl @@ -9,6 +9,7 @@ use POSIX; use Devel::Peek; use HTML::Entities; use Encode; +use utf8; use locale; require '../config.pm'; @@ -25,6 +26,7 @@ binmode STDOUT, ':utf8'; my %players = (); my %ratings = (); +my %ratings_stddev = (); my @matches = (); my %parms = (); my $match_stddev; @@ -39,7 +41,7 @@ sub color { } sub make_table { - my ($lowest_division, $used_ratings) = @_; + my ($lowest_division, $used_ratings, $used_cov) = @_; print <<"EOF"; @@ -58,11 +60,20 @@ EOF printf MCCALC "%d\n", scalar keys %players; for my $id (keys %players) { - if (exists($used_ratings->{$id})) { - printf MCCALC "%s %f\n", $id, $used_ratings->{$id}; - } else { - printf MCCALC "%s %f\n", $id, 1500.0; + my $rating = $used_ratings->{$id} // 1500.0; + printf MCCALC "%s %f\n", $id, $rating; + } + + # covariance matrix + for my $id1 (keys %players) { + for my $id2 (keys %players) { + if ($id1 == $id2) { + printf MCCALC "%f ", ($used_cov->{$id1}{$id2} // $parms{-3}); + } else { + printf MCCALC "%f ", ($used_cov->{$id1}{$id2} // 0.0); + } } + printf MCCALC "\n"; } for my $match (@matches) { @@ -80,7 +91,7 @@ EOF chomp; my @x = split /\s+/; my $id = $x[0]; - my $player = sprintf "%s (%.0f)", $players{$id}, $ratings{$id}; + my $player = sprintf "%s (%.0f ± %.0f)", $players{$id}, ($ratings{$id} // 1500.0), ($ratings_stddev{$id} // $parms{-3}); $prob{$player} = [ @x[1..$#x] ]; } close MCCALC; @@ -147,7 +158,11 @@ POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8'); print $cgi->header(-type=>'text/html; charset=utf-8', -expires=>'now'); printf <<"EOF", $match_stddev; - + + +
Under er en variant som tar relativ spillestyrke med i beregningen; se ratingsiden.
EOF -make_table($lowest_division, \%ratings); +make_table($lowest_division, \%ratings, $cov); -print << "EOF"; - +print <<"EOF"; EOF