diff options
Diffstat (limited to 'tools/stats_tables_h48')
| -rw-r--r-- | tools/stats_tables_h48/stats_tables_h48.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tools/stats_tables_h48/stats_tables_h48.c b/tools/stats_tables_h48/stats_tables_h48.c new file mode 100644 index 0000000..9f9bacf --- /dev/null +++ b/tools/stats_tables_h48/stats_tables_h48.c | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | #include <time.h> | ||
| 2 | #include "../timerun.h" | ||
| 3 | #include "../../src/cube.h" | ||
| 4 | |||
| 5 | #define MAXMOVES 20 | ||
| 6 | #define NCUBES 1000 | ||
| 7 | |||
| 8 | typedef struct { uint8_t n[16]; } i128; | ||
| 9 | |||
| 10 | char *buf; | ||
| 11 | |||
| 12 | i128 rand128(void) { | ||
| 13 | uint8_t i, j; | ||
| 14 | i128 ret = {0}; | ||
| 15 | |||
| 16 | for (i = 0; i < 16; i++) | ||
| 17 | for (j = 0; j < 8; j++) | ||
| 18 | ret.n[i] |= (uint8_t)(rand() % 2) << j; | ||
| 19 | |||
| 20 | return ret; | ||
| 21 | } | ||
| 22 | |||
| 23 | void output(int64_t v[13][100]) { | ||
| 24 | /* TODO: write to file and output only cocsepdata table stats */ | ||
| 25 | } | ||
| 26 | |||
| 27 | void run(void) { | ||
| 28 | uint32_t *h48info; | ||
| 29 | int i, j; | ||
| 30 | char sols[13], cube[22]; | ||
| 31 | int64_t s, v[13][100] = {0}; | ||
| 32 | |||
| 33 | s = nissy_gendata("H48stats", "", buf); | ||
| 34 | |||
| 35 | if (s == -1) { | ||
| 36 | printf("Error generating table\n"); | ||
| 37 | return; | ||
| 38 | } | ||
| 39 | |||
| 40 | for (i = 0; i < NCUBES; i++) { | ||
| 41 | nissy_gencube(rand128(), "", cube); | ||
| 42 | nissy_solve(cube, "H48stats", | ||
| 43 | "", "", "", 0, MAXMOVES, 1, -1, buf, sols); | ||
| 44 | for (j = 0; j < 13; j++) | ||
| 45 | v[j][(int)sols[j]]++; | ||
| 46 | } | ||
| 47 | |||
| 48 | output(v); | ||
| 49 | } | ||
| 50 | |||
| 51 | int main() { | ||
| 52 | int64_t size; | ||
| 53 | |||
| 54 | srand(time(NULL)); | ||
| 55 | |||
| 56 | size = nissy_datasize("H48", OPTIONS); | ||
| 57 | if (size == -1) { | ||
| 58 | printf("h48 stats: error in datasize\n"); | ||
| 59 | return 1; | ||
| 60 | } | ||
| 61 | |||
| 62 | buf = malloc(size); | ||
| 63 | |||
| 64 | timerun(run, "h48 table stats"); | ||
| 65 | |||
| 66 | free(buf); | ||
| 67 | |||
| 68 | return 0; | ||
| 69 | } | ||
