From a125e69c8ce0a2764b1e50b2dad0a4fa9d141ef4 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 6 Sep 2022 18:00:40 +0200 Subject: Symcoord version of nissy. Interesting idea, but performance are actually slower. AT THIS STAGE NISSY IS NOT USABLE. --- old/maybe-useful-coord.c | 181 ++++++++ old/maybe-useful-steps.c | 1111 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1292 insertions(+) create mode 100644 old/maybe-useful-coord.c create mode 100644 old/maybe-useful-steps.c (limited to 'old') diff --git a/old/maybe-useful-coord.c b/old/maybe-useful-coord.c new file mode 100644 index 0000000..9ab2971 --- /dev/null +++ b/old/maybe-useful-coord.c @@ -0,0 +1,181 @@ +int +array_ep_to_epos(int *ep, int *ss) +{ + int epos[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int eps[4]; + int i, j, is; + + for (i = 0, is = 0; i < 12; i++) { + for (j = 0; j < 4; j++) { + if (ep[i] == ss[j]) { + eps[is++] = j; + epos[i] = 1; + } + } + } + + for (i = 0; i < 4; i++) + swap(&epos[ss[i]], &epos[i+8]); + + return 24 * subset_to_index(epos, 12, 4) + perm_to_index(eps, 4); +} + +void +epos_to_compatible_ep(int epos, int *ep, int *ss) +{ + int i, j, k, other[8]; + bool flag; + + for (i = 0; i < 12; i++) + ep[i] = -1; + + epos_to_partial_ep(epos, ep, ss); + + for (i = 0, j = 0; i < 12; i++) { + flag = false; + for (k = 0; k < 4; k++) + flag = flag || (i == ss[k]); + if (!flag) + other[j++] = i; + } + + for (i = 0, j = 0; i < 12; i++) + if (ep[i] == -1) + ep[i] = other[j++]; +} + +void +epos_to_partial_ep(int epos, int *ep, int *ss) +{ + int i, is, eposs[12], eps[4]; + + index_to_perm(epos % FACTORIAL4, 4, eps); + index_to_subset(epos / FACTORIAL4, 12, 4, eposs); + + for (i = 0; i < 4; i++) + swap(&eposs[ss[i]], &eposs[i+8]); + + for (i = 0, is = 0; i < 12; i++) + if (eposs[i]) + ep[i] = ss[eps[is++]]; +} + +void +fix_eorleoud(CubeArray *arr) +{ + int i; + + for (i = 0; i < 12; i++) { + if ((edge_slice(i) == 0 && edge_slice(arr->ep[i]) != 0) || + (edge_slice(i) != 0 && edge_slice(arr->ep[i]) == 0)) { + arr->eorl[i] = 1 - arr->eofb[i]; + } else { + arr->eorl[i] = arr->eofb[i]; + } + + if ((edge_slice(i) == 2 && edge_slice(arr->ep[i]) != 2) || + (edge_slice(i) != 2 && edge_slice(arr->ep[i]) == 2)) { + arr->eoud[i] = 1 - arr->eofb[i]; + } else { + arr->eoud[i] = arr->eofb[i]; + } + } +} + +void +fix_cofbcorl(CubeArray *arr) +{ + int i; + + for (i = 0; i < 8; i++) { + if (i % 2 == arr->cp[i] % 2) { + arr->cofb[i] = arr->coud[i]; + arr->corl[i] = arr->coud[i]; + } else { + if (arr->cp[i] % 2 == 0) { + arr->cofb[i] = (arr->coud[i]+1)%3; + arr->corl[i] = (arr->coud[i]+2)%3; + } else { + arr->cofb[i] = (arr->coud[i]+2)%3; + arr->corl[i] = (arr->coud[i]+1)%3; + } + } + } +} + +Cube +admissible_ep(Cube cube, PieceFilter f) +{ + CubeArray *arr = new_cubearray(cube, f); + Cube ret; + bool used[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int i, j; + + for (i = 0; i < 12; i++) + if (arr->ep[i] != -1) + used[arr->ep[i]] = true; + + for (i = 0, j = 0; i < 12; i++) { + for ( ; j < 11 && used[j]; j++); + if (arr->ep[i] == -1) + arr->ep[i] = j++; + } + + ret = arrays_to_cube(arr, pf_ep); + free_cubearray(arr, f); + + return ret; +} + +int +edge_slice(Edge e) { + if (e < 0 || e > 11) + return -1; + + if (e == FR || e == FL || e == BL || e == BR) + return 0; + if (e == UR || e == UL || e == DR || e == DL) + return 1; + + return 2; +} + +int +piece_orientation(Cube cube, int piece, char *orientation) +{ + int arr[12], n, b, x; + + if (!strcmp(orientation, "eofb")) { + x = cube.eofb; + n = 12; + b = 2; + } else if (!strcmp(orientation, "eorl")) { + x = cube.eorl; + n = 12; + b = 2; + } else if (!strcmp(orientation, "eoud")) { + x = cube.eoud; + n = 12; + b = 2; + } else if (!strcmp(orientation, "coud")) { + x = cube.coud; + n = 8; + b = 3; + } else if (!strcmp(orientation, "corl")) { + x = cube.corl; + n = 8; + b = 3; + } else if (!strcmp(orientation, "cofb")) { + x = cube.cofb; + n = 8; + b = 3; + } else { + return -1; + } + + int_to_sum_zero_array(x, b, n, arr); + if (piece < n) + return arr[piece]; + + return -1; +} diff --git a/old/maybe-useful-steps.c b/old/maybe-useful-steps.c new file mode 100644 index 0000000..2a20dd9 --- /dev/null +++ b/old/maybe-useful-steps.c @@ -0,0 +1,1111 @@ +#include "steps.h" + +#define UPDATECHECKSTOP(a, b, c) if ((a=(MAX((a),(b))))>(c)) return (a); + +static int estimate_stepalt(StepAlt *a, uint64_t *ind); + +/* Checkers and validators ***************************************************/ + +/* TODO: these should be with Cube *cube (and all need to change) */ +/* Maybe move them to cube.c */ +static bool check_centers(Cube cube); +static bool check_coud_HTM(Cube cube); +static bool check_coud_URF(Cube cube); +static bool check_corners_HTM(Cube cube); +static bool check_corners_URF(Cube cube); +static bool check_cornershtr(Cube cube); +static bool check_eofb(Cube cube); +static bool check_drud(Cube cube); +static bool check_htr(Cube cube); + +static bool always_valid(Alg *alg); +static bool validate_singlecw_ending(Alg *alg); + +/* Messages for when cube is not ready ***************************************/ + +static char check_centers_msg[100] = "cube must be oriented (centers solved)"; +static char check_eo_msg[100] = "EO must be solved on given axis"; +static char check_dr_msg[100] = "DR must be solved on given axis"; +static char check_htr_msg[100] = "HTR must be solved"; +static char check_drany_msg[100] = "DR must be solved on at least one axis"; + +/* Steps *********************************************************************/ + +/* Optimal solvers *******************/ + +Step +optimal_HTM = { + .shortname = "optimal", + .name = "Optimal solve (in HTM)", + + .final = true, + .is_done = is_solved, + .estimate = estimate_nxopt31_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = always_valid, + .moveset = &moveset_HTM, + + .pre_trans = uf, + + .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, + .ntables = 2, +}; + +Step +optimal_light_HTM = { + .shortname = "light", + .name = "Optimal solve (in HTM), small table (500Mb RAM total)", + + .final = true, + .is_done = is_solved, + .estimate = estimate_light_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = always_valid, + .moveset = &moveset_HTM, + + .pre_trans = uf, + + .tables = {&pd_drud_sym16_HTM, &pd_corners_HTM}, + .ntables = 2, +}; + +/* Optimal after EO ******************/ + +Step +eofin_eo = { + .shortname = "eofin", + .name = "Optimal solve after EO without breaking EO (detected)", + + .final = true, + .is_done = is_solved, + .estimate = estimate_nxopt31_HTM, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = always_valid, + .moveset = &moveset_eofb, + + .detect = detect_pretrans_eofb, + + .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, + .ntables = 2, +}; + +Step +eofbfin_eofb = { + .shortname = "eofbfin", + .name = "Optimal after EO on F/B without breaking EO", + + .final = true, + .is_done = is_solved, + .estimate = estimate_nxopt31_HTM, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = always_valid, + .moveset = &moveset_eofb, + + .pre_trans = uf, + + .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, + .ntables = 2, +}; + +Step +eorlfin_eorl = { + .shortname = "eorlfin", + .name = "Optimal after EO on R/L without breaking EO", + + .final = true, + .is_done = is_solved, + .estimate = estimate_nxopt31_HTM, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = always_valid, + .moveset = &moveset_eofb, + + .pre_trans = ur, + + .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, + .ntables = 2, +}; + +Step +eoudfin_eoud = { + .shortname = "eoudfin", + .name = "Optimal after EO on U/D without breaking EO", + + .final = true, + .is_done = is_solved, + .estimate = estimate_nxopt31_HTM, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = always_valid, + .moveset = &moveset_eofb, + + .pre_trans = fd, + + .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, + .ntables = 2, +}; + +/* EO steps **************************/ +Step +eoany_HTM = { + .shortname = "eo", + .name = "EO on any axis", + + .final = false, + .is_done = check_eofb, + .estimate = estimate_eofb_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .detect = detect_pretrans_void_3axis, + + .tables = {&pd_eofb_HTM}, + .ntables = 1, +}; + +Step +eofb_HTM = { + .shortname = "eofb", + .name = "EO on F/B", + + .final = false, + .is_done = check_eofb, + .estimate = estimate_eofb_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = uf, + + .tables = {&pd_eofb_HTM}, + .ntables = 1, +}; + +Step +eorl_HTM = { + .shortname = "eorl", + .name = "EO on R/L", + + .final = false, + .is_done = check_eofb, + .estimate = estimate_eofb_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = ur, + + .tables = {&pd_eofb_HTM}, + .ntables = 1, +}; + +Step +eoud_HTM = { + .shortname = "eoud", + .name = "EO on U/D", + + .final = false, + .is_done = check_eofb, + .estimate = estimate_eofb_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = fd, + + .tables = {&pd_eofb_HTM}, + .ntables = 1, +}; + +/* CO steps **************************/ +Step +coany_HTM = { + .shortname = "co", + .name = "CO on any axis", + + .final = false, + .is_done = check_coud_HTM, + .estimate = estimate_coud_HTM, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .detect = detect_pretrans_void_3axis, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +Step +coud_HTM = { + .shortname = "coud", + .name = "CO on U/D", + + .final = false, + .is_done = check_coud_HTM, + .estimate = estimate_coud_HTM, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = uf, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +Step +corl_HTM = { + .shortname = "corl", + .name = "CO on R/L", + + .final = false, + .is_done = check_coud_HTM, + .estimate = estimate_coud_HTM, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = rf, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +Step +cofb_HTM = { + .shortname = "cofb", + .name = "CO on F/B", + + .final = false, + .is_done = check_coud_HTM, + .estimate = estimate_coud_HTM, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = fd, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +Step +coany_URF = { + .shortname = "co-URF", + .name = "CO any axis (URF moveset)", + + .final = false, + .is_done = check_coud_URF, + .estimate = estimate_coud_URF, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_URF, + + .detect = detect_pretrans_void_3axis, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +Step +coud_URF = { + .shortname = "coud-URF", + .name = "CO on U/D (URF moveset)", + + .final = false, + .is_done = check_coud_URF, + .estimate = estimate_coud_URF, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_URF, + + .pre_trans = uf, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +Step +corl_URF = { + .shortname = "corl-URF", + .name = "CO on R/L (URF moveset)", + + .final = false, + .is_done = check_coud_URF, + .estimate = estimate_coud_URF, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_URF, + + .pre_trans = rf, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +Step +cofb_URF = { + .shortname = "cofb-URF", + .name = "CO on F/B (URF moveset)", + + .final = false, + .is_done = check_coud_URF, + .estimate = estimate_coud_URF, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_URF, + + .pre_trans = fd, + + .tables = {&pd_coud_HTM}, + .ntables = 1, +}; + +/* Misc corner steps *****************/ +Step +cornershtr_HTM = { + .shortname = "chtr", + .name = "Solve corners to HTR state", + + .final = false, + .is_done = check_cornershtr, + .estimate = estimate_cornershtr_HTM, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = uf, + + .tables = {&pd_cornershtr_HTM}, + .ntables = 1, +}; + +Step +cornershtr_URF = { + .shortname = "chtr-URF", + .name = "Solve corners to HTR state (URF moveset)", + + .final = false, + .is_done = check_cornershtr, + .estimate = estimate_cornershtr_URF, + .ready = NULL, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_URF, + + .pre_trans = uf, + + .tables = {&pd_cornershtr_HTM}, + .ntables = 1, +}; + +Step +corners_HTM = { + .shortname = "corners", + .name = "Solve corners", + + .final = true, + .is_done = check_corners_HTM, + .estimate = estimate_corners_HTM, + .ready = NULL, + .is_valid = always_valid, + .moveset = &moveset_HTM, + + .pre_trans = uf, + + .tables = {&pd_corners_HTM}, + .ntables = 1, +}; + +Step +corners_URF = { + .shortname = "corners-URF", + .name = "Solve corners (URF moveset)", + + .final = true, /* TODO: check if this works with reorient */ + .is_done = check_corners_URF, + .estimate = estimate_corners_URF, + .ready = NULL, + .is_valid = always_valid, + .moveset = &moveset_URF, + + .pre_trans = uf, + + .tables = {&pd_corners_HTM}, + .ntables = 1, +}; + +/* DR steps **************************/ +Step +drany_HTM = { + .shortname = "dr", + .name = "DR on any axis", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .detect = detect_pretrans_void_3axis, + + .tables = {&pd_drud_sym16_HTM}, + .ntables = 1, +}; + +Step +drud_HTM = { + .shortname = "drud", + .name = "DR on U/D", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = uf, + + .tables = {&pd_drud_sym16_HTM}, + .ntables = 1, +}; + +Step +drrl_HTM = { + .shortname = "drrl", + .name = "DR on R/L", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = rf, + + .tables = {&pd_drud_sym16_HTM}, + .ntables = 1, +}; + +Step +drfb_HTM = { + .shortname = "drfb", + .name = "DR on F/B", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_HTM, + .ready = check_centers, + .ready_msg = check_centers_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_HTM, + + .pre_trans = fd, + + .tables = {&pd_drud_sym16_HTM}, + .ntables = 1, +}; + +/* DR from EO */ +Step +dr_eo = { + .shortname = "dr-eo", + .name = "DR without breaking EO (automatically detected)", + + .final = false, + .is_done = check_drud, + .estimate = estimate_dr_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .detect = detect_pretrans_eofb, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +dr_eofb = { + .shortname = "dr-eofb", + .name = "DR on U/D or R/L without breaking EO on F/B", + + .final = false, + .is_done = check_drud, + .estimate = estimate_dr_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = uf, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +dr_eorl = { + .shortname = "dr-eorl", + .name = "DR on U/D or F/B without breaking EO on R/L", + + .final = false, + .is_done = check_drud, + .estimate = estimate_dr_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = ur, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +dr_eoud = { + .shortname = "dr-eoud", + .name = "DR on R/L or F/B without breaking EO on U/D", + + .final = false, + .is_done = check_drud, + .estimate = estimate_dr_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = fd, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +drud_eofb = { + .shortname = "drud-eofb", + .name = "DR on U/D without breaking EO on F/B", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = uf, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +drrl_eofb = { + .shortname = "drrl-eofb", + .name = "DR on R/L without breaking EO on F/B", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = rf, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +drud_eorl = { + .shortname = "drud-eorl", + .name = "DR on U/D without breaking EO on R/L", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = ur, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +drfb_eorl = { + .shortname = "drfb-eorl", + .name = "DR on F/B without breaking EO on R/L", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = fr, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +drfb_eoud = { + .shortname = "drfb-eoud", + .name = "DR on F/B without breaking EO on U/D", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = fd, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +Step +drrl_eoud = { + .shortname = "drrl-eoud", + .name = "DR on R/L without breaking EO on U/D", + + .final = false, + .is_done = check_drud, + .estimate = estimate_drud_eofb, + .ready = check_eofb, + .ready_msg = check_eo_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_eofb, + + .pre_trans = rd, + + .tables = {&pd_drud_eofb}, + .ntables = 1, +}; + +/* DR finish steps */ +Step +dranyfin_DR = { + .shortname = "drfin", + .name = "DR finish on any axis without breaking DR", + + .final = true, + .is_done = is_solved, + .estimate = estimate_drudfin_drud, + .ready = check_drud, + .ready_msg = check_drany_msg, + .is_valid = always_valid, + .moveset = &moveset_drud, + + .detect = detect_pretrans_drud, + + .tables = {&pd_drudfin_noE_sym16_drud}, + .ntables = 1, +}; + +Step +drudfin_drud = { + .shortname = "drudfin", + .name = "DR finish on U/D without breaking DR", + + .final = true, + .is_done = is_solved, + .estimate = estimate_drudfin_drud, + .ready = check_drud, + .ready_msg = check_dr_msg, + .is_valid = always_valid, + .moveset = &moveset_drud, + + .pre_trans = uf, + + .tables = {&pd_drudfin_noE_sym16_drud}, + .ntables = 1, +}; + +Step +drrlfin_drrl = { + .shortname = "drrlfin", + .name = "DR finish on R/L without breaking DR", + + .final = true, + .is_done = is_solved, + .estimate = estimate_drudfin_drud, + .ready = check_drud, + .ready_msg = check_dr_msg, + .is_valid = always_valid, + .moveset = &moveset_drud, + + .pre_trans = rf, + + .tables = {&pd_drudfin_noE_sym16_drud}, + .ntables = 1, +}; + +Step +drfbfin_drfb = { + .shortname = "drfbfin", + .name = "DR finish on F/B without breaking DR", + + .final = true, + .is_done = is_solved, + .estimate = estimate_drudfin_drud, + .ready = check_drud, + .ready_msg = check_dr_msg, + .is_valid = always_valid, + .moveset = &moveset_drud, + + .pre_trans = fd, + + .tables = {&pd_drudfin_noE_sym16_drud}, + .ntables = 1, +}; + +/* HTR from DR */ +Step +htr_any = { + .shortname = "htr", + .name = "HTR from DR", + + .final = false, + .is_done = check_htr, + .estimate = estimate_htr_drud, + .ready = check_drud, + .ready_msg = check_drany_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_drud, + + .detect = detect_pretrans_drud, + + .tables = {&pd_htr_drud}, + .ntables = 1, +}; + +Step +htr_drud = { + .shortname = "htr-drud", + .name = "HTR from DR on U/D", + + .final = false, + .is_done = check_htr, + .estimate = estimate_htr_drud, + .ready = check_drud, + .ready_msg = check_dr_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_drud, + + .pre_trans = uf, + + .tables = {&pd_htr_drud}, + .ntables = 1, +}; + +Step +htr_drrl = { + .shortname = "htr-drrl", + .name = "HTR from DR on R/L", + + .final = false, + .is_done = check_htr, + .estimate = estimate_htr_drud, + .ready = check_drud, + .ready_msg = check_dr_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_drud, + + .pre_trans = rf, + + .tables = {&pd_htr_drud}, + .ntables = 1, +}; + +Step +htr_drfb = { + .shortname = "htr-drfb", + .name = "HTR from DR on F/B", + + .final = false, + .is_done = check_htr, + .estimate = estimate_htr_drud, + .ready = check_drud, + .ready_msg = check_dr_msg, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_drud, + + .pre_trans = fd, + + .tables = {&pd_htr_drud}, + .ntables = 1, +}; + +/* HTR finish */ +Step +htrfin_htr = { + .shortname = "htrfin", + .name = "HTR finish without breaking HTR", + + .final = true, + .is_done = is_solved, + .estimate = estimate_htrfin_htr, + .ready = check_htr, + .ready_msg = check_htr_msg, + .is_valid = always_valid, + .moveset = &moveset_htr, + + .pre_trans = uf, + + .tables = {&pd_htrfin_htr}, + .ntables = 1, +}; + +Step *steps[] = { + &optimal_HTM, /* first is default */ + &optimal_light_HTM, + + &eofin_eo, + &eofbfin_eofb, + &eorlfin_eorl, + &eoudfin_eoud, + + &eoany_HTM, + &eofb_HTM, + &eorl_HTM, + &eoud_HTM, + + &coany_HTM, + &coud_HTM, + &corl_HTM, + &cofb_HTM, + + &coany_URF, + &coud_URF, + &corl_URF, + &cofb_URF, + + &drany_HTM, + &drud_HTM, + &drrl_HTM, + &drfb_HTM, + + &dr_eo, + &dr_eofb, + &dr_eorl, + &dr_eoud, + &drud_eofb, + &drrl_eofb, + &drud_eorl, + &drfb_eorl, + &drfb_eoud, + &drrl_eoud, + + &dranyfin_DR, + &drudfin_drud, + &drrlfin_drrl, + &drfbfin_drfb, + + &htr_any, + &htr_drud, + &htr_drrl, + &htr_drfb, + + &htrfin_htr, + + &cornershtr_HTM, + &cornershtr_URF, + &corners_HTM, + &corners_URF, + + NULL +}; + +/* Checkers and validators ***************************************************/ + +static bool +check_centers(Cube cube) +{ + return cube.cpos == 0; +} + +static bool +check_coud_HTM(Cube cube) +{ + return cube.coud == 0; +} + +static bool +check_coud_URF(Cube cube) +{ + Cube c2, c3; + + c2 = apply_move(z, cube); + c3 = apply_move(x, cube); + + return cube.coud == 0 || c2.coud == 0 || c3.coud == 0; +} + +static bool +check_corners_URF(Cube cube) +{ + Cube c; + Trans i; + + for (i = 0; i < NROTATIONS; i++) { + c = apply_alg(rotation_alg(i), cube); + if (c.cp && c.coud) + return true; + } + + return false; +} + +static bool +check_corners_HTM(Cube cube) +{ + return cube.cp == 0 && cube.coud == 0; +} + +static bool +check_cornershtr(Cube cube) +{ + return coord_cornershtr.index(cube) == 0; +} + +static bool +check_eofb(Cube cube) +{ + return cube.eofb == 0; +} + +static bool +check_drud(Cube cube) +{ + return cube.eofb == 0 && cube.eorl == 0 && cube.coud == 0; +} + +static bool +check_htr(Cube cube) +{ + return check_drud(cube) && coord_htr_drud.index(cube) == 0; +} + +static bool +always_valid(Alg *alg) +{ + return true; +} + +static bool +validate_singlecw_ending(Alg *alg) +{ + int i; + bool nor, inv; + Move l2 = NULLMOVE, l1 = NULLMOVE, l2i = NULLMOVE, l1i = NULLMOVE; + + for (i = 0; i < alg->len; i++) { + if (alg->inv[i]) { + l2i = l1i; + l1i = alg->move[i]; + } else { + l2 = l1; + l1 = alg->move[i]; + } + } + + nor = l1 ==base_move(l1) && (!commute(l1, l2) ||l2 ==base_move(l2)); + inv = l1i==base_move(l1i) && (!commute(l1i,l2i)||l2i==base_move(l2i)); + + return nor && inv; +} + +/* Public functions **********************************************************/ + +void +compute_ind(StepAlt *a, Cube *cube, uint64_t *ind) +{ + +} + +int +estimate_stepalt(StepAlt *a, uint64_t *ind) +{ + int i, ret, est[a->n_coord]; + + for (i = 0; i < a->n_coord; i++) { + est[i] = ptableval(a->pd[i], ind[i]); + if (est[i] == 0 && a->compact_pd[i]) + est[i] = ptableval(a->fallback_pd, ind[i] / a->fbmod); + } + + for (i = 0; i < a->n_dbtrick; i++) + if (est[a->dbtrick[i][0]] == est[a->dbtrick[i][1]] && + est[a->dbtrick[i][0]] == est[a->dbtrick[i][2]]) + est[a->dbtrick[i][0]] += 1; + + for (i = 0, ret = -1; i < a->n_coord; i++) + ret = max(ret, est[i]); + + return ret; +} + +void +prepare_step(Step *step, SolveOptions *opts) +{ + int i, j; + PDGenData pdg; + StepAlt *a; + + init_moveset(step->moveset); + pdg.moveset = step->moveset; + + for (i = 0; step->alt[i] != NULL; i++) { + a = step->alt[i]; + for (j = 0; j < a->n_coord; j++) { + gen_coord(a->coord[j]); + + pdg.coord = a->coord[j]; + pdg.compact = a->compact[j]; + pdg.pd = NULL; + + a->pd[j] = genptable(&pdg, opts->nthreads); + + if (a->compact_pd[j]) { + gen_coord(a->fallback_coord[j]); + + pdg.coord = a->fallback_coord[j]; + pdg.compact = false; + pdg.pd = NULL; + + a->fallback_pd[j] = + step->genptable(&pdg, opts->nthreads); + } + } + } +} -- cgit v1.3