aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/301_solve_file/solve_file.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/301_solve_file/solve_file.c b/tools/301_solve_file/solve_file.c
index be4d1f5..5976dc0 100644
--- a/tools/301_solve_file/solve_file.c
+++ b/tools/301_solve_file/solve_file.c
@@ -8,9 +8,11 @@ char *solver;
8int64_t size = 0, N = 0; 8int64_t size = 0, N = 0;
9unsigned char *buf; 9unsigned char *buf;
10char scrambles[MAX_SCR][MAX_SCR_LEN]; 10char scrambles[MAX_SCR][MAX_SCR_LEN];
11unsigned nsols = 1;
12unsigned optimal = 0;
11 13
12void run(void) { 14void run(void) {
13 int64_t i, nsols; 15 int64_t i, solsfound;
14 long long stats[NISSY_SIZE_SOLVE_STATS]; 16 long long stats[NISSY_SIZE_SOLVE_STATS];
15 char sol[SOL_BUFFER_LEN], cube[NISSY_SIZE_CUBE]; 17 char sol[SOL_BUFFER_LEN], cube[NISSY_SIZE_CUBE];
16 18
@@ -19,14 +21,14 @@ void run(void) {
19 printf("%" PRId64 ". %s\n", i+1, scrambles[i]); 21 printf("%" PRId64 ". %s\n", i+1, scrambles[i]);
20 printf("Solving scramble %s\n", scrambles[i]); 22 printf("Solving scramble %s\n", scrambles[i]);
21 if (nissy_applymoves(NISSY_SOLVED_CUBE, scrambles[i], cube) 23 if (nissy_applymoves(NISSY_SOLVED_CUBE, scrambles[i], cube)
22 == -1) { 24 != NISSY_OK) {
23 printf("Invalid scramble\n"); 25 printf("Invalid scramble\n");
24 continue; 26 continue;
25 } 27 }
26 nsols = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL, 28 solsfound = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL,
27 0, 20, 1, -1, 0, size, buf, SOL_BUFFER_LEN, sol, stats, 29 0, 20, nsols, optimal, 0, size, buf, SOL_BUFFER_LEN,
28 NULL, NULL); 30 sol, stats, NULL, NULL);
29 if (nsols == 0) 31 if (solsfound == 0)
30 printf("No solution found\n"); 32 printf("No solution found\n");
31 else 33 else
32 printf("Solutions:\n%s\n", sol); 34 printf("Solutions:\n%s\n", sol);
@@ -39,12 +41,19 @@ int main(int argc, char **argv) {
39 41
40 if (argc < 3) { 42 if (argc < 3) {
41 printf("Error: not enough arguments. " 43 printf("Error: not enough arguments. "
42 "A solver and a scramble file must be given.\n"); 44 "A solver and a scramble file must be given.\n"
45 "Optionally, a maximum number of solutions per scramble "
46 "and a bound for the number of moves above the shortest "
47 "solution can be provided.\n");
43 return 1; 48 return 1;
44 } 49 }
45 50
46 solver = argv[1]; 51 solver = argv[1];
47 scrfilename = argv[2]; 52 scrfilename = argv[2];
53 if (argc >= 5) {
54 nsols = atoi(argv[3]);
55 optimal = atoi(argv[4]);
56 }
48 57
49 srand(time(NULL)); 58 srand(time(NULL));
50 nissy_setlogger(log_stderr, NULL); 59 nissy_setlogger(log_stderr, NULL);

Generated with cgit - Back to sebastiano.tronto.net