Newsgroup: it.hobby.scacchi
Titolo: programmino per calcolo della performance

Vi faccio dono :) di un programmino perl che ho scritto (e concepito)
per calcolare la performance a partire dalla percentuale di punti
realizzata in un torneo. Il programma stampa il valore che bisogna
aggiungere alla media elo degli avversari incontrati, per valori da 1%
a 99%.
-------------------------------- INIZIO
----------------------------------
use strict;
main(@ARGV);
sub log10 {
    my $n = shift;
    return log($n)/log(10);
}
sub main {
    my ($perc, $diff);
    for $perc(1..99) {
        $diff = -400 * log10((1 - $perc/100)/($perc/100));
        $diff = int($diff + 0.5);
        print "$perc% -> $diff\n";
    }
}
-------------------------------- FINE
----------------------------------
1%      -> -797
2%      -> -675
3%      -> -603
4%      -> -551
5%      -> -511
6%      -> -477
7%      -> -448
8%      -> -423
9%      -> -401
10%     -> -381
11%     -> -362
12%     -> -345
13%     -> -329
14%     -> -314
15%     -> -300
16%     -> -287
17%     -> -274
18%     -> -262
19%     -> -251
20%     -> -240
21%     -> -229
22%     -> -219
23%     -> -209
24%     -> -199
25%     -> -190
26%     -> -181
27%     -> -172
28%     -> -163
29%     -> -155
30%     -> -146
31%     -> -138
32%     -> -130
33%     -> -122
34%     -> -114
35%     -> -107
36%     -> -99
37%     -> -91
38%     -> -84
39%     -> -77
40%     -> -69
41%     -> -62
42%     -> -55
43%     -> -48
44%     -> -41
45%     -> -34
46%     -> -27
47%     -> -20
48%     -> -13
49%     -> -6
50%     -> 0
51%     -> 7
52%     -> 14
53%     -> 21
54%     -> 28
55%     -> 35
56%     -> 42
57%     -> 49
58%     -> 56
59%     -> 63
60%     -> 70
61%     -> 78
62%     -> 85
63%     -> 92
64%     -> 100
65%     -> 108
66%     -> 115
67%     -> 123
68%     -> 131
69%     -> 139
70%     -> 147
71%     -> 156
72%     -> 164
73%     -> 173
74%     -> 182
75%     -> 191
76%     -> 200
77%     -> 210
78%     -> 220
79%     -> 230
80%     -> 241
81%     -> 252
82%     -> 263
83%     -> 275
84%     -> 288
85%     -> 301
86%     -> 315
87%     -> 330
88%     -> 346
89%     -> 363
90%     -> 382
91%     -> 402
92%     -> 424
93%     -> 449
94%     -> 478
95%     -> 512
96%     -> 552
97%     -> 604
98%     -> 676
99%     -> 798
Ad esempio, se si ha realizzato 3 punti su 4 (75%) contro avversari con
media 2000, si performa 2000 + 191.
Sperando di aver fatto cosa gradita,
J.

Piccola correzione nell'arrotondamento :
use strict;
main(@ARGV);
sub log10 {
    my $n = shift;
    return log($n)/log(10);
}
sub main {
    my ($perc, $diff);
    for $perc(1..99) {
        $diff = -400 * log10((1 - $perc/100)/($perc/100));
        if ($diff > 0) {
            $diff = int($diff + 0.5);
        }
        else {
            $diff = int($diff - 0.5);
        }
        print "$perc%   -> $diff\n";
    }
}
1%      -> -798
2%      -> -676
3%      -> -604
4%      -> -552
5%      -> -512
6%      -> -478
7%      -> -449
8%      -> -424
9%      -> -402
10%     -> -382
11%     -> -363
12%     -> -346
13%     -> -330
14%     -> -315
15%     -> -301
16%     -> -288
17%     -> -275
18%     -> -263
19%     -> -252
20%     -> -241
21%     -> -230
22%     -> -220
23%     -> -210
24%     -> -200
25%     -> -191
26%     -> -182
27%     -> -173
28%     -> -164
29%     -> -156
30%     -> -147
31%     -> -139
32%     -> -131
33%     -> -123
34%     -> -115
35%     -> -108
36%     -> -100
37%     -> -92
38%     -> -85
39%     -> -78
40%     -> -70
41%     -> -63
42%     -> -56
43%     -> -49
44%     -> -42
45%     -> -35
46%     -> -28
47%     -> -21
48%     -> -14
49%     -> -7

J.

