diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/001_gendata_h48h0k4/gendata_h48h0k4.c | 22 | ||||
| -rw-r--r-- | tools/002_gendata_h48h0k2/gendata_h48h0k2.c | 21 | ||||
| -rw-r--r-- | tools/020_solve_small/solve_small.c | 16 | ||||
| -rwxr-xr-x | tools/run_tool.sh | 2 | ||||
| -rw-r--r-- | tools/tool.h | 10 |
5 files changed, 32 insertions, 39 deletions
diff --git a/tools/001_gendata_h48h0k4/gendata_h48h0k4.c b/tools/001_gendata_h48h0k4/gendata_h48h0k4.c index 0e3deb1..a9993b8 100644 --- a/tools/001_gendata_h48h0k4/gendata_h48h0k4.c +++ b/tools/001_gendata_h48h0k4/gendata_h48h0k4.c | |||
| @@ -27,8 +27,6 @@ uint32_t expected[21] = { | |||
| 27 | char *buf; | 27 | char *buf; |
| 28 | 28 | ||
| 29 | void run(void) { | 29 | void run(void) { |
| 30 | uint32_t *h48info, x; | ||
| 31 | int i; | ||
| 32 | int64_t s; | 30 | int64_t s; |
| 33 | 31 | ||
| 34 | s = nissy_gendata("h48", OPTIONS, buf); | 32 | s = nissy_gendata("h48", OPTIONS, buf); |
| @@ -36,20 +34,12 @@ void run(void) { | |||
| 36 | if (s == -1) { | 34 | if (s == -1) { |
| 37 | printf("Error generating table\n"); | 35 | printf("Error generating table\n"); |
| 38 | } else { | 36 | } else { |
| 39 | printf("Table is probably ok\n"); | 37 | nissy_datainfo(buf, write_stdout); |
| 40 | /* | 38 | printf("\n"); |
| 41 | TODO: adapt to new tables | 39 | printf("Succesfully generated %" PRId64 " bytes. " |
| 42 | printf("Succesfully generated %" PRId64 " bytes. Table:\n", s); | 40 | "See above for details on the tables.\n", s); |
| 43 | h48info = (uint32_t *)buf + 1 + (ETABLESIZE(HVALUE) + COCSEPSIZE) / 4; | 41 | |
| 44 | for (i = 0; i < MAXDEPTH+1 && h48info[i+1]; i++) { | 42 | /* TODO: check that the table is correct */ |
| 45 | x = h48info[i+1]; | ||
| 46 | printf("%d:\t%" PRIu32, i, x); | ||
| 47 | if (x != expected[i]) | ||
| 48 | printf(" <--- Error! Expected: %" PRIu32, | ||
| 49 | expected[i]); | ||
| 50 | printf("\n"); | ||
| 51 | } | ||
| 52 | */ | ||
| 53 | } | 43 | } |
| 54 | } | 44 | } |
| 55 | 45 | ||
diff --git a/tools/002_gendata_h48h0k2/gendata_h48h0k2.c b/tools/002_gendata_h48h0k2/gendata_h48h0k2.c index 2754f80..271d339 100644 --- a/tools/002_gendata_h48h0k2/gendata_h48h0k2.c +++ b/tools/002_gendata_h48h0k2/gendata_h48h0k2.c | |||
| @@ -5,9 +5,6 @@ | |||
| 5 | #define OPTIONS "0;2;20" | 5 | #define OPTIONS "0;2;20" |
| 6 | #define LONGOPTIONS "h = 0, k = 2, max depth = 20" | 6 | #define LONGOPTIONS "h = 0, k = 2, max depth = 20" |
| 7 | 7 | ||
| 8 | #define COCSEPSIZE 1119792 | ||
| 9 | #define ETABLESIZE(h) (((3393 * 495 * 70) >> 2) << (size_t)(h)) | ||
| 10 | |||
| 11 | uint32_t expected[21] = { | 8 | uint32_t expected[21] = { |
| 12 | /* Base value is 8 */ | 9 | /* Base value is 8 */ |
| 13 | [0] = 5473562, | 10 | [0] = 5473562, |
| @@ -19,8 +16,6 @@ uint32_t expected[21] = { | |||
| 19 | char *buf; | 16 | char *buf; |
| 20 | 17 | ||
| 21 | void run(void) { | 18 | void run(void) { |
| 22 | uint32_t *h48info, x; | ||
| 23 | int i; | ||
| 24 | int64_t s; | 19 | int64_t s; |
| 25 | 20 | ||
| 26 | s = nissy_gendata("h48", OPTIONS, buf); | 21 | s = nissy_gendata("h48", OPTIONS, buf); |
| @@ -28,16 +23,12 @@ void run(void) { | |||
| 28 | if (s == -1) { | 23 | if (s == -1) { |
| 29 | printf("Error generating table\n"); | 24 | printf("Error generating table\n"); |
| 30 | } else { | 25 | } else { |
| 31 | printf("Succesfully generated %" PRId64 " bytes. Table:\n", s); | 26 | nissy_datainfo(buf, write_stdout); |
| 32 | h48info = (uint32_t *)buf + 1 + (ETABLESIZE(HVALUE) + COCSEPSIZE) / 4; | 27 | printf("\n"); |
| 33 | for (i = 0; i < 4; i++) { | 28 | printf("Succesfully generated %" PRId64 " bytes. " |
| 34 | x = h48info[i+1]; | 29 | "See above for details on the tables.\n", s); |
| 35 | printf("%d:\t%" PRIu32, i, x); | 30 | |
| 36 | if (x != expected[i]) | 31 | /* TODO: check that the table is correct */ |
| 37 | printf(" <--- Error! Expected: %" PRIu32, | ||
| 38 | expected[i]); | ||
| 39 | printf("\n"); | ||
| 40 | } | ||
| 41 | } | 32 | } |
| 42 | } | 33 | } |
| 43 | 34 | ||
diff --git a/tools/020_solve_small/solve_small.c b/tools/020_solve_small/solve_small.c index dee2b55..4d07728 100644 --- a/tools/020_solve_small/solve_small.c +++ b/tools/020_solve_small/solve_small.c | |||
| @@ -20,20 +20,22 @@ void run(void) { | |||
| 20 | 20 | ||
| 21 | printf("Solved the following scrambles:\n\n"); | 21 | printf("Solved the following scrambles:\n\n"); |
| 22 | for (i = 0; scrambles[i] != NULL; i++) { | 22 | for (i = 0; scrambles[i] != NULL; i++) { |
| 23 | printf("%s\n", scrambles[i]); | 23 | printf("%d. %s\n", i+1, scrambles[i]); |
| 24 | fprintf(stderr, "Solving scramble %s\n", scrambles[i]); | 24 | fprintf(stderr, "Solving scramble %s\n", scrambles[i]); |
| 25 | if (nissy_frommoves(scrambles[i], cube) == -1) { | 25 | if (nissy_frommoves(scrambles[i], cube) == -1) { |
| 26 | fprintf(stderr, "Invalid scramble, " | 26 | fprintf(stderr, "Invalid scramble\n"); |
| 27 | "continuing with next scramble\n"); | 27 | printf("Invalid\n"); |
| 28 | continue; | 28 | continue; |
| 29 | } | 29 | } |
| 30 | n = nissy_solve( | 30 | n = nissy_solve( |
| 31 | cube, "h48", options, "", 0, 20, 1, -1, buf, sol); | 31 | cube, "h48", options, "", 0, 20, 1, -1, buf, sol); |
| 32 | if (n == 0) | 32 | if (n == 0) { |
| 33 | fprintf(stderr, "No solution found, " | 33 | printf("No solution\n"); |
| 34 | "continuing with next scramble\n"); | 34 | fprintf(stderr, "No solution found\n"); |
| 35 | } else { | ||
| 36 | printf("Solutions:\n%s\n", sol); | ||
| 37 | } | ||
| 35 | } | 38 | } |
| 36 | printf("\n"); | ||
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | int main(void) { | 41 | int main(void) { |
diff --git a/tools/run_tool.sh b/tools/run_tool.sh index 2462b2d..cec7630 100755 --- a/tools/run_tool.sh +++ b/tools/run_tool.sh | |||
| @@ -16,7 +16,7 @@ for t in tools/*; do | |||
| 16 | fi | 16 | fi |
| 17 | toolname="$(basename "$t" .c)" | 17 | toolname="$(basename "$t" .c)" |
| 18 | $CC -o $BIN $t/*.c $CUBEOBJ || exit 1; | 18 | $CC -o $BIN $t/*.c $CUBEOBJ || exit 1; |
| 19 | $BIN | tee "tools/results/$toolname-$d.txt" | 19 | $BIN | tee "tools/results/$toolname-$d.txt" "tools/results/last.out" |
| 20 | break | 20 | break |
| 21 | done | 21 | done |
| 22 | 22 | ||
diff --git a/tools/tool.h b/tools/tool.h index d75342d..7995621 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -18,6 +18,16 @@ log_stderr(const char *str, ...) | |||
| 18 | va_end(args); | 18 | va_end(args); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | static void | ||
| 22 | write_stdout(const char *str, ...) | ||
| 23 | { | ||
| 24 | va_list args; | ||
| 25 | |||
| 26 | va_start(args, str); | ||
| 27 | vfprintf(stdout, str, args); | ||
| 28 | va_end(args); | ||
| 29 | } | ||
| 30 | |||
| 21 | static double | 31 | static double |
| 22 | timerun(void (*run)(void), char *name) | 32 | timerun(void (*run)(void), char *name) |
| 23 | { | 33 | { |
