X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Findex.pl;h=697470cdd75a6002c92ed6b2919bef3b15258007;hb=8964d30bbe836e9c0989208be582d3c7213eb574;hp=fd3228b7a3894676b1247e19024c9fe2350af079;hpb=ca05ac92ffa61529291368e179e3ae10c83b34b0;p=wloh diff --git a/www/index.pl b/www/index.pl index fd3228b..697470c 100755 --- a/www/index.pl +++ b/www/index.pl @@ -177,6 +177,10 @@ sub get_covariance_matrix { sub write_parms_to_file { my ($aux_parms, $match_stddev, $used_ratings, $used_cov) = @_; + POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8'); + + my @sorted_players = sort { $players{$a} cmp $players{$b} } keys %players; + POSIX::setlocale(&POSIX::LC_ALL, 'C'); my $tmpnam = POSIX::tmpnam(); @@ -186,7 +190,7 @@ sub write_parms_to_file { printf MCCALC "%f\n", $match_stddev; printf MCCALC "%d\n", scalar keys %players; - for my $id (keys %players) { + for my $id (@sorted_players) { my $rating = $used_ratings->{$id} // 500.0; printf MCCALC "%s %f\n", $id, $rating; } @@ -220,7 +224,18 @@ sub make_table { ++$num_tables; print <<"EOF"; - + @@ -267,7 +282,12 @@ EOF ($r, $b) = ($b, $r); } - printf " \n", $pn * 100.0; + my $num_total_games = ($num_games * ($num_games - 1)) / 2; + if (scalar @matches == $num_total_games || $prob{$player}->[$i - 1] == $trials) { + printf " \n", $pn * 100.0; + } else { + printf " \n", $pn * 100.0; + } } unless ($lowest_division) { @@ -370,10 +390,15 @@ if (defined($match_player) && defined($match_position)) { close MCCALC; #unlink $tmpnam; + my @sorted_players = sort { $players{$a} cmp $players{$b} } keys %players; + my $player_name = $players{$sorted_players[$match_player]}; + if (scalar @scenario == 0) { - # FIXME: distinguish between "all played" and "none found" - print "

Fant ingen måte dette kunne skje på.

\n"; + printf "

Fant ingen måte %s kan ende på %d. plass på.

\n", + $player_name, ($match_position + 1); } else { + printf "

Scenario der %s ender på %d. plass:

\n", + $player_name, ($match_position + 1); print "
%.1f%%%.1f%%%.1f%%