summaryrefslogtreecommitdiff
path: root/dartbot.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-20 06:00:00 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-20 06:00:00 -0700
commit36b74c04154cdecba1f999f5b358874502755cd0 (patch)
tree21bac2ca5dc251e18ec3b2e9a878bb110ecb8b6e /dartbot.c
parent6d399b63a4d0f29169c06e119fc56fce465c4a55 (diff)
downloaddartboat-36b74c04154cdecba1f999f5b358874502755cd0.tar.gz
dartboat-36b74c04154cdecba1f999f5b358874502755cd0.tar.xz
add function to test three-dart averages
Diffstat (limited to 'dartbot.c')
-rw-r--r--dartbot.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/dartbot.c b/dartbot.c
index 314548f..03b4ec5 100644
--- a/dartbot.c
+++ b/dartbot.c
@@ -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;
}