clementgallet/FiveStage444 — Issue #1: create lookup table instead of formulas
Author: ChenShuang
Created: 2011-12-25 06:03:27+00:00
State: open

((cube2.get_dist_edgcen() - (distEdgCen%3) + 4) % 3 ) + distEdgCen - 1; // TODO: Could make a better formula...
return (prune_table_edgcen[idx>>2] >> ((idx & 0x3) << 1)) & 0x3;

As lookup table is always faster than "%" operations,
the first line can be replaced by:
int[][] GetPrun = new int[MAXDEPTH][3]
GetPrun[currentdist][get_dist()];
the second line can be replaced by:
return UPack[prune_table_edgecen[idx>>2]][idx&0x3];
int[][] UPack = new int[256][4], whilch UPack[i][j] = i >> ((j & 0x3) << 1)) & 0x3 // for 4 entrance in one byte, and it can contains 5 entrance in one byte as 3^5 < 2^8, as Kociemba's Cube Explorer and my 4x4x4 solver(edge12.java) did.