diff options
| -rw-r--r-- | TODO.txt | 4 | ||||
| -rw-r--r-- | cube.c | 39 |
2 files changed, 39 insertions, 4 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | TODO optimize cocsep generation (very slow!) | 1 | TODO optimize cocsep generation (very slow!) |
| 2 | TODO cocsep data: fix | 2 | TODO check which is faster: foreach_move or simple for loop? |
| 3 | TODO cocsep data: add hash checks? | 3 | same for transformations |
| 4 | TODO implement big pruning table for H48 solver | 4 | TODO implement big pruning table for H48 solver |
| 5 | TODO alternative: ARM NEON part | 5 | TODO alternative: ARM NEON part |
| 6 | 6 | ||
| @@ -1075,6 +1075,30 @@ previous sections, while some other operate directly on the cube. | |||
| 1075 | invertco_fast(compose_fast(compose_fast(_trans_cube_ ## T, c), \ | 1075 | invertco_fast(compose_fast(compose_fast(_trans_cube_ ## T, c), \ |
| 1076 | _trans_cube_ ## T ## _inverse)) | 1076 | _trans_cube_ ## T ## _inverse)) |
| 1077 | 1077 | ||
| 1078 | #define _foreach_move(_m, _c, _d, instruction) \ | ||
| 1079 | _m = U; _d = _move(U, _c); instruction \ | ||
| 1080 | _m = U2; _d = _move(U2, _c); instruction \ | ||
| 1081 | _m = U3; _d = _move(U3, _c); instruction \ | ||
| 1082 | _m = D; _d = _move(D, _c); instruction \ | ||
| 1083 | _m = D2; _d = _move(D2, _c); instruction \ | ||
| 1084 | _m = D3; _d = _move(D3, _c); instruction \ | ||
| 1085 | _m = R; _d = _move(R, _c); instruction \ | ||
| 1086 | _m = R2; _d = _move(R2, _c); instruction \ | ||
| 1087 | _m = R3; _d = _move(R3, _c); instruction \ | ||
| 1088 | _m = L; _d = _move(L, _c); instruction \ | ||
| 1089 | _m = L2; _d = _move(L2, _c); instruction \ | ||
| 1090 | _m = L3; _d = _move(L3, _c); instruction \ | ||
| 1091 | _m = F; _d = _move(F, _c); instruction \ | ||
| 1092 | _m = F2; _d = _move(F2, _c); instruction \ | ||
| 1093 | _m = F3; _d = _move(F3, _c); instruction \ | ||
| 1094 | _m = B; _d = _move(B, _c); instruction \ | ||
| 1095 | _m = B2; _d = _move(B2, _c); instruction \ | ||
| 1096 | _m = B3; _d = _move(B3, _c); instruction | ||
| 1097 | /* | ||
| 1098 | #define _foreach_move(_m, _c, _d, instruction) \ | ||
| 1099 | for (_m = 0; _m < 18; _m++) { _d = move(_c, _m); instruction } | ||
| 1100 | */ | ||
| 1101 | |||
| 1078 | cube_t solvedcube(void); | 1102 | cube_t solvedcube(void); |
| 1079 | bool isconsistent(cube_t); | 1103 | bool isconsistent(cube_t); |
| 1080 | bool issolvable(cube_t); | 1104 | bool issolvable(cube_t); |
| @@ -1924,8 +1948,10 @@ dfs_cocsep( | |||
| 1924 | if (olddepth != depth) | 1948 | if (olddepth != depth) |
| 1925 | return 0; | 1949 | return 0; |
| 1926 | 1950 | ||
| 1927 | for (m = 0, cc = 0; m < 18; m++) | 1951 | cc = 0; |
| 1928 | cc += dfs_cocsep(move(c, m), depth+1, maxdepth, n, buf32); | 1952 | _foreach_move(m, c, d, |
| 1953 | cc += dfs_cocsep(d, depth+1, maxdepth, n, buf32); | ||
| 1954 | ) | ||
| 1929 | 1955 | ||
| 1930 | return cc; | 1956 | return cc; |
| 1931 | } | 1957 | } |
| @@ -2081,6 +2107,7 @@ solve_generic_dfs(dfsarg_generic_t arg) | |||
| 2081 | 2107 | ||
| 2082 | memcpy(&nextarg, &arg, sizeof(dfsarg_generic_t)); | 2108 | memcpy(&nextarg, &arg, sizeof(dfsarg_generic_t)); |
| 2083 | nextarg.nmoves = arg.nmoves + 1; | 2109 | nextarg.nmoves = arg.nmoves + 1; |
| 2110 | /* | ||
| 2084 | for (m = 0, ret = 0; m < 18; m++) { | 2111 | for (m = 0, ret = 0; m < 18; m++) { |
| 2085 | if (allowednextmove(arg.moves, arg.nmoves, m)) { | 2112 | if (allowednextmove(arg.moves, arg.nmoves, m)) { |
| 2086 | nextarg.cube = move(arg.cube, m); | 2113 | nextarg.cube = move(arg.cube, m); |
| @@ -2088,6 +2115,14 @@ solve_generic_dfs(dfsarg_generic_t arg) | |||
| 2088 | ret += solve_generic_dfs(nextarg); | 2115 | ret += solve_generic_dfs(nextarg); |
| 2089 | } | 2116 | } |
| 2090 | } | 2117 | } |
| 2118 | */ | ||
| 2119 | ret = 0; | ||
| 2120 | _foreach_move(m, arg.cube, nextarg.cube, | ||
| 2121 | if (allowednextmove(arg.moves, arg.nmoves, m)) { | ||
| 2122 | nextarg.moves[arg.nmoves] = m; | ||
| 2123 | ret += solve_generic_dfs(nextarg); | ||
| 2124 | } | ||
| 2125 | ) | ||
| 2091 | 2126 | ||
| 2092 | return ret; | 2127 | return ret; |
| 2093 | } | 2128 | } |
