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


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