Revision 1958
Added more functionality to database for mapping things.
validTurns.c | ||
---|---|---|
7 | 7 |
* |
8 | 8 |
*/ |
9 | 9 |
|
10 |
|
|
11 |
/******************************Random Num Gen Version of validTurns*/ |
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
#define GET16(s)( ((s)&0x8000)>>16 ) /*gets the 16 bit*/ |
|
16 |
#define GET14(s)( ((s)&0x2000)>>14 ) /*gets the 14thbit*/ |
|
17 |
#define GET13(s)( ((s)&0x1000)>>13 ) /*you get the idea*/ |
|
18 |
#define GET11(s)( ((s)&0x400)>>11 ) |
|
19 |
#define CYCLES 10 /*the number of reseeds i perform before finally extracting my ranodm number*/ |
|
20 |
#define SHIFT(s)( (s)<<1) |
|
21 |
#define RESEED(s)( (s)=( ( ((GET16(s)^GET14(s))^GET13(s))^GET11(s) ) | SHIFT(s) ) )/*reseeding the first bit of the number with bits from the number*/ |
|
22 |
|
|
23 |
|
|
10 | 24 |
unsigned int seed = 0xC0FFEE; |
25 |
int randomNumGen(int max){ |
|
26 |
int a = 0; |
|
27 |
int b = 0xBEEF; |
|
28 |
seed++; |
|
29 |
return seed%4; |
|
30 |
} |
|
11 | 31 |
|
12 |
/******************************Random Num Gen Version of validTurns*/ |
|
13 | 32 |
/* |
14 | 33 |
int randomNumGen(int max){ |
15 | 34 |
return rtc_get() % max; |
Also available in: Unified diff