Una variante :
------------- INIZIO ------------------
use strict;
main(@ARGV);
sub log10 {
    my $n = shift;
    return log($n)/log(10);
}
sub main {
    my ($turni, $diff, $punti, $perc);
    for $turni(3..12) {
        print "TURNI = $turni\n";
        for ($punti = 0.5; $punti <= $turni-0.5; $punti += 0.5) {
            $perc = $punti/$turni;
            $diff = -400 * log10((1 - $perc)/($perc));
            if ($diff > 0) {
                $diff = int($diff + 0.5);
            }
            else {
                $diff = int($diff - 0.5);
            }
            print "$punti/$turni                -> $diff\n";
        }
        print "\n";
    }
}
------------- FINE ------------------
TURNI = 3
0.5/3           -> -280
1/3             -> -120
1.5/3           -> 0
2/3             -> 120
2.5/3           -> 280
TURNI = 4
0.5/4           -> -338
1/4             -> -191
1.5/4           -> -89
2/4             -> 0
2.5/4           -> 89
3/4             -> 191
3.5/4           -> 338
TURNI = 5
0.5/5           -> -382
1/5             -> -241
1.5/5           -> -147
2/5             -> -70
2.5/5           -> 0
3/5             -> 70
3.5/5           -> 147
4/5             -> 241
4.5/5           -> 382
TURNI = 6
0.5/6           -> -417
1/6             -> -280
1.5/6           -> -191
2/6             -> -120
2.5/6           -> -58
3/6             -> 0
3.5/6           -> 58
4/6             -> 120
4.5/6           -> 191
5/6             -> 280
5.5/6           -> 417
TURNI = 7
0.5/7           -> -446
1/7             -> -311
1.5/7           -> -226
2/7             -> -159
2.5/7           -> -102
3/7             -> -50
3.5/7           -> 0
4/7             -> 50
4.5/7           -> 102
5/7             -> 159
5.5/7           -> 226
6/7             -> 311
6.5/7           -> 446
TURNI = 8
0.5/8           -> -470
1/8             -> -338
1.5/8           -> -255
2/8             -> -191
2.5/8           -> -137
3/8             -> -89
3.5/8           -> -44
4/8             -> 0
4.5/8           -> 44
5/8             -> 89
5.5/8           -> 137
6/8             -> 191
6.5/8           -> 255
7/8             -> 338
7.5/8           -> 470
TURNI = 9
0.5/9           -> -492
1/9             -> -361
1.5/9           -> -280
2/9             -> -218
2.5/9           -> -166
3/9             -> -120
3.5/9           -> -79
4/9             -> -39
4.5/9           -> 0
5/9             -> 39
5.5/9           -> 79
6/9             -> 120
6.5/9           -> 166
7/9             -> 218
7.5/9           -> 280
8/9             -> 361
8.5/9           -> 492
TURNI = 10
0.5/10          -> -512
1/10            -> -382
1.5/10          -> -301
2/10            -> -241
2.5/10          -> -191
3/10            -> -147
3.5/10          -> -108
4/10            -> -70
4.5/10          -> -35
5/10            -> 0
5.5/10          -> 35
6/10            -> 70
6.5/10          -> 108
7/10            -> 147
7.5/10          -> 191
8/10            -> 241
8.5/10          -> 301
9/10            -> 382
9.5/10          -> 512
TURNI = 11
0.5/11          -> -529
1/11            -> -400
1.5/11          -> -321
2/11            -> -261
2.5/11          -> -213
3/11            -> -170
3.5/11          -> -132
4/11            -> -97
4.5/11          -> -64
5/11            -> -32
5.5/11          -> 0
6/11            -> 32
6.5/11          -> 64
7/11            -> 97
7.5/11          -> 132
8/11            -> 170
8.5/11          -> 213
9/11            -> 261
9.5/11          -> 321
10/11           -> 400
10.5/11         -> 529
TURNI = 12
0.5/12          -> -545
1/12            -> -417
1.5/12          -> -338
2/12            -> -280
2.5/12          -> -232
3/12            -> -191
3.5/12          -> -154
4/12            -> -120
4.5/12          -> -89
5/12            -> -58
5.5/12          -> -29
6/12            -> 0
6.5/12          -> 29
7/12            -> 58
7.5/12          -> 89
8/12            -> 120
8.5/12          -> 154
9/12            -> 191
9.5/12          -> 232
10/12           -> 280
10.5/12         -> 338
11/12           -> 417
11.5/12         -> 545
J.