diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-20 06:00:00 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-20 06:00:00 -0700 |
commit | 36b74c04154cdecba1f999f5b358874502755cd0 (patch) | |
tree | 21bac2ca5dc251e18ec3b2e9a878bb110ecb8b6e /dartbot.c | |
parent | 6d399b63a4d0f29169c06e119fc56fce465c4a55 (diff) | |
download | dartboat-36b74c04154cdecba1f999f5b358874502755cd0.tar.gz dartboat-36b74c04154cdecba1f999f5b358874502755cd0.tar.xz |
add function to test three-dart averages
Diffstat (limited to 'dartbot.c')
-rw-r--r-- | dartbot.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -13,11 +13,11 @@ void test_match(int start_points) { struct leg *l = leg_init(start_points, NULL); - while(l->rem > 0) + while (l->rem > 0) comp_visit(l); printf("(%2d) %3d\n", 0, l->start); - for(int i = 0; i < l->n_visits; ++i) { + for (int i = 0; i < l->n_visits; ++i) { struct visit *v = l->visits + i; printf("(%2d) %3d %3d", i+1, v->points, v->rem); @@ -129,6 +129,27 @@ void pvp_curses_match(int start_points) curses_match(start_points, "David", user_visit, "Davidn't", user_visit); } +void test_averages() +{ + int rounds = 100000; + + for (int stdev = 4; stdev < 25; ++stdev) { + horizontal_stdev = vertical_stdev = stdev; + + int darts = 0; + for (int i = 0; i < rounds; ++i) { + struct leg *l = leg_init(501, NULL); + while (l->rem > 0) + comp_visit(l); + leg_free(l); + + darts += (l->n_visits-1)*3 + l->visits[l->n_visits-1].n_darts; + } + + printf("%d %f\n", stdev, (double)(501*rounds)/darts*3); + } +} + int main() { srand(time(NULL)); @@ -138,6 +159,7 @@ int main() pvc_curses_match(501); //pvp_curses_match(501); test_match(501); + //test_averages(); return 0; } |