]> git.sesse.net Git - wloh/commitdiff
Properly handle the fact that score X-0 is different from X-(-X). Urg, bad bug.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Mar 2012 19:13:30 +0000 (21:13 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Mar 2012 19:13:30 +0000 (21:13 +0200)
mcwordfeud.cpp

index 3b55f01c88ee5dc4433d1322a8c49209dd884d14..049a2196b998b2c53d38c296733f1d243493e89a 100644 (file)
@@ -196,8 +196,13 @@ int main(int argc, char **argv)
                                float mu = drawn_ratings(pl1) - drawn_ratings(pl2);
                                
                                int score = lrintf(draw_gaussian(mu, match_stddev));
-                               scores[pl1][pl2] = score;
-                               scores[pl2][pl1] = -score;
+                               if (score >= 0) {
+                                       scores[pl1][pl2] = score;
+                                       scores[pl2][pl1] = 0;
+                               } else {
+                                       scores[pl1][pl2] = 0;
+                                       scores[pl2][pl1] = -score;
+                               }
                        }
                }
 
@@ -249,7 +254,7 @@ int main(int argc, char **argv)
                                                continue;
                                        }
                                        float mu = drawn_ratings(pl1) - drawn_ratings(pl2);
-                                       float z = (scores[pl1][pl2] - mu) / match_stddev;
+                                       float z = (scores[pl1][pl2] - scores[pl2][pl1] - mu) / match_stddev;
                                        llh -= z * z * 0.5f;
                                }
                        }
@@ -277,7 +282,7 @@ int main(int argc, char **argv)
                                if (has_scores[pl1][pl2]) {
                                        continue;
                                }
-                               printf("%s %s %d\n", players[pl1].c_str(), players[pl2].c_str(), mlm_scores[pl1][pl2]);
+                               printf("%s %s %d\n", players[pl1].c_str(), players[pl2].c_str(), mlm_scores[pl1][pl2] - mlm_scores[pl2][pl1]);
                        }
                }
        }