-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
74 lines (67 loc) · 1.7 KB
/
test.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
void generate_full_hand(int ran)
{
//int ran = (rand() % 52) + 4;
uint64_t card = (1LL << ran);
uint64_t card2 = (1LL << ran);
printf("%d | %llu | %llu\n", ran, card, card2);
}
uint64_t generate_hand()
{
uint64_t ret = 0;
int cards_added = 0;
while(cards_added < 7)
{
int r = (rand() % 52) + 4;
uint64_t card = (1LL << r); //generate random number from 0 to 51, then add four (since we add low aces manually)
printf("rand: %d\n", r);
printf("card: %llu\n", card);
printf("what card should be: %llu\n", (uint64_t)(1LL << r));
if(!(ret & card))
{
ret += card;
if(card > (1LL << 51)) //if its a high ace
{
ret += (card >> 52); //add the low ace marker as well
}
cards_added++;
}
};
return ret;
}
uint16_t generate_straight_hand(uint64_t full_hand)
{
uint16_t ret = 0;
uint64_t indicator = 15LL; //2^0 + 2^1 + 2^2 + 2^3
for(int i = 1; i < 14; i++)
{
if((full_hand >> (4*i)) & indicator)
{
ret += (1 << i);
}
}
return ret;
}
int main()
{
for(int i = 0; i < 64; i++)
{
generate_hand();
}
/*uint64_t fh_1 = generate_hand();
uint16_t sh_1 = generate_straight_hand(fh_1);
uint64_t fh_2 = generate_hand();
uint16_t sh_2 = generate_straight_hand(fh_2);
printf("%lu | %d\n", fh_1, sh_1);
printf("%lu | %d\n", fh_2, sh_2);
clock_t total_time = 0.0;
for(int i = 0; i < 100000; i++)
{
clock_t start_time = clock(), diff;
total_time += (clock() - start_time);
}*/
return 0;
}