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 (2589B)


      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 uint64_t coordinate_drslice_coord(cube_t, const unsigned char *);
      9 STATIC cube_t coordinate_drslice_cube(uint64_t, const unsigned char *);
     10 STATIC bool coordinate_drslice_isnasty(uint64_t, const unsigned char *);
     11 STATIC size_t coordinate_drslice_gendata(unsigned char *);
     12 STATIC bool is_drslice_solvable(cube_t);
     13 STATIC bool is_drslice_solved(uint64_t, const unsigned char *);
     14 
     15 STATIC coord_t coordinate_drslice = {
     16 	.name = "DRSLICE",
     17 	.coord = &coordinate_drslice_coord,
     18 	.cube = &coordinate_drslice_cube,
     19 	.isnasty = &coordinate_drslice_isnasty,
     20 	.gendata = coordinate_drslice_gendata,
     21 	.max = CLASSES_CP_16 * FACT_8,
     22 	.trans_mask = TM_UDFIX,
     23 	.moves_mask_gendata = MM18_DR,
     24 	.moves_mask_solve = MM18_DR_NOD,
     25 	.is_admissible = &solution_always_valid,
     26 	.solution_prune = NULL,
     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_merge_ce,
     58 	},
     59 };
     60 
     61 STATIC uint64_t
     62 coordinate_drslice_coord(cube_t cube, const unsigned char *data)
     63 {
     64 	return coord_coord_generic(&coordinate_drslice, cube, data);
     65 }
     66 
     67 STATIC cube_t
     68 coordinate_drslice_cube(uint64_t i, const unsigned char *data)
     69 {
     70 	return coord_cube_generic(&coordinate_drslice, i, data);
     71 }
     72 
     73 STATIC size_t
     74 coordinate_drslice_gendata(unsigned char *data)
     75 {
     76 	return coord_gendata_generic(&coordinate_drslice, data);
     77 }
     78 
     79 STATIC bool
     80 coordinate_drslice_isnasty(uint64_t i, const unsigned char *data)
     81 {
     82 	return coord_isnasty_generic(&coordinate_drslice, i, data);
     83 }
     84 
     85 STATIC bool
     86 is_drslice_solvable(cube_t cube) {
     87 	return coord_eo(cube) == 0 &&
     88 	       coord_eo(transform_edges(cube, TRANS_URr)) == 0 &&
     89 	       coord_co(cube) == 0;
     90 }
     91 
     92 STATIC bool
     93 is_drslice_solved(uint64_t i, const unsigned char *data)
     94 {
     95 	/* Pre-computed coordinates of U D' (= U' D up to trans) and U2 D2 */
     96 	return i == 0 || i == 109779816 || i == 68468527;
     97 }