h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

eo.h (1352B)


      1 STATIC uint64_t coordinate_eo_coord(cube_t, const unsigned char *);
      2 STATIC cube_t coordinate_eo_cube(uint64_t, const unsigned char *);
      3 STATIC bool coordinate_eo_isnasty(uint64_t, const unsigned char *);
      4 STATIC size_t coordinate_eo_gendata(unsigned char *);
      5 STATIC bool is_eo_even(cube_t);
      6 
      7 STATIC coord_t coordinate_eo = {
      8 	.name = "EO",
      9 	.coord = &coordinate_eo_coord,
     10 	.cube = &coordinate_eo_cube,
     11 	.isnasty = &coordinate_eo_isnasty,
     12 	.gendata = coordinate_eo_gendata,
     13 	.max = POW_2_11,
     14 	.trans_mask = TM_SINGLE(TRANS_UFr),
     15 	.moves_mask = MM_ALLMOVES,
     16 	.axistrans = {
     17 		[AXIS_UD] = TRANS_FDr,
     18 		[AXIS_RL] = TRANS_URr,
     19 		[AXIS_FB] = TRANS_UFr,
     20 	},
     21 	.is_admissible = &solution_lastqt_cw,
     22 	.is_solvable = &is_eo_even,
     23 	.sym = {0},
     24 };
     25 
     26 STATIC uint64_t
     27 coordinate_eo_coord(cube_t c, const unsigned char *data)
     28 {
     29 	return (uint64_t)coord_eo(c);
     30 }
     31 
     32 STATIC cube_t
     33 coordinate_eo_cube(uint64_t c, const unsigned char *data)
     34 {
     35 	cube_t cube = SOLVED_CUBE;
     36 	set_eo(&cube, (int64_t)c);
     37 	return cube;
     38 }
     39 
     40 STATIC bool
     41 coordinate_eo_isnasty(uint64_t c, const unsigned char *data)
     42 {
     43 	return false;
     44 }
     45 
     46 STATIC size_t
     47 coordinate_eo_gendata(unsigned char *data)
     48 {
     49 	return 0;
     50 }
     51 
     52 STATIC bool
     53 is_eo_even(cube_t cube)
     54 {
     55 	uint8_t c[8], e[12], i, count;
     56 
     57 	pieces(&cube, c, e);
     58 
     59 	for (i = 0, count = 0; i < 12; i++)
     60 		count += (e[i] & EOBIT) >> EOSHIFT;
     61 
     62 	return count % 2 == 0;
     63 }