summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-06-10 14:28:43 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-06-10 14:28:43 -0700
commitefe6b2e06ba24308f3875580b540783f5f16b0c0 (patch)
tree3b12a47ac9770a6395f374fc7b3edd75091e8166
parent2ebc14b69c7aab2457123c831fc51286cbc62de0 (diff)
downloaddartboat-test_95.tar.gz
dartboat-test_95.tar.xz
test 95% within radiustest_95
-rw-r--r--comp.c2
-rw-r--r--comp.h2
-rw-r--r--dartboat.c37
3 files changed, 38 insertions, 3 deletions
diff --git a/comp.c b/comp.c
index 3ce0c5e..46fb1ca 100644
--- a/comp.c
+++ b/comp.c
@@ -76,7 +76,7 @@ static struct ccoords gauss_offset()
.y = gauss(0, vertical_stdev) };
}
-static struct pcoords throw_dart(struct pcoords target, struct ccoords *cc)
+struct pcoords throw_dart(struct pcoords target, struct ccoords *cc)
{
struct ccoords tc = pol_to_cart(target);
struct ccoords offset = gauss_offset();
diff --git a/comp.h b/comp.h
index 009028f..cf53ffb 100644
--- a/comp.h
+++ b/comp.h
@@ -8,4 +8,6 @@ extern double horizontal_stdev, vertical_stdev;
void comp_set_difficulty(int diff);
void comp_visit(struct leg *l);
+struct pcoords throw_dart(struct pcoords target, struct ccoords *cc);
+
#endif
diff --git a/dartboat.c b/dartboat.c
index 952b5b7..dcd523d 100644
--- a/dartboat.c
+++ b/dartboat.c
@@ -157,16 +157,49 @@ void test_averages()
}
}
+int comp_95(const void *a, const void *b)
+{
+ if (*(double *)a > *(double *)b)
+ return 1;
+ if (*(double *)a < *(double *)b)
+ return -1;
+ return 0;
+}
+
+#define ROUNDS 1000000
+void test_95()
+{
+ for (int i = 8; i <= 88; i += 8) {
+ comp_set_difficulty(i);
+
+ struct ccoords cc;
+ struct pcoords target = {0, 0};
+
+ double dists[ROUNDS];
+ for (int i = 0; i < ROUNDS; ++i)
+ dists[i] = throw_dart(target, &cc).r;
+ qsort(dists, ROUNDS, sizeof(*dists), comp_95);
+
+ int index = (int)(ROUNDS * 0.95) - 1;
+
+ printf("%3d %5.2f %5.2f\n",
+ 10 * (i/8 + 1),
+ horizontal_stdev,
+ dists[index]);
+ }
+}
+
int main()
{
srand(time(NULL));
init_board();
//cvc_curses_match(501);
- pvc_curses_match(501);
+ //pvc_curses_match(501);
//pvp_curses_match(501);
- test_match(501);
+ //test_match(501);
//test_averages();
+ test_95();
return 0;
}