summaryrefslogtreecommitdiff
path: root/dartbot.c
diff options
context:
space:
mode:
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;
}