#define MAX_PLAYERS 16
-float match_variance = 70.0f * 70.0f;
+float match_stddev = 70.0f;
struct player {
int player_index;
int main(int argc, char **argv)
{
int trials = atoi(argv[1]);
- float match_stddev;
if (scanf("%f", &match_stddev) != 1) {
fprintf(stderr, "Could't read match stddev\n");
exit(1);
}
- match_variance = match_stddev * match_stddev;
-
int num_players;
if (scanf("%d", &num_players) != 1) {
fprintf(stderr, "Could't read number of players\n");
vector<string> players;
map<string, int> player_map;
float ratings[MAX_PLAYERS];
- float ratings_variance[MAX_PLAYERS];
+ float ratings_stddev[MAX_PLAYERS];
bool has_scores[MAX_PLAYERS][MAX_PLAYERS];
for (int pl1 = 0; pl1 < num_players; ++pl1) {
for (int pl2 = 0; pl2 < num_players; ++pl2) {
players.push_back(buf);
player_map[buf] = i;
ratings[i] = rating;
- ratings_variance[i] = rating_stddev * rating_stddev;
+ ratings_stddev[i] = rating_stddev;
}
for ( ;; ) {
}
for (int i = 0; i < trials; ++i) {
+ // draw true strength for all players
+ float drawn_ratings[MAX_PLAYERS];
+ for (int p = 0; p < num_players; ++p) {
+ drawn_ratings[p] = draw_gaussian(ratings[p], ratings_stddev[p]);
+ }
+
// draw the missing matches
for (int pl1 = 0; pl1 < num_players; ++pl1) {
for (int pl2 = pl1 + 1; pl2 < num_players; ++pl2) {
continue;
}
- float mu = ratings[pl1] - ratings[pl2];
- float stddev = sqrt(match_variance + ratings_variance[pl1] + ratings_variance[pl2]);
+ float mu = drawn_ratings[pl1] - drawn_ratings[pl2];
- int score = lrintf(draw_gaussian(mu, stddev));
+ int score = lrintf(draw_gaussian(mu, match_stddev));
scores[pl1][pl2] = score;
scores[pl2][pl1] = -score;
}