diff options
| -rw-r--r-- | src/solvers/h48/solve.h | 3 | ||||
| -rw-r--r-- | src/solvers/h48/thread.h | 21 | ||||
| -rw-r--r-- | tools/200_solve_small/solve_small.c | 2 |
3 files changed, 16 insertions, 10 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index b67aedc..4a1e961 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -199,6 +199,7 @@ solve_h48( | |||
| 199 | arg.npremoves = 0; | 199 | arg.npremoves = 0; |
| 200 | solve_h48_dfs(&arg); | 200 | solve_h48_dfs(&arg); |
| 201 | } | 201 | } |
| 202 | 202 | **arg.nextsol = '\0'; | |
| 203 | (*arg.nextsol)++; | ||
| 203 | return nsols; | 204 | return nsols; |
| 204 | } | 205 | } |
diff --git a/src/solvers/h48/thread.h b/src/solvers/h48/thread.h index d035b52..c76c9d6 100644 --- a/src/solvers/h48/thread.h +++ b/src/solvers/h48/thread.h | |||
| @@ -4,7 +4,8 @@ | |||
| 4 | #include <stdio.h> | 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
| 6 | 6 | ||
| 7 | #define MAX_QUEUE_SIZE 500 | 7 | #define MAX_QUEUE_SIZE 244 |
| 8 | #define BFS_DEPTH 2 | ||
| 8 | typedef struct | 9 | typedef struct |
| 9 | { | 10 | { |
| 10 | dfsarg_solveh48_t *tasks[MAX_QUEUE_SIZE]; | 11 | dfsarg_solveh48_t *tasks[MAX_QUEUE_SIZE]; |
| @@ -31,7 +32,7 @@ STATIC void | |||
| 31 | solve_h48_appendsolution_thread(dfsarg_solveh48_t *arg, task_queue_t *tq) | 32 | solve_h48_appendsolution_thread(dfsarg_solveh48_t *arg, task_queue_t *tq) |
| 32 | { | 33 | { |
| 33 | pthread_mutex_lock(&tq->mutex); | 34 | pthread_mutex_lock(&tq->mutex); |
| 34 | int strl; | 35 | int strl = 0; |
| 35 | uint8_t invertedpremoves[MAXLEN]; | 36 | uint8_t invertedpremoves[MAXLEN]; |
| 36 | char *solution = *arg->nextsol; | 37 | char *solution = *arg->nextsol; |
| 37 | 38 | ||
| @@ -168,7 +169,7 @@ solve_h48_bfs(dfsarg_solveh48_t *arg_zero, task_queue_t *tq) | |||
| 168 | nextarg.cube = move(arg.cube, m); | 169 | nextarg.cube = move(arg.cube, m); |
| 169 | nextarg.inverse = premove(arg.inverse, m); | 170 | nextarg.inverse = premove(arg.inverse, m); |
| 170 | 171 | ||
| 171 | if (nextarg.nmoves == 2){ | 172 | if (nextarg.nmoves == BFS_DEPTH){ |
| 172 | dfsarg_solveh48_t *task = malloc(sizeof(dfsarg_solveh48_t)); | 173 | dfsarg_solveh48_t *task = malloc(sizeof(dfsarg_solveh48_t)); |
| 173 | *task = nextarg; | 174 | *task = nextarg; |
| 174 | submit_task(tq, task); | 175 | submit_task(tq, task); |
| @@ -179,11 +180,11 @@ solve_h48_bfs(dfsarg_solveh48_t *arg_zero, task_queue_t *tq) | |||
| 179 | } | 180 | } |
| 180 | } | 181 | } |
| 181 | if (nodes_at_current_depth == 0){ | 182 | if (nodes_at_current_depth == 0){ |
| 182 | depth++; | ||
| 183 | nodes_at_current_depth = nodes_at_next_depth; | 183 | nodes_at_current_depth = nodes_at_next_depth; |
| 184 | nodes_at_next_depth = 0; | 184 | nodes_at_next_depth = 0; |
| 185 | LOG("Found %" PRId64 " solutions, searching at depth %" PRId8 "\n", *nextarg.nsols, depth++); | ||
| 185 | } | 186 | } |
| 186 | if (depth == 2) return 0; | 187 | if (depth == BFS_DEPTH) return 0; |
| 187 | } | 188 | } |
| 188 | return 1; | 189 | return 1; |
| 189 | } | 190 | } |
| @@ -248,7 +249,7 @@ solve_h48_parent( | |||
| 248 | { | 249 | { |
| 249 | int64_t nsols = 0; | 250 | int64_t nsols = 0; |
| 250 | int p_depth = 0; | 251 | int p_depth = 0; |
| 251 | dfsarg_solveh48_t bfs_arg; | 252 | dfsarg_solveh48_t arg; |
| 252 | tableinfo_t info; | 253 | tableinfo_t info; |
| 253 | pthread_t threads[THREADS]; | 254 | pthread_t threads[THREADS]; |
| 254 | 255 | ||
| @@ -258,7 +259,7 @@ solve_h48_parent( | |||
| 258 | return 0; | 259 | return 0; |
| 259 | } | 260 | } |
| 260 | 261 | ||
| 261 | bfs_arg = (dfsarg_solveh48_t){ | 262 | arg = (dfsarg_solveh48_t){ |
| 262 | .cube = cube, | 263 | .cube = cube, |
| 263 | .inverse = inverse(cube), | 264 | .inverse = inverse(cube), |
| 264 | .nsols = &nsols, | 265 | .nsols = &nsols, |
| @@ -271,7 +272,7 @@ solve_h48_parent( | |||
| 271 | 272 | ||
| 272 | task_queue_t q; | 273 | task_queue_t q; |
| 273 | init_queue(&q); | 274 | init_queue(&q); |
| 274 | if (solve_h48_bfs(&bfs_arg, &q)) | 275 | if (solve_h48_bfs(&arg, &q)) |
| 275 | return nsols; | 276 | return nsols; |
| 276 | 277 | ||
| 277 | task_queue_t nq; | 278 | task_queue_t nq; |
| @@ -282,7 +283,7 @@ solve_h48_parent( | |||
| 282 | } | 283 | } |
| 283 | 284 | ||
| 284 | nsols = 0; | 285 | nsols = 0; |
| 285 | for (p_depth = minmoves > 2 ? minmoves : 2; | 286 | for (p_depth = minmoves > BFS_DEPTH ? minmoves : BFS_DEPTH; |
| 286 | p_depth <= maxmoves && nsols < maxsolutions; | 287 | p_depth <= maxmoves && nsols < maxsolutions; |
| 287 | p_depth++) | 288 | p_depth++) |
| 288 | { | 289 | { |
| @@ -301,5 +302,7 @@ solve_h48_parent( | |||
| 301 | for (int i = 0; i < THREADS; i++){ | 302 | for (int i = 0; i < THREADS; i++){ |
| 302 | pthread_join(threads[i], NULL); | 303 | pthread_join(threads[i], NULL); |
| 303 | } | 304 | } |
| 305 | **arg.nextsol = '\0'; | ||
| 306 | (*arg.nextsol)++; | ||
| 304 | return nsols; | 307 | return nsols; |
| 305 | } | 308 | } |
diff --git a/tools/200_solve_small/solve_small.c b/tools/200_solve_small/solve_small.c index 4d07728..ed71982 100644 --- a/tools/200_solve_small/solve_small.c +++ b/tools/200_solve_small/solve_small.c | |||
| @@ -10,6 +10,8 @@ char *buf; | |||
| 10 | char *scrambles[] = { | 10 | char *scrambles[] = { |
| 11 | "R D' R2 D R U2 R' D' R U2 R D R'", /* 12 optimal */ | 11 | "R D' R2 D R U2 R' D' R U2 R D R'", /* 12 optimal */ |
| 12 | "RLUD RLUD RLUD", /* 12 optimal */ | 12 | "RLUD RLUD RLUD", /* 12 optimal */ |
| 13 | "R' U' F D2 L2 F R2 U2 R2 B D2 L B2 D' B2 L' R' B D2 B U2 L U2 R' U' F", /* FMC2019 A1 - 16 optimal */ | ||
| 14 | // "R' U' F D R F2 D L F D2 F2 L' U R' L2 D' R2 F2 R2 D L2 U2 R' U' F", /* FMC2024 A1 - 19 optimal */ | ||
| 13 | NULL | 15 | NULL |
| 14 | }; | 16 | }; |
| 15 | 17 | ||
