-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrick.c
50 lines (38 loc) · 1.36 KB
/
brick.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <brick.h>
#include <stats.h>
int main(void){
//Generate masks
gen_masks(n_singles, n_pairs, n_triples, n_tthirds,
&mask1, &mask2, &mask3, &mask32);
//Check to see we havent overcommitted the deck with bricks
if (mask1 > (1ULL << (sz_deck-1))){
printf("Too many bricks!\n");
exit(EXIT_SUCCESS);
}
//Initialize other variables
ll hand;
int i;
int ones = 0;
int twos = 0;
int threes = 0;
int tthirds = 0;
int any = 0;
time_t t;
srand((unsigned) time(&t)); //Initialize random numbers for gen_hands
//Loop over iterations
for(i=0;i<n_iter;i++){
//Generate a hand
hand = gen_hand(n_cards,sz_deck);
//Test if/how the hand bricked
test_brick(hand, mask1, mask2, mask3, mask32,
&ones, &twos, &threes, &tthirds, &any);
}
t = clock() - t;
printf("Brick Rate for Singles: %f %%\n",100.*ones/n_iter);
printf("Brick Rate for Pairs: %f %%\n",100.*twos/n_iter);
printf("Brick Rate for Triples: %f %%\n",100.*threes/n_iter);
printf("Brick Rate for Two/Triples: %f %%\n",100.*tthirds/n_iter);
printf("Overall Brick Rate: %f %%\n",100.*any/n_iter);
printf("Expected error: %f %%\n",100.*check_error(any,n_iter));
return 0;
}