nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

drslice.h (2765B)


      1 /*
      2 The DRSLICE coordinate is almost identical to DRFINNOE, but it allows for
      3 the centers of the E layer to be off by a rotation. For this reason we reuse
      4 much of the code of DRFINNOE. We could make the pruning table 4x smaller
      5 if we reduced the coordinate by rotations. TODO.
      6 */
      7 
      8 STATIC cube_t coordinate_drslice_merge(cube_t, cube_t);
      9 STATIC uint64_t coordinate_drslice_coord(cube_t, const unsigned char *);
     10 STATIC cube_t coordinate_drslice_cube(uint64_t, const unsigned char *);
     11 STATIC bool coordinate_drslice_isnasty(uint64_t, const unsigned char *);
     12 STATIC size_t coordinate_drslice_gendata(unsigned char *);
     13 STATIC bool is_drslice_solvable(cube_t);
     14 STATIC bool is_drslice_solved(uint64_t, const unsigned char *);
     15 
     16 STATIC coord_t coordinate_drslice = {
     17 	.name = "DRSLICE",
     18 	.coord = &coordinate_drslice_coord,
     19 	.cube = &coordinate_drslice_cube,
     20 	.isnasty = &coordinate_drslice_isnasty,
     21 	.gendata = coordinate_drslice_gendata,
     22 	.max = CLASSES_CP_16 * FACT_8,
     23 	.trans_mask = TM_UDFIX,
     24 	.moves_mask_gendata = MM18_DR,
     25 	.moves_mask_solve = MM18_DR_NOD,
     26 	.is_admissible = &solution_always_valid,
     27 	.is_solvable = &is_drslice_solvable,
     28 	.is_solved = &is_drslice_solved,
     29 	.allow_niss = false,
     30 	.pruning_distribution = {
     31  		[0] = 3,
     32 		[1] = 7,
     33 		[2] = 18,
     34 		[3] = 111,
     35 		[4] = 433,
     36 		[5] = 1618,
     37 		[6] = 6718,
     38 		[7] = 29182,
     39 		[8] = 119873,
     40 		[9] = 476999,
     41 		[10] = 1858350,
     42 		[11] = 6531166,
     43 		[12] = 18338522,
     44 		[13] = 32839235,
     45 		[14] = 34118824,
     46 		[15] = 17284701
     47 	},
     48 	.pruning_max = 15,
     49 	.sym = {
     50 		.classes = CLASSES_CP_16,
     51 		.max = FACT_8,
     52 		.coord = &coord_cp,
     53 		.cube = &invcoord_cp,
     54 		.max2 = FACT_8,
     55 		.coord2 = &coord_epud,
     56 		.cube2 = &invcoord_epud,
     57 		.merge = &coordinate_drslice_merge,
     58 	},
     59 };
     60 
     61 STATIC cube_t
     62 coordinate_drslice_merge(cube_t c1, cube_t c2)
     63 {
     64 	cube_t merged;
     65 
     66 	merged = c1;
     67 	copy_edges(&merged, c2);
     68 
     69 	return merged;
     70 }
     71 
     72 STATIC uint64_t
     73 coordinate_drslice_coord(cube_t cube, const unsigned char *data)
     74 {
     75 	return coord_coord_generic(&coordinate_drslice, cube, data);
     76 }
     77 
     78 STATIC cube_t
     79 coordinate_drslice_cube(uint64_t i, const unsigned char *data)
     80 {
     81 	return coord_cube_generic(&coordinate_drslice, i, data);
     82 }
     83 
     84 STATIC size_t
     85 coordinate_drslice_gendata(unsigned char *data)
     86 {
     87 	return coord_gendata_generic(&coordinate_drslice, data);
     88 }
     89 
     90 STATIC bool
     91 coordinate_drslice_isnasty(uint64_t i, const unsigned char *data)
     92 {
     93 	return coord_isnasty_generic(&coordinate_drslice, i, data);
     94 }
     95 
     96 STATIC bool
     97 is_drslice_solvable(cube_t cube) {
     98 	return coord_eo(cube) == 0 &&
     99 	       coord_eo(transform_edges(cube, TRANS_URr)) == 0 &&
    100 	       coord_co(cube) == 0;
    101 }
    102 
    103 STATIC bool
    104 is_drslice_solved(uint64_t i, const unsigned char *data)
    105 {
    106 	/* Pre-computed coordinates of U D' (= U' D up to trans) and U2 D2 */
    107 	return i == 0 || i == 109779816 || i == 68468527;
    108 }