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

common.h (1413B)


      1 STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]);
      2 STATIC_INLINE bool equal(cube_t, cube_t);
      3 STATIC_INLINE cube_t invertco(cube_t);
      4 STATIC_INLINE cube_t compose_epcpeo(cube_t, cube_t);
      5 STATIC_INLINE cube_t compose_edges(cube_t, cube_t);
      6 STATIC_INLINE cube_t compose_corners(cube_t, cube_t);
      7 STATIC_INLINE cube_t compose(cube_t, cube_t);
      8 STATIC_INLINE cube_t inverse(cube_t);
      9 
     10 STATIC_INLINE int64_t coord_co(cube_t);
     11 STATIC_INLINE int64_t coord_csep(cube_t);
     12 STATIC_INLINE int64_t coord_cocsep(cube_t);
     13 STATIC_INLINE int64_t coord_eo(cube_t);
     14 STATIC_INLINE int64_t coord_esep(cube_t);
     15 
     16 STATIC_INLINE void copy_corners(cube_t *, cube_t);
     17 STATIC_INLINE void copy_edges(cube_t *, cube_t);
     18 STATIC_INLINE void set_eo(cube_t *, int64_t);
     19 STATIC_INLINE cube_t invcoord_esep(int64_t);
     20 
     21 STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]);
     22 
     23 STATIC_INLINE void
     24 invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12])
     25 {
     26 	int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1;
     27 	uint8_t slice[3] = {0};
     28 
     29 	for (i = 0, j = 0, k = 4, l = 4; i < 12; i++)
     30 	{
     31 		v = binomial[11 - i][k];
     32 		jj = j < 8;
     33 		w = jj * binomial[7 - (j * jj)][l];
     34 		bit2 = set2 >= v;
     35 		bit1 = set1 >= w;
     36 		is1 = (1 - bit2) * bit1;
     37 
     38 		set2 -= bit2 * v;
     39 		k -= bit2;
     40 		set1 -= is1 * w;
     41 		l -= is1;
     42 		j += (1 - bit2);
     43 		s = 2 * bit2 + (1 - bit2) * bit1;
     44 
     45 		mem[i] = (slice[s]++) | (uint8_t)(s << 2);
     46 	}
     47 }