aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO_COORDINATES15
-rw-r--r--shell/shell.c28
-rw-r--r--src/nissy.c21
-rw-r--r--src/nissy.h4
-rw-r--r--src/solvers/coord/common.h (renamed from src/solvers/coord/coord_common.h)0
-rw-r--r--src/solvers/coord/coord.h4
-rw-r--r--src/solvers/coord/gendata.h30
-rw-r--r--src/solvers/coord/solve.h69
-rw-r--r--src/solvers/coord/types_macros.h (renamed from src/solvers/coord/coord_types_macros.h)0
-rw-r--r--src/solvers/h48/solve.h7
-rw-r--r--test/120_gendata_eo/gendata_eo_tests.c4
-rw-r--r--test/test.h2
12 files changed, 131 insertions, 53 deletions
diff --git a/TODO_COORDINATES b/TODO_COORDINATES
index 8d75ed6..6634623 100644
--- a/TODO_COORDINATES
+++ b/TODO_COORDINATES
@@ -1,4 +1,16 @@
1- solver (from TODOs in appending solution) 1- coord solver
2 - add new parameter to solve(): options (char *)
3 - fix all usages
4 x tests
5 x shell
6 - tools
7 - python bindings
8 - document what to do when changing interface?
9 - where do I document which solvers take which parameters?
10 now that I am implementing more solvers I need an extra
11 document in doc/
12 - in nissy.c, check for minmoves, maxmoves and nissflag (must be in range)
13 - add a dispatcher in solvers.h?
2- test solver for EO 14- test solver for EO
3- add NISS (and add tests for NISS EO) 15- add NISS (and add tests for NISS EO)
4- make solve parallelized 16- make solve parallelized
@@ -7,3 +19,4 @@
7- make gendata parallelized 19- make gendata parallelized
8 20
9- refactor common parts of coord and h48 solvers 21- refactor common parts of coord and h48 solvers
22- move parse_h48 to h48 module?
diff --git a/shell/shell.c b/shell/shell.c
index 5a2d283..2853350 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -17,6 +17,7 @@
17#define FLAG_PERM "-perm" 17#define FLAG_PERM "-perm"
18#define FLAG_COMMAND "-command" 18#define FLAG_COMMAND "-command"
19#define FLAG_STR_CUBE "-cubestr" 19#define FLAG_STR_CUBE "-cubestr"
20#define FLAG_SOLVE_OPTS "-options"
20#define FLAG_FORMAT "-format" 21#define FLAG_FORMAT "-format"
21#define FLAG_FORMAT_IN "-fin" 22#define FLAG_FORMAT_IN "-fin"
22#define FLAG_FORMAT_OUT "-fout" 23#define FLAG_FORMAT_OUT "-fout"
@@ -44,6 +45,7 @@ typedef struct {
44 char cube_perm[22]; 45 char cube_perm[22];
45 char *str_command; 46 char *str_command;
46 char *str_cube; 47 char *str_cube;
48 char *str_options;
47 char *str_format; 49 char *str_format;
48 char *str_format_in; 50 char *str_format_in;
49 char *str_format_out; 51 char *str_format_out;
@@ -79,6 +81,7 @@ static bool set_cube(int, char **, args_t *);
79static bool set_cube_perm(int, char **, args_t *); 81static bool set_cube_perm(int, char **, args_t *);
80static bool set_str_command(int, char **, args_t *); 82static bool set_str_command(int, char **, args_t *);
81static bool set_str_cube(int, char **, args_t *); 83static bool set_str_cube(int, char **, args_t *);
84static bool set_str_options(int, char **, args_t *);
82static bool set_str_format(int, char **, args_t *); 85static bool set_str_format(int, char **, args_t *);
83static bool set_str_format_in(int, char **, args_t *); 86static bool set_str_format_in(int, char **, args_t *);
84static bool set_str_format_out(int, char **, args_t *); 87static bool set_str_format_out(int, char **, args_t *);
@@ -105,6 +108,7 @@ struct {
105 OPTION(FLAG_PERM, 1, set_cube_perm), 108 OPTION(FLAG_PERM, 1, set_cube_perm),
106 OPTION(FLAG_COMMAND, 1, set_str_command), 109 OPTION(FLAG_COMMAND, 1, set_str_command),
107 OPTION(FLAG_STR_CUBE, 1, set_str_cube), 110 OPTION(FLAG_STR_CUBE, 1, set_str_cube),
111 OPTION(FLAG_SOLVE_OPTS, 1, set_str_options),
108 OPTION(FLAG_FORMAT, 1, set_str_format), 112 OPTION(FLAG_FORMAT, 1, set_str_format),
109 OPTION(FLAG_FORMAT_IN, 1, set_str_format_in), 113 OPTION(FLAG_FORMAT_IN, 1, set_str_format_in),
110 OPTION(FLAG_FORMAT_OUT, 1, set_str_format_out), 114 OPTION(FLAG_FORMAT_OUT, 1, set_str_format_out),
@@ -197,6 +201,7 @@ struct {
197 "solve", 201 "solve",
198 "solve " FLAG_SOLVER " SOLVER" 202 "solve " FLAG_SOLVER " SOLVER"
199 "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] " 203 "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] "
204 "[" FLAG_SOLVE_OPTS " options] "
200 FLAG_CUBE " CUBE" 205 FLAG_CUBE " CUBE"
201 FLAG_THREADS " T", 206 FLAG_THREADS " T",
202 "Solve the given CUBE using SOLVER, " 207 "Solve the given CUBE using SOLVER, "
@@ -208,6 +213,7 @@ struct {
208 "solve_scramble", 213 "solve_scramble",
209 "solve_scramble " FLAG_SOLVER " SOLVER" 214 "solve_scramble " FLAG_SOLVER " SOLVER"
210 "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] " 215 "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] "
216 "[" FLAG_SOLVE_OPTS " options] "
211 FLAG_MOVES " MOVES", 217 FLAG_MOVES " MOVES",
212 "Solve the given SCRAMBLE using SOLVER, " 218 "Solve the given SCRAMBLE using SOLVER, "
213 "using at least n and at most N moves. " 219 "using at least n and at most N moves. "
@@ -473,15 +479,15 @@ solve_exec(args_t *args)
473 fclose(file); 479 fclose(file);
474 if (read != 1) { 480 if (read != 1) {
475 fprintf(stderr, "Error reading data from file: " 481 fprintf(stderr, "Error reading data from file: "
476 "fread() returned %zu instead of 1 when attempting to" 482 "fread() returned %zu instead of 1 when attempting to "
477 "read %" PRId64 " bytes from file %s\n", read, size, path); 483 "read %" PRId64 " bytes from file %s\n", read, size, path);
478 return -2; 484 goto solve_exec_error;
479 } 485 }
480 486
481 ret = nissy_solve( 487 ret = nissy_solve(
482 args->cube, args->str_solver, nissflag, args->minmoves, 488 args->cube, args->str_solver, args->str_options, nissflag,
483 args->maxmoves, args->maxsolutions, args->optimal, args->threads, 489 args->minmoves, args->maxmoves, args->maxsolutions, args->optimal,
484 size, buf, SOLUTIONS_BUFFER_SIZE, solutions, stats); 490 args->threads, size, buf, SOLUTIONS_BUFFER_SIZE, solutions, stats);
485 491
486 free(buf); 492 free(buf);
487 493
@@ -491,6 +497,10 @@ solve_exec(args_t *args)
491 printf("%s", solutions); 497 printf("%s", solutions);
492 498
493 return 0; 499 return 0;
500
501solve_exec_error:
502 free(buf);
503 return -2;
494} 504}
495 505
496static int64_t 506static int64_t
@@ -655,6 +665,14 @@ set_str_cube(int argc, char **argv, args_t *args)
655} 665}
656 666
657static bool 667static bool
668set_str_options(int argc, char **argv, args_t *args)
669{
670 args->str_options = argv[0];
671
672 return true;
673}
674
675static bool
658set_str_format(int argc, char **argv, args_t *args) 676set_str_format(int argc, char **argv, args_t *args)
659{ 677{
660 args->str_format = argv[0]; 678 args->str_format = argv[0];
diff --git a/src/nissy.c b/src/nissy.c
index ffda4b3..ed1d3f4 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -451,14 +451,16 @@ nissy_gendata_unsafe(
451 return NISSY_ERROR_DATA; 451 return NISSY_ERROR_DATA;
452 } 452 }
453 453
454 arg.buf_size = data_size;
455 arg.buf = data;
456 if (!strncmp(solver, "h48", 3)) { 454 if (!strncmp(solver, "h48", 3)) {
455 arg.buf_size = data_size;
456 arg.buf = data;
457 parse_ret = parse_h48_solver(solver, &arg.h, &arg.k); 457 parse_ret = parse_h48_solver(solver, &arg.h, &arg.k);
458 arg.maxdepth = 20; 458 arg.maxdepth = 20;
459 if (parse_ret != NISSY_OK) 459 if (parse_ret != NISSY_OK)
460 return parse_ret; 460 return parse_ret;
461 return gendata_h48(&arg); 461 return gendata_h48(&arg);
462 } else if (!strncmp(solver, "coord_", 6)) {
463 return gendata_coord_dispatch(solver+6, data);
462 } else { 464 } else {
463 LOG("gendata: unknown solver %s\n", solver); 465 LOG("gendata: unknown solver %s\n", solver);
464 return NISSY_ERROR_INVALID_SOLVER; 466 return NISSY_ERROR_INVALID_SOLVER;
@@ -501,6 +503,7 @@ long long
501nissy_solve( 503nissy_solve(
502 const char cube[static NISSY_SIZE_B32], 504 const char cube[static NISSY_SIZE_B32],
503 const char *solver, 505 const char *solver,
506 const char *options,
504 unsigned nissflag, 507 unsigned nissflag,
505 unsigned minmoves, 508 unsigned minmoves,
506 unsigned maxmoves, 509 unsigned maxmoves,
@@ -536,6 +539,8 @@ nissy_solve(
536 return NISSY_ERROR_UNSOLVABLE_CUBE; 539 return NISSY_ERROR_UNSOLVABLE_CUBE;
537 } 540 }
538 541
542/* TODO: checks for minmoves, maxmoves, nissflag */
543
539 if (maxsols == 0) { 544 if (maxsols == 0) {
540 LOG("solve: 'maxsols' is 0, returning no solution\n"); 545 LOG("solve: 'maxsols' is 0, returning no solution\n");
541 return 0; 546 return 0;
@@ -562,11 +567,15 @@ nissy_solve(
562 567
563 if (!strncmp(solver, "h48", 3)) { 568 if (!strncmp(solver, "h48", 3)) {
564 parse_ret = parse_h48_solver(solver, &h, &k); 569 parse_ret = parse_h48_solver(solver, &h, &k);
565 if (parse_ret == NISSY_OK) 570 if (parse_ret != NISSY_OK)
566 return solve_h48(c, minmoves, maxmoves, maxsols, opt,
567 t, data_size, data, sols_size, sols, stats);
568 else
569 return parse_ret; 571 return parse_ret;
572/* TODO give warning if options is not NULL or empty? */
573 return solve_h48(c, minmoves, maxmoves, maxsols,
574 opt, t, data_size, data, sols_size, sols, stats);
575 } else if (!strncmp(solver, "coord_", 6)) {
576 return solve_coord_dispatch(c, solver + 6, options, nissflag,
577 minmoves, maxmoves, maxsols, opt, t, data_size, data,
578 sols_size, sols);
570 } else { 579 } else {
571 LOG("solve: unknown solver '%s'\n", solver); 580 LOG("solve: unknown solver '%s'\n", solver);
572 return NISSY_ERROR_INVALID_SOLVER; 581 return NISSY_ERROR_INVALID_SOLVER;
diff --git a/src/nissy.h b/src/nissy.h
index 6c5a3e6..9c26292 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -257,6 +257,9 @@ Solve the given cube using the given solver and options.
257Parameters: 257Parameters:
258 cube - The cube to solver, in B32 format. 258 cube - The cube to solver, in B32 format.
259 solver - The name of the solver. 259 solver - The name of the solver.
260 options - Extra options for the solver. Some solver require additional
261 parameters, some do not. For example, a coordinate solver
262 may require an "axis" (UD, FB, RL) as a parameter.
260 nissflag - The flags for NISS (linear, inverse, mixed, or combinations). 263 nissflag - The flags for NISS (linear, inverse, mixed, or combinations).
261 minmoves - The minimum number of moves for a solution. 264 minmoves - The minimum number of moves for a solution.
262 maxmoves - The maximum number of moves for a solution. 265 maxmoves - The maximum number of moves for a solution.
@@ -290,6 +293,7 @@ long long
290nissy_solve( 293nissy_solve(
291 const char cube[static NISSY_SIZE_B32], 294 const char cube[static NISSY_SIZE_B32],
292 const char *solver, 295 const char *solver,
296 const char *options,
293 unsigned nissflag, 297 unsigned nissflag,
294 unsigned minmoves, 298 unsigned minmoves,
295 unsigned maxmoves, 299 unsigned maxmoves,
diff --git a/src/solvers/coord/coord_common.h b/src/solvers/coord/common.h
index d827665..d827665 100644
--- a/src/solvers/coord/coord_common.h
+++ b/src/solvers/coord/common.h
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h
index fc241cb..6ca68c5 100644
--- a/src/solvers/coord/coord.h
+++ b/src/solvers/coord/coord.h
@@ -1,5 +1,5 @@
1#include "coord_types_macros.h" 1#include "types_macros.h"
2#include "eo.h" 2#include "eo.h"
3#include "coord_common.h" 3#include "common.h"
4#include "gendata.h" 4#include "gendata.h"
5#include "solve.h" 5#include "solve.h"
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h
index 3d385e9..d366466 100644
--- a/src/solvers/coord/gendata.h
+++ b/src/solvers/coord/gendata.h
@@ -1,26 +1,26 @@
1STATIC size_t gendata_coordinate(const coord_t *, void *); 1STATIC size_t gendata_coord(const coord_t *, void *);
2STATIC size_t gendata_coordinate_name(const char *, void *); 2STATIC int64_t gendata_coord_dispatch(const char *, void *);
3STATIC tableinfo_t genptable_coordinate(const coord_t *, const void *, uint8_t *); 3STATIC tableinfo_t genptable_coord(const coord_t *, const void *, uint8_t *);
4STATIC uint8_t get_coord_pval(const coord_t *, const uint8_t *, uint64_t); 4STATIC uint8_t get_coord_pval(const coord_t *, const uint8_t *, uint64_t);
5STATIC void set_coord_pval(const coord_t *, uint8_t *, uint64_t, uint8_t); 5STATIC void set_coord_pval(const coord_t *, uint8_t *, uint64_t, uint8_t);
6 6
7STATIC size_t 7STATIC int64_t
8gendata_coordinate_name(const char *name, void *buf) 8gendata_coord_dispatch(const char *coordstr, void *buf)
9{ 9{
10 coord_t *coord; 10 coord_t *coord;
11 11
12 coord = parse_coord(name, strlen(name)); 12 coord = parse_coord(coordstr, strlen(coordstr));
13
13 if (coord == NULL) { 14 if (coord == NULL) {
14 LOG("Cannot generate data for coordinate '%s': not found\n", 15 LOG("Could not parse coordinate '%s'\n", coord);
15 name); 16 return NISSY_ERROR_INVALID_SOLVER;
16 return 0;
17 } 17 }
18 18
19 return gendata_coordinate(coord, buf); 19 return (int64_t)gendata_coord(coord, buf);
20} 20}
21 21
22STATIC size_t 22STATIC size_t
23gendata_coordinate(const coord_t *coord, void *buf) 23gendata_coord(const coord_t *coord, void *buf)
24{ 24{
25 uint64_t coord_dsize, tablesize, ninfo; 25 uint64_t coord_dsize, tablesize, ninfo;
26 void *pruningbuf, *coord_data; 26 void *pruningbuf, *coord_data;
@@ -33,7 +33,7 @@ gendata_coordinate(const coord_t *coord, void *buf)
33 tablesize = DIV_ROUND_UP(coord->max, 2); 33 tablesize = DIV_ROUND_UP(coord->max, 2);
34 34
35 if (buf == NULL) 35 if (buf == NULL)
36 goto gendata_coordinate_return_size; 36 goto gendata_coord_return_size;
37 37
38 if (ninfo == 2) { 38 if (ninfo == 2) {
39 coord_data_info = (tableinfo_t) { 39 coord_data_info = (tableinfo_t) {
@@ -62,15 +62,15 @@ gendata_coordinate(const coord_t *coord, void *buf)
62 } 62 }
63 63
64 table = ((uint8_t *)pruningbuf) + INFOSIZE; 64 table = ((uint8_t *)pruningbuf) + INFOSIZE;
65 pruning_info = genptable_coordinate(coord, coord_data, table); 65 pruning_info = genptable_coord(coord, coord_data, table);
66 writetableinfo(&pruning_info, INFOSIZE + tablesize, pruningbuf); 66 writetableinfo(&pruning_info, INFOSIZE + tablesize, pruningbuf);
67 67
68gendata_coordinate_return_size: 68gendata_coord_return_size:
69 return ninfo * INFOSIZE + coord_dsize + tablesize; 69 return ninfo * INFOSIZE + coord_dsize + tablesize;
70} 70}
71 71
72STATIC tableinfo_t 72STATIC tableinfo_t
73genptable_coordinate(const coord_t *coord, const void *data, uint8_t *table) 73genptable_coord(const coord_t *coord, const void *data, uint8_t *table)
74{ 74{
75 uint64_t tablesize, i, j, d, tot; 75 uint64_t tablesize, i, j, d, tot;
76 tableinfo_t info; 76 tableinfo_t info;
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h
index e954aac..190ac1f 100644
--- a/src/solvers/coord/solve.h
+++ b/src/solvers/coord/solve.h
@@ -20,8 +20,9 @@ typedef struct {
20 20
21STATIC int64_t solve_coord(cube_t, coord_t *, uint8_t, uint8_t, uint8_t, 21STATIC int64_t solve_coord(cube_t, coord_t *, uint8_t, uint8_t, uint8_t,
22 uint8_t, uint64_t, int, int, uint64_t, const void *, uint64_t, char *); 22 uint8_t, uint64_t, int, int, uint64_t, const void *, uint64_t, char *);
23STATIC int64_t solve_coord_dispatch(cube_t, const char *, uint8_t, uint8_t, 23STATIC int64_t solve_coord_dispatch(cube_t, const char *, const char *,
24 uint8_t, uint64_t, int, int, uint64_t, const void *, uint64_t, char *); 24 uint8_t, uint8_t, uint8_t, uint64_t, int, int, uint64_t, const void *,
25 uint64_t, char *);
25STATIC bool solve_coord_appendchar(char *, uint64_t, uint64_t *, char); 26STATIC bool solve_coord_appendchar(char *, uint64_t, uint64_t *, char);
26STATIC int64_t solve_coord_appendsolution(dfsarg_solve_coord_t *); 27STATIC int64_t solve_coord_appendsolution(dfsarg_solve_coord_t *);
27STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t *); 28STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t *);
@@ -29,7 +30,9 @@ STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t *);
29STATIC int64_t 30STATIC int64_t
30solve_coord_appendsolution(dfsarg_solve_coord_t *arg) 31solve_coord_appendsolution(dfsarg_solve_coord_t *arg)
31{ 32{
32 uint8_t i, t, tmoves[MAXLEN_COORDSOL]; 33 uint8_t i, t, l, tmoves[MAXLEN_COORDSOL];
34 char *m;
35 int64_t strl;
33 36
34 if (*arg->nsols >= arg->maxsolutions || 37 if (*arg->nsols >= arg->maxsolutions ||
35 arg->nmoves > *arg->shortest_sol + arg->optimal) 38 arg->nmoves > *arg->shortest_sol + arg->optimal)
@@ -41,9 +44,26 @@ solve_coord_appendsolution(dfsarg_solve_coord_t *arg)
41 for (i = 0; i < arg->nmoves; i++) 44 for (i = 0; i < arg->nmoves; i++)
42 tmoves[i] = transform_move(arg->moves[i], t); 45 tmoves[i] = transform_move(arg->moves[i], t);
43 46
44 /* TODO append tmoves[] */ 47 l = arg->solutions_size - *arg->solutions_used;
48 m = *arg->solutions + *arg->solutions_used;
49 strl = writemoves(tmoves, arg->nmoves, l, m);
50 if (strl < 0)
51 goto solve_coord_appendsolution_error;
52
53 *arg->solutions_used += MAX(0, strl-1);
54
55 if (!solve_coord_appendchar(
56 *arg->solutions, arg->solutions_size, arg->solutions_used, '\n'))
57 goto solve_coord_appendsolution_error;
58
59 (*arg->nsols)++;
60 *arg->shortest_sol = MIN(*arg->shortest_sol, arg->nmoves);
45 61
46 return 1; 62 return 1;
63
64solve_coord_appendsolution_error:
65 LOG("Could not append solution to buffer: size too small\n");
66 return NISSY_ERROR_BUFFER_SIZE;
47} 67}
48 68
49STATIC bool 69STATIC bool
@@ -61,8 +81,11 @@ solve_coord_appendchar(char *s, uint64_t s_size, uint64_t *s_used, char c)
61STATIC int64_t 81STATIC int64_t
62solve_coord_dfs(dfsarg_solve_coord_t *arg) 82solve_coord_dfs(dfsarg_solve_coord_t *arg)
63{ 83{
84 uint8_t m, pval;
85 uint32_t mm;
64 uint64_t coord; 86 uint64_t coord;
65 uint8_t pval; 87 int64_t n, ret;
88 cube_t backup_cube;
66 89
67 coord = arg->coord->coord(arg->cube, arg->coord_data); 90 coord = arg->coord->coord(arg->cube, arg->coord_data);
68 91
@@ -76,8 +99,23 @@ solve_coord_dfs(dfsarg_solve_coord_t *arg)
76 if (arg->nmoves + pval > arg->depth) 99 if (arg->nmoves + pval > arg->depth)
77 return 0; 100 return 0;
78 101
79 /* TODO recursive call */ 102 backup_cube = arg->cube;
80 /* Is allowednextmove available here? */ 103
104 ret = 0;
105 mm = allowednextmove_mask(arg->moves, arg->nmoves);
106 arg->nmoves++;
107 for (m = 0; m < 18; m++) {
108 if (!(mm & (1 << m)))
109 continue;
110
111 arg->moves[arg->nmoves-1] = m;
112 arg->cube = move(backup_cube, m);
113 n = solve_coord_dfs(arg);
114 if (n < 0)
115 return n;
116 ret += n;
117 }
118 arg->nmoves--;
81 119
82 return 0; 120 return 0;
83} 121}
@@ -85,7 +123,8 @@ solve_coord_dfs(dfsarg_solve_coord_t *arg)
85STATIC int64_t 123STATIC int64_t
86solve_coord_dispatch( 124solve_coord_dispatch(
87 cube_t cube, 125 cube_t cube,
88 const char *coord_axis, 126 const char *coordstr,
127 const char *options,
89 uint8_t nissflag, 128 uint8_t nissflag,
90 uint8_t minmoves, 129 uint8_t minmoves,
91 uint8_t maxmoves, 130 uint8_t maxmoves,
@@ -98,23 +137,19 @@ solve_coord_dispatch(
98 char *sols 137 char *sols
99) 138)
100{ 139{
101 int i, n;
102 coord_t *coord; 140 coord_t *coord;
103 uint8_t axis; 141 uint8_t axis;
104 142
105 n = strlen(coord_axis); 143 coord = parse_coord(coordstr, strlen(coordstr));
106 for (i = 0; coord_axis[i] != ' ' && coord_axis[i] != '\0'; i++) ; 144 axis = parse_axis(options, strlen(options));
107
108 coord = parse_coord(coord_axis, i);
109 axis = parse_axis(coord_axis + i + 1, n - i - 1);
110 145
111 if (coord == NULL) { 146 if (coord == NULL) {
112 LOG("Could not parse coordinate '%s'\n", coord_axis); 147 LOG("Could not parse coordinate '%s'\n", coordstr);
113 return NISSY_ERROR_INVALID_SOLVER; 148 return NISSY_ERROR_INVALID_SOLVER;
114 } 149 }
115 150
116 if (axis == UINT8_ERROR) { 151 if (axis == UINT8_ERROR) {
117 LOG("Could not parse axis from '%s'\n", coord_axis); 152 LOG("Could not parse axis from options '%s'\n", options);
118 return NISSY_ERROR_INVALID_SOLVER; 153 return NISSY_ERROR_INVALID_SOLVER;
119 } 154 }
120 155
@@ -165,8 +200,8 @@ solve_coord(
165 nsols = 0; 200 nsols = 0;
166 sols_used = 0; 201 sols_used = 0;
167 shortest_sol = MAXLEN_COORDSOL + 1; 202 shortest_sol = MAXLEN_COORDSOL + 1;
168 c = transform(cube, t);
169 t = coord->axistrans[axis]; 203 t = coord->axistrans[axis];
204 c = transform(cube, t);
170 205
171 arg = (dfsarg_solve_coord_t) { 206 arg = (dfsarg_solve_coord_t) {
172 .cube = c, 207 .cube = c,
diff --git a/src/solvers/coord/coord_types_macros.h b/src/solvers/coord/types_macros.h
index 594f594..594f594 100644
--- a/src/solvers/coord/coord_types_macros.h
+++ b/src/solvers/coord/types_macros.h
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index 44f6a89..182beee 100644
--- a/src/solvers/h48/solve.h
+++ b/src/solvers/h48/solve.h
@@ -145,8 +145,7 @@ solve_h48_appendallsym(dfsarg_solve_h48_t *arg)
145 goto solve_h48_appendallsym_error; 145 goto solve_h48_appendallsym_error;
146 146
147 (*arg->nsols)++; 147 (*arg->nsols)++;
148 *arg->shortest_sol = 148 *arg->shortest_sol = MIN(*arg->shortest_sol, n);
149 MIN(*arg->shortest_sol, arg->nmoves + arg->npremoves);
150 ret++; 149 ret++;
151 } 150 }
152 151
@@ -291,7 +290,7 @@ solve_h48_dfs(dfsarg_solve_h48_t *arg)
291 if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { 290 if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) {
292 arg->nmoves++; 291 arg->nmoves++;
293 for (m = 0; m < 18; m++) { 292 for (m = 0; m < 18; m++) {
294 if (!(mm_normal & (1 << m))) 293 if (!(mm_normal & (UINT32_C(1) << (uint32_t)m)))
295 continue; 294 continue;
296 arg->moves[arg->nmoves-1] = m; 295 arg->moves[arg->nmoves-1] = m;
297 arg->cube = move(backup_cube, m); 296 arg->cube = move(backup_cube, m);
@@ -308,7 +307,7 @@ solve_h48_dfs(dfsarg_solve_h48_t *arg)
308 } else { 307 } else {
309 arg->npremoves++; 308 arg->npremoves++;
310 for (m = 0; m < 18; m++) { 309 for (m = 0; m < 18; m++) {
311 if(!(mm_inverse & (1 << m))) 310 if(!(mm_inverse & (UINT32_C(1) << (uint32_t)m)))
312 continue; 311 continue;
313 arg->premoves[arg->npremoves-1] = m; 312 arg->premoves[arg->npremoves-1] = m;
314 arg->inverse = move(backup_inverse, m); 313 arg->inverse = move(backup_inverse, m);
diff --git a/test/120_gendata_eo/gendata_eo_tests.c b/test/120_gendata_eo/gendata_eo_tests.c
index 3a6ac07..46a0606 100644
--- a/test/120_gendata_eo/gendata_eo_tests.c
+++ b/test/120_gendata_eo/gendata_eo_tests.c
@@ -17,7 +17,7 @@ Pruning table values (from nissy):
17 17
18char buf[FULLSIZE]; 18char buf[FULLSIZE];
19 19
20size_t gendata_coordinate_name(const char *, void *); 20size_t gendata_coord_dispatch(const char *, void *);
21bool readtableinfo(uint64_t, const char *, tableinfo_t *); 21bool readtableinfo(uint64_t, const char *, tableinfo_t *);
22 22
23void run(void) { 23void run(void) {
@@ -25,7 +25,7 @@ void run(void) {
25 size_t result; 25 size_t result;
26 tableinfo_t info; 26 tableinfo_t info;
27 27
28 result = gendata_coordinate_name("EO", buf); 28 result = gendata_coord_dispatch("EO", buf);
29 if (readtableinfo(FULLSIZE, buf, &info) != NISSY_OK) { 29 if (readtableinfo(FULLSIZE, buf, &info) != NISSY_OK) {
30 printf("Error reading info from table\n"); 30 printf("Error reading info from table\n");
31 return; 31 return;
diff --git a/test/test.h b/test/test.h
index e144527..4b281e0 100644
--- a/test/test.h
+++ b/test/test.h
@@ -14,7 +14,7 @@
14#include "../src/solvers/h48/coordinate_macros.h" 14#include "../src/solvers/h48/coordinate_macros.h"
15#include "../src/solvers/h48/map_types_macros.h" 15#include "../src/solvers/h48/map_types_macros.h"
16#include "../src/solvers/h48/gendata_types_macros.h" 16#include "../src/solvers/h48/gendata_types_macros.h"
17#include "../src/solvers/coord/coord_types_macros.h" 17#include "../src/solvers/coord/types_macros.h"
18 18
19#define STRLENMAX 10000 19#define STRLENMAX 10000
20 20

Generated with cgit - Back to sebastiano.tronto.net