From b5b382d43f6ce23c97021b742fb7519b1e0f10ab Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Thu, 7 Feb 2019 14:22:33 -0700 Subject: [PATCH] 666 move step60 to IDAViaC --- ida_search.c | 98 +++++++- ida_search_666.c | 133 ++++++++++- ida_search_666.h | 13 + rubikscubennnsolver/RubiksCube666.py | 340 +-------------------------- 4 files changed, 239 insertions(+), 345 deletions(-) diff --git a/ida_search.c b/ida_search.c index ae6117df..946f72b0 100644 --- a/ida_search.c +++ b/ida_search.c @@ -54,6 +54,7 @@ typedef enum { // 6x6x6 UD_OBLIQUE_EDGES_STAGE_666, LR_INNER_X_CENTERS_AND_OBLIQUE_EDGES_STAGE_666, + LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_SOLVE_666, // 7x7x7 UD_OBLIQUE_EDGES_STAGE_777, @@ -94,10 +95,14 @@ char *LF_centers_cost_only_555 = NULL; // 6x6x6 -struct key_value_pair *LR_inner_x_centers_and_oblique_edges_666 = NULL; +struct key_value_pair *LR_inner_x_centers_and_oblique_edges_stage_666 = NULL; char *LR_inner_x_centers_666 = NULL; char *LR_oblique_edges_666 = NULL; +struct key_value_pair *LFRB_inner_x_centers_and_oblique_edges_solve_666 = NULL; +char *LR_inner_x_centers_and_oblique_edges_solve_666 = NULL; +char *FB_inner_x_centers_and_oblique_edges_solve_666 = NULL; + // 7x7x7 struct key_value_pair *step40_777 = NULL; @@ -421,6 +426,12 @@ init_cube(char *cube, int size, lookup_table_type type, char *kociemba) print_cube(cube, size); break; + case LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_SOLVE_666: + // Convert to 1s and 0s + str_replace_for_binary(cube, ones_LF); + print_cube(cube, size); + break; + case CENTERS_SOLVE_555: // Remember what the cube looked like so we can restore the edges memcpy(cube_copy, cube, sizeof(char) * array_size); @@ -605,7 +616,8 @@ ida_prune_table_preload (struct key_value_pair **hashtable, char *filename) } - } else if (strmatch(filename, "lookup-table-6x6x6-step30-LR-inner-x-centers-oblique-edges-stage.txt")) { + } else if (strmatch(filename, "lookup-table-6x6x6-step30-LR-inner-x-centers-oblique-edges-stage.txt") || + strmatch(filename, "lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.3-deep")) { while (fgets(buffer, BUFFER_SIZE, fh_read) != NULL) { // 0..11 are the state @@ -769,10 +781,18 @@ ida_heuristic (char *cube, lookup_table_type type, unsigned int max_cost_to_goal return ida_heuristic_LR_inner_x_centers_and_oblique_edges_stage_666( cube, max_cost_to_goal, - &LR_inner_x_centers_and_oblique_edges_666, + &LR_inner_x_centers_and_oblique_edges_stage_666, LR_inner_x_centers_666, LR_oblique_edges_666); + case LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_SOLVE_666: + return ida_heuristic_LFRB_inner_x_centers_and_oblique_edges_solve_666( + cube, + max_cost_to_goal, + &LFRB_inner_x_centers_and_oblique_edges_solve_666, + LR_inner_x_centers_and_oblique_edges_solve_666, + FB_inner_x_centers_and_oblique_edges_solve_666); + // 7x7x7 case UD_OBLIQUE_EDGES_STAGE_777: return ida_heuristic_UD_oblique_edges_stage_777(cube, max_cost_to_goal); @@ -1091,6 +1111,9 @@ ida_search_complete ( case LR_INNER_X_CENTERS_AND_OBLIQUE_EDGES_STAGE_666: return ida_search_complete_LR_inner_x_centers_and_oblique_edges_stage(cube); + case LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_SOLVE_666: + return ida_search_complete_LFRB_inner_x_centers_and_oblique_edges_solve(cube); + // 7x7x7 case UD_OBLIQUE_EDGES_STAGE_777: return ida_search_complete_UD_oblique_edges_stage_777(cube); @@ -1295,6 +1318,53 @@ step_allowed_by_ida_search (lookup_table_type type, move_type move) return 1; } + case LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_SOLVE_666: + switch (move) { + // do not mess up staged centers + case threeUw: + case threeUw_PRIME: + case threeDw: + case threeDw_PRIME: + case threeLw: + case threeLw_PRIME: + case threeRw: + case threeRw_PRIME: + case threeFw: + case threeFw_PRIME: + case threeBw: + case threeBw_PRIME: + case threeRw2: + case threeLw2: + case threeFw2: + case threeBw2: + case Uw: + case Uw_PRIME: + case Dw: + case Dw_PRIME: + case Lw: + case Lw_PRIME: + case Rw: + case Rw_PRIME: + case Fw: + case Fw_PRIME: + case Bw: + case Bw_PRIME: + + // can skip these for 6x6x6 cubes + //case threeLw: + //case threeLw_PRIME: + //case threeLw2: + //case threeDw: + //case threeDw_PRIME: + case threeDw2: + //case threeBw: + //case threeBw_PRIME: + //case threeBw2: + return 0; + default: + return 1; + } + // 7x7x7 case UD_OBLIQUE_EDGES_STAGE_777: switch (move) { @@ -2185,9 +2255,14 @@ free_prune_tables() ULFRBD_centers_555 = NULL; } - if (LR_inner_x_centers_and_oblique_edges_666 == NULL) { - free(LR_inner_x_centers_and_oblique_edges_666); - LR_inner_x_centers_and_oblique_edges_666 = NULL; + if (LR_inner_x_centers_and_oblique_edges_stage_666 == NULL) { + free(LR_inner_x_centers_and_oblique_edges_stage_666); + LR_inner_x_centers_and_oblique_edges_stage_666 = NULL; + } + + if (LFRB_inner_x_centers_and_oblique_edges_solve_666 == NULL) { + free(LFRB_inner_x_centers_and_oblique_edges_solve_666); + LFRB_inner_x_centers_and_oblique_edges_solve_666 = NULL; } } @@ -2259,11 +2334,16 @@ ida_solve ( break; case LR_INNER_X_CENTERS_AND_OBLIQUE_EDGES_STAGE_666: - ida_prune_table_preload(&LR_inner_x_centers_and_oblique_edges_666, "lookup-table-6x6x6-step30-LR-inner-x-centers-oblique-edges-stage.txt"); + ida_prune_table_preload(&LR_inner_x_centers_and_oblique_edges_stage_666, "lookup-table-6x6x6-step30-LR-inner-x-centers-oblique-edges-stage.txt"); LR_oblique_edges_666 = ida_cost_only_preload("lookup-table-6x6x6-step31-LR-oblique-edges-stage.hash-cost-only.txt", 165636908); LR_inner_x_centers_666 = ida_cost_only_preload("lookup-table-6x6x6-step32-LR-inner-x-center-stage.cost-only.txt", 65281); break; + case LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_SOLVE_666: + ida_prune_table_preload(&LFRB_inner_x_centers_and_oblique_edges_solve_666, "lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.3-deep"); + LR_inner_x_centers_and_oblique_edges_solve_666 = ida_cost_only_preload("lookup-table-6x6x6-step61-LR-solve-inner-x-center-and-oblique-edges.cost-only.txt", 16773121); + FB_inner_x_centers_and_oblique_edges_solve_666 = ida_cost_only_preload("lookup-table-6x6x6-step62-FB-solve-inner-x-center-and-oblique-edges.cost-only.txt", 16773121); + // 7x7x7 case UD_OBLIQUE_EDGES_STAGE_777: case LR_OBLIQUE_EDGES_STAGE_777: @@ -2382,6 +2462,10 @@ main (int argc, char *argv[]) type = LR_INNER_X_CENTERS_AND_OBLIQUE_EDGES_STAGE_666, cube_size_type = 6; + } else if (strmatch(argv[i], "6x6x6-LFRB-solve-inner-x-center-and-oblique-edges")) { + type = LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_SOLVE_666, + cube_size_type = 6; + // 7x7x7 } else if (strmatch(argv[i], "7x7x7-UD-oblique-edges-stage")) { type = UD_OBLIQUE_EDGES_STAGE_777; diff --git a/ida_search_666.c b/ida_search_666.c index b4ae49ae..93e478d6 100644 --- a/ida_search_666.c +++ b/ida_search_666.c @@ -65,6 +65,30 @@ unsigned int LFRB_oblique_edges_666[NUM_LFRB_OBLIQUE_EDGES_666] = { 171, 172 }; +unsigned int LR_inner_x_centers_and_oblique_edges_666[NUM_LR_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666] = { + 45, 46, + 50, 51, 52, 53, + 56, 57, 58, 59, + 63, 64, + + 117, 118, + 122, 123, 124, 125, + 128, 129, 130, 131, + 135, 136, +}; + +unsigned int FB_inner_x_centers_and_oblique_edges_666[NUM_FB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666] = { + 81, 82, + 86, 87, 88, 89, + 92, 93, 94, 95, + 99, 100, + + 153, 154, + 158, 159, 160, 161, + 164, 165, 166, 167, + 171, 172 +}; + unsigned int LFRB_inner_x_centers_and_oblique_edges_666[NUM_LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666] = { 45, 46, 50, 51, 52, 53, @@ -169,7 +193,7 @@ struct ida_heuristic_result ida_heuristic_LR_inner_x_centers_and_oblique_edges_stage_666 ( char *cube, unsigned int max_cost_to_goal, - struct key_value_pair **LR_inner_x_centers_and_oblique_edges_666, + struct key_value_pair **LR_inner_x_centers_and_oblique_edges_stage_666, char *LR_inner_x_centers_cost_666, char *LR_oblique_edges_cost_666) { @@ -229,7 +253,7 @@ ida_heuristic_LR_inner_x_centers_and_oblique_edges_stage_666 ( int MAX_DEPTH = 2; struct key_value_pair *hash_entry = NULL; - hash_entry = hash_find(LR_inner_x_centers_and_oblique_edges_666, result.lt_state); + hash_entry = hash_find(LR_inner_x_centers_and_oblique_edges_stage_666, result.lt_state); if (hash_entry) { cost_to_goal = hash_entry->value; @@ -246,8 +270,7 @@ ida_heuristic_LR_inner_x_centers_and_oblique_edges_stage_666 ( int ida_search_complete_LR_inner_x_centers_and_oblique_edges_stage (char *cube) { - if (( - // First check if the inner x-centers are staged + if (( // First check if the inner x-centers are staged (cube[51] == '1' && cube[52] == '1' && cube[57] == '1' && @@ -266,7 +289,107 @@ ida_search_complete_LR_inner_x_centers_and_oblique_edges_stage (char *cube) cube[129] == '0' && cube[130] == '0')) && - // Then check if all LR oblique edges are paired + // Then check if all oblique edges are paired + get_unpaired_obliques_count_666(cube) == 0) { + return 1; + } else { + return 0; + } +} + + +// ============================================================================ +// step60 +// ============================================================================ +struct ida_heuristic_result +ida_heuristic_LFRB_inner_x_centers_and_oblique_edges_solve_666( + char *cube, + unsigned int max_cost_to_goal, + struct key_value_pair **LFRB_inner_x_centers_and_oblique_edges_solve_666, + char *LR_inner_x_centers_and_oblique_edges_solve_666, + char *FB_inner_x_centers_and_oblique_edges_solve_666) +{ + unsigned long long LR_state = 0; + unsigned long long LR_cost = 0; + unsigned long long FB_state = 0; + unsigned long long FB_cost = 0; + unsigned long long cost_to_goal = 0; + unsigned long long state = 0; + int cube_index; + struct ida_heuristic_result result; + + // get state of LR inner x-centers and oblique edges + for (int i = 0; i < NUM_LR_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666; i++) { + if (cube[LR_inner_x_centers_and_oblique_edges_666[i]] == '1') { + LR_state |= 0x1; + } + LR_state <<= 1; + } + LR_state >>= 1; + LR_cost = hex_to_int(LR_inner_x_centers_and_oblique_edges_solve_666[LR_state]); + + // get state of FB inner x-centers and oblique edges + for (int i = 0; i < NUM_FB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666; i++) { + if (cube[FB_inner_x_centers_and_oblique_edges_666[i]] == '1') { + FB_state |= 0x1; + } + FB_state <<= 1; + } + FB_state >>= 1; + FB_cost = hex_to_int(FB_inner_x_centers_and_oblique_edges_solve_666[FB_state]); + + // get state of LFRB inner x-centers and oblique edges + for (int i = 0; i < NUM_LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666; i++) { + if (cube[LFRB_inner_x_centers_and_oblique_edges_666[i]] == '1') { + state |= 0x1; + } + state <<= 1; + } + state >>= 1; + + // 00019b267fff is 12 chars + sprintf(result.lt_state, "%012llx", state); + cost_to_goal = max(LR_cost, FB_cost); + + // dwalton + // printf("LR_state %llu, LR_cost %llu, FB_state %llu, FB_cost %llu, state %s, cost_to_goal %llu\n", LR_state, LR_cost, FB_state, FB_cost, result.lt_state, cost_to_goal); + // exit(0); + + if (cost_to_goal > 0) { + // The step60 table we loaded is 3-deep + int MAX_DEPTH = 3; + + struct key_value_pair *hash_entry = NULL; + hash_entry = hash_find(LFRB_inner_x_centers_and_oblique_edges_solve_666, result.lt_state); + + if (hash_entry) { + cost_to_goal = hash_entry->value; + } else { + // Not admissible but much faster + cost_to_goal = max((int) cost_to_goal * 1.2, MAX_DEPTH+1); + //cost_to_goal = max(cost_to_goal, MAX_DEPTH + 1); + } + } + + result.cost_to_goal = cost_to_goal; + return result; +} + + +int +ida_search_complete_LFRB_inner_x_centers_and_oblique_edges_solve (char *cube) +{ + if (// First check if the inner x-centers are solved + cube[51] == '1' && + cube[52] == '1' && + cube[57] == '1' && + cube[58] == '1' && + cube[87] == '1' && + cube[88] == '1' && + cube[93] == '1' && + cube[94] == '1' && + + // Then check if all oblique edges are paired get_unpaired_obliques_count_666(cube) == 0) { return 1; } else { diff --git a/ida_search_666.h b/ida_search_666.h index 99451f84..0200360f 100644 --- a/ida_search_666.h +++ b/ida_search_666.h @@ -8,6 +8,9 @@ #define NUM_LFRB_INNER_X_CENTERS_666 16 #define NUM_LFRB_OBLIQUE_EDGES_666 32 + +#define NUM_LR_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666 24 +#define NUM_FB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666 24 #define NUM_LFRB_INNER_X_CENTERS_AND_OBLIQUE_EDGES_666 48 struct ida_heuristic_result ida_heuristic_UD_oblique_edges_stage_666( @@ -26,4 +29,14 @@ struct ida_heuristic_result ida_heuristic_LR_inner_x_centers_and_oblique_edges_s ); int ida_search_complete_LR_inner_x_centers_and_oblique_edges_stage(char *cube); + +struct ida_heuristic_result ida_heuristic_LFRB_inner_x_centers_and_oblique_edges_solve_666( + char *cube, + unsigned int max_cost_to_goal, + struct key_value_pair **LFRB_inner_x_centers_and_oblique_edges_solve_666, + char *LR_inner_x_centers_and_oblique_edges_solve_666, + char *FB_inner_x_centers_and_oblique_edges_solve_666 +); +int ida_search_complete_LFRB_inner_x_centers_and_oblique_edges_solve(char *cube); + #endif /* _IDA_SEARCH_666_H */ diff --git a/rubikscubennnsolver/RubiksCube666.py b/rubikscubennnsolver/RubiksCube666.py index 26e70786..7ee4c3e3 100755 --- a/rubikscubennnsolver/RubiksCube666.py +++ b/rubikscubennnsolver/RubiksCube666.py @@ -426,83 +426,7 @@ def ida_heuristic(self): return (lt_state, 0) -class LookupTable666LRInnerXCenterAndObliqueEdges(LookupTable): - """ - lookup-table-6x6x6-step61-LR-solve-inner-x-center-and-oblique-edges.txt - ======================================================================== - 1 steps has 140 entries (0 percent, 0.00x previous step) - 2 steps has 476 entries (0 percent, 3.40x previous step) - 3 steps has 2,166 entries (0 percent, 4.55x previous step) - 4 steps has 10,430 entries (3 percent, 4.82x previous step) - 5 steps has 37,224 entries (10 percent, 3.57x previous step) - 6 steps has 89,900 entries (26 percent, 2.42x previous step) - 7 steps has 124,884 entries (36 percent, 1.39x previous step) - 8 steps has 70,084 entries (20 percent, 0.56x previous step) - 9 steps has 7,688 entries (2 percent, 0.11x previous step) - 10 steps has 8 entries (0 percent, 0.00x previous step) - - Total: 343,000 entries - Average: 6.64 moves - """ - - def __init__(self, parent): - LookupTable.__init__( - self, - parent, - 'lookup-table-6x6x6-step61-LR-solve-inner-x-center-and-oblique-edges.txt', - ('198e67', '19b267', '19bc47', '19be23', '19be64', '1dc267', '1dcc47', '1dce23', - '1dce64', '1df047', '1df223', '1df264', '1dfc03', '1dfc44', '1dfe20', '3b8267', - '3b8c47', '3b8e23', '3b8e64', '3bb047', '3bb223', '3bb264', '3bbc03', '3bbc44', - '3bbe20', '3fc047', '3fc223', '3fc264', '3fcc03', '3fcc44', '3fce20', '3ff003', - '3ff044', '3ff220', '3ffc00', 'd98267', 'd98c47', 'd98e23', 'd98e64', 'd9b047', - 'd9b223', 'd9b264', 'd9bc03', 'd9bc44', 'd9be20', 'ddc047', 'ddc223', 'ddc264', - 'ddcc03', 'ddcc44', 'ddce20', 'ddf003', 'ddf044', 'ddf220', 'ddfc00', 'fb8047', - 'fb8223', 'fb8264', 'fb8c03', 'fb8c44', 'fb8e20', 'fbb003', 'fbb044', 'fbb220', - 'fbbc00', 'ffc003', 'ffc044', 'ffc220', 'ffcc00', 'fff000'), - linecount=343000, - max_depth=10, - filesize=3430000) - - -class LookupTable666FBInnerXCenterAndObliqueEdges(LookupTable666LRInnerXCenterAndObliqueEdges): - """ - lookup-table-6x6x6-step62-FB-solve-inner-x-center-and-oblique-edges.txt - ======================================================================= - 1 steps has 140 entries (0 percent, 0.00x previous step) - 2 steps has 476 entries (0 percent, 3.40x previous step) - 3 steps has 2,166 entries (0 percent, 4.55x previous step) - 4 steps has 10,430 entries (3 percent, 4.82x previous step) - 5 steps has 37,224 entries (10 percent, 3.57x previous step) - 6 steps has 89,900 entries (26 percent, 2.42x previous step) - 7 steps has 124,884 entries (36 percent, 1.39x previous step) - 8 steps has 70,084 entries (20 percent, 0.56x previous step) - 9 steps has 7,688 entries (2 percent, 0.11x previous step) - 10 steps has 8 entries (0 percent, 0.00x previous step) - - Total: 343,000 entries - Average: 6.64 moves - """ - - def __init__(self, parent): - LookupTable.__init__( - self, - parent, - 'lookup-table-6x6x6-step62-FB-solve-inner-x-center-and-oblique-edges.txt', - ('198e67', '19b267', '19bc47', '19be23', '19be64', '1dc267', '1dcc47', '1dce23', - '1dce64', '1df047', '1df223', '1df264', '1dfc03', '1dfc44', '1dfe20', '3b8267', - '3b8c47', '3b8e23', '3b8e64', '3bb047', '3bb223', '3bb264', '3bbc03', '3bbc44', - '3bbe20', '3fc047', '3fc223', '3fc264', '3fcc03', '3fcc44', '3fce20', '3ff003', - '3ff044', '3ff220', '3ffc00', 'd98267', 'd98c47', 'd98e23', 'd98e64', 'd9b047', - 'd9b223', 'd9b264', 'd9bc03', 'd9bc44', 'd9be20', 'ddc047', 'ddc223', 'ddc264', - 'ddcc03', 'ddcc44', 'ddce20', 'ddf003', 'ddf044', 'ddf220', 'ddfc00', 'fb8047', - 'fb8223', 'fb8264', 'fb8c03', 'fb8c44', 'fb8e20', 'fbb003', 'fbb044', 'fbb220', - 'fbbc00', 'ffc003', 'ffc044', 'ffc220', 'ffcc00', 'fff000'), - linecount=343000, - max_depth=10, - filesize=3430000) - - -class LookupTableIDA666LFRBInnerXCenterAndObliqueEdges(LookupTableIDA): +class LookupTableIDA666LFRBInnerXCenterAndObliqueEdges(LookupTableIDAViaC): """ lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt ========================================================================= @@ -514,31 +438,6 @@ class LookupTableIDA666LFRBInnerXCenterAndObliqueEdges(LookupTableIDA): Total: 35,805,732 entries """ - step60_centers_666 = ( - # Left - 45, 46, - 50, 51, 52, 53, - 56, 57, 58, 59, - 63, 64, - - # Front - 81, 82, - 86, 87, 88, 89, - 92, 93, 94, 95, - 99, 100, - - # Right - 117, 118, - 122, 123, 124, 125, - 128, 129, 130, 131, - 135, 136, - - # Back - 153, 154, - 158, 159, 160, 161, - 164, 165, 166, 167, - 171, 172, - ) step61_centers_666 = ( # Left @@ -571,132 +470,15 @@ class LookupTableIDA666LFRBInnerXCenterAndObliqueEdges(LookupTableIDA): set_step61_centers_666 = set(step61_centers_666) set_step62_centers_666 = set(step62_centers_666) - # Not using these right now - heuristic_stats = { - (0, 0): 0, - (0, 2): 3, - (0, 3): 3, - (0, 4): 4, - (0, 5): 5, - (0, 6): 6, - (1, 1): 1, - (1, 2): 2, - (1, 3): 3, - (1, 4): 5, - (1, 5): 6, - (1, 6): 6, - (1, 7): 7, - (2, 0): 3, - (2, 1): 2, - (2, 2): 3, - (2, 3): 4, - (2, 4): 5, - (2, 5): 6, - (2, 6): 7, - (2, 7): 8, - (2, 8): 8, - (3, 0): 4, - (3, 1): 3, - (3, 2): 4, - (3, 3): 4, - (3, 4): 5, - (3, 5): 6, - (3, 6): 7, - (3, 7): 8, - (3, 8): 9, - (4, 1): 5, - (4, 2): 5, - (4, 3): 5, - (4, 4): 5, - (4, 5): 6, - (4, 6): 8, - (4, 7): 9, - (4, 8): 10, - (5, 1): 6, - (5, 2): 6, - (5, 3): 6, - (5, 4): 6, - (5, 5): 7, - (5, 6): 8, - (5, 7): 9, - (5, 8): 10, - (5, 9): 11, - (6, 2): 7, - (6, 3): 7, - (6, 4): 7, - (6, 5): 8, - (6, 6): 9, - (6, 7): 10, - (6, 8): 11, - (6, 9): 11, - (7, 2): 8, - (7, 3): 8, - (7, 4): 9, - (7, 5): 9, - (7, 6): 9, - (7, 7): 10, - (7, 8): 11, - (7, 9): 12, - (8, 2): 9, - (8, 3): 9, - (8, 4): 10, - (8, 5): 10, - (8, 6): 11, - (8, 7): 11, - (8, 8): 12, - (8, 9): 12, - (9, 5): 10, - (9, 6): 11, - (9, 7): 11, - (9, 8): 12 - } - - # The higher this number the less you honor the heuristic_stats - # - 0 uses the heuristic_stats exactly as reported - # - 1 subtracts 1 from the heuristic_stats value - # - 99 disables heuristic_stats - # - # You want to put this as high as you can but low enough - # to still speed up the slow IDA searches. - # 99 : 13 moves in 9s - # 2 : 13 moves in 1500ms - # 1 : 13 moves in 100ms - # 0 : 13 moves in 100ms - heuristic_stats_error = 1 - def __init__(self, parent): - # uses 165M - if True or parent.min_memory: - filename = "lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.4-deep" - linecount = 5320232 - max_depth = 4 - filesize = 164927192 - - # uses 1.3G - else: - filename = "lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt" - linecount = 35805732 - max_depth = 5 - filesize = 1289006352 - - LookupTableIDA.__init__( + LookupTableIDAViaC.__init__( self, parent, - filename, - state_targets_step60, - moves_666, - - ("3Rw", "3Rw'", "3Lw", "3Lw'", "3Fw", "3Fw'", "3Bw", "3Bw'", "3Uw", "3Uw'", "3Dw", "3Dw'", # do not mess up staged centers - "Rw", "Rw'", "Lw", "Lw'", "Fw", "Fw'", "Bw", "Bw'", "Uw", "Uw'", "Dw", "Dw'", # do not mess up staged centers - "3Rw2", "3Lw2", "3Fw2", "3Bw2", # do not mess up solved UD - "3Lw", "3Lw'", "3Lw2", # can skip these for 6x6x6 cubes - "3Dw", "3Dw'", "3Dw2", - "3Bw", "3Bw'", "3Bw2"), - - linecount=linecount, - max_depth=max_depth, - filesize=filesize, + (('lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt', 10953600, None), + ('lookup-table-6x6x6-step61-LR-solve-inner-x-center-and-oblique-edges.cost-only.txt', 16773121, None), + ('lookup-table-6x6x6-step62-FB-solve-inner-x-center-and-oblique-edges.cost-only.txt', 16773121, None)), + '6x6x6-LFRB-solve-inner-x-center-and-oblique-edges' # C_ida_type ) def recolor(self): @@ -716,104 +498,7 @@ def recolor(self): else: self.parent.state[x] = '.' - #self.parent.print_cube() - - def ida_heuristic_tuple(self): - parent_state = self.parent.state - parent = self.parent - parent_state = self.parent.state - set_step61_centers_666 = self.set_step61_centers_666 - set_step62_centers_666 = self.set_step62_centers_666 - - lt_state = 0 - step61_state = 0 - step62_state = 0 - - for x in self.step60_centers_666: - x_state = parent_state[x] - - if x in set_step61_centers_666: - - if x_state == 'L': - step61_state = step61_state | 0x1 - lt_state = lt_state | 0x1 - - step61_state = step61_state << 1 - - elif x in set_step62_centers_666: - - if x_state == 'F': - step62_state = step62_state | 0x1 - lt_state = lt_state | 0x1 - - step62_state = step62_state << 1 - - lt_state = lt_state << 1 - - lt_state = lt_state >> 1 - step61_state = step61_state >> 1 - step62_state = step62_state >> 1 - - step61_state = parent.lt_LR_solve_inner_x_centers_and_oblique_edges.hex_format % step61_state - step62_state = parent.lt_FB_solve_inner_x_centers_and_oblique_edges.hex_format % step62_state - - step61_cost = parent.lt_LR_solve_inner_x_centers_and_oblique_edges.heuristic(step61_state) - step62_cost = parent.lt_FB_solve_inner_x_centers_and_oblique_edges.heuristic(step62_state) - - return (str(self), step61_cost, step62_cost) - - def ida_heuristic(self): - parent = self.parent - parent_state = self.parent.state - set_step61_centers_666 = self.set_step61_centers_666 - set_step62_centers_666 = self.set_step62_centers_666 - - lt_state = 0 - step61_state = 0 - step62_state = 0 - - for x in self.step60_centers_666: - x_state = parent_state[x] - - if x in set_step61_centers_666: - - if x_state == 'L': - step61_state = step61_state | 0x1 - lt_state = lt_state | 0x1 - - step61_state = step61_state << 1 - - elif x in set_step62_centers_666: - - if x_state == 'F': - step62_state = step62_state | 0x1 - lt_state = lt_state | 0x1 - - step62_state = step62_state << 1 - - lt_state = lt_state << 1 - - lt_state = lt_state >> 1 - step61_state = step61_state >> 1 - step62_state = step62_state >> 1 - - step61_state = parent.lt_LR_solve_inner_x_centers_and_oblique_edges.hex_format % step61_state - step62_state = parent.lt_FB_solve_inner_x_centers_and_oblique_edges.hex_format % step62_state - lt_state = self.hex_format % lt_state - - step61_cost = parent.lt_LR_solve_inner_x_centers_and_oblique_edges.heuristic(step61_state) - step62_cost = parent.lt_FB_solve_inner_x_centers_and_oblique_edges.heuristic(step62_state) - cost_to_goal = max(step61_cost, step62_cost) - - if cost_to_goal > 0 and cost_to_goal < self.max_depth+1: - steps = self.steps(lt_state) - - if steps: - cost_to_goal = len(steps) - else: - cost_to_goal = self.max_depth + 1 - - return (lt_state, cost_to_goal) + self.parent.print_cube() class RubiksCube666(RubiksCubeNNNEvenEdges): @@ -941,13 +626,7 @@ def lt_init(self, UD_oblique_edge_only=False): self.lt_LR_inner_x_centers_and_oblique_edges_stage = LookupTableIDA666LRInnerXCenterAndObliqueEdgesStage(self) self.lt_UD_solve_inner_x_centers_and_oblique_edges = LookupTable666UDInnerXCenterAndObliqueEdges(self) - - self.lt_LR_solve_inner_x_centers_and_oblique_edges = LookupTable666LRInnerXCenterAndObliqueEdges(self) - self.lt_FB_solve_inner_x_centers_and_oblique_edges = LookupTable666FBInnerXCenterAndObliqueEdges(self) self.lt_LFRB_solve_inner_x_centers_and_oblique_edges = LookupTableIDA666LFRBInnerXCenterAndObliqueEdges(self) - self.lt_LR_solve_inner_x_centers_and_oblique_edges.preload_cache_dict() - self.lt_FB_solve_inner_x_centers_and_oblique_edges.preload_cache_dict() - self.lt_LFRB_solve_inner_x_centers_and_oblique_edges.preload_cache_string() def populate_fake_555_for_ULFRBD_solve(self): fake_555 = self.get_fake_555() @@ -1096,11 +775,6 @@ def group_centers_guts(self, oblique_edges_only=False): log.info("%s: UD inner x-center solved and oblique edges paired, %d steps in" % (self, self.get_solution_len_minus_rotates(self.solution))) #log.info("kociemba: %s" % self.get_kociemba_string(True)) - # Test the prune tables - #self.lt_LR_solve_inner_x_centers_and_oblique_edges.solve() - #self.lt_FB_solve_inner_x_centers_and_oblique_edges.solve() - #self.print_cube() - tmp_solution_len = len(self.solution) self.lt_LFRB_solve_inner_x_centers_and_oblique_edges.solve() self.print_cube()