]> git.sesse.net Git - wloh/blobdiff - mcwordfeud.cpp
Submit the form automatically when needed.
[wloh] / mcwordfeud.cpp
index 7470af3feafcc760928b06cd724b5d03e4572299..c8d28a47b85bcf933374d49f1339378bcd4bee31 100644 (file)
@@ -14,6 +14,8 @@ using namespace std;
 
 #define MAX_PLAYERS 16
 
+float match_stddev = 70.0f;
+
 struct player {
        int player_index;
        int points, margin;
@@ -50,9 +52,9 @@ float draw_gaussian(float stddev)
 float draw_gaussian(float mu, float stddev)
 {
        static bool inited = false;
-       static long unsigned seed = 123456789;
-       int kn[128];
-       float fn[128], wn[128];
+       static long unsigned seed = time(NULL);
+       static int kn[128];
+       static float fn[128], wn[128];
        if (!inited) {
                r4_nor_setup(kn, fn, wn);
                inited = true;
@@ -66,6 +68,11 @@ int main(int argc, char **argv)
 {
        int trials = atoi(argv[1]);
 
+       if (scanf("%f", &match_stddev) != 1) {
+               fprintf(stderr, "Could't read match stddev\n");
+               exit(1);
+       }
+
        int num_players;
        if (scanf("%d", &num_players) != 1) {
                fprintf(stderr, "Could't read number of players\n");
@@ -145,7 +152,7 @@ int main(int argc, char **argv)
 
                                float mu = ratings[pl1] - ratings[pl2];
                                
-                               int score = lrintf(draw_gaussian(mu, 82.9f));
+                               int score = lrintf(draw_gaussian(mu, match_stddev));
                                scores[pl1][pl2] = score;
                                scores[pl2][pl1] = -score;
                        }