Anonymous avatar Anonymous committed 509cb37

cleanup

Comments (0)

Files changed (4)

stand_alone/2_all.c

 
 int main(void)
 {
-	char buf[128];
 	int i, j;
 
 	for (i = 0; i < 5040; i++)

stand_alone/2_solve.c

  * index  : 0   1   2   3   4   5   6   n/a
  * corners: UFR URB UBL ULF DRF DFL DLB DBR
  */
-uint8_t  cp[7], co[7];
-uint8_t  cpco_prune[5040][729];
+uint8_t  cp[7], co[7], cpco_prune[5040][729];
 uint16_t cp_trans[5040][3], co_trans[729][3];
 
 /*
  * moves are:
  * U U2 U' F F2 F' L L2 L'
  * 0 1  2  3 4  5  6 7  8
+ *
+ * faces are move / 3:
+ * U F L
+ * 0 1 2
  */
 
-uint8_t c_cycles[6][4] = {
+int c_cycles[6][4] = {
 	{ 0, 1, 2, 3 }, /* U */
 	{ 0, 3, 5, 4 }, /* F */
 	{ 2, 6, 5, 3 }, /* L */
 };
-uint8_t c_twists[6][4] = {
+int c_twists[6][4] = {
 	{ 0, 0, 0, 0 }, /* U */
 	{ 2, 1, 2, 1 }, /* F */
 	{ 1, 2, 1, 2 }, /* L */
 };
 
 /*
- * perform the permutation cycle 1 - 3 times based on move
+ * do a quarter turn on the given face
+ * perform the permutation cycle
  * perform the orientation twists on the cubies that are being cycled
  */
-void move_pieces(uint8_t *perm, uint8_t *orie, uint8_t *cycle, uint8_t *twist, int mod)
+void do_move(int face)
 {
-	uint8_t otmp, ptmp, i;
+	int otmp, ptmp, i;
 
-	ptmp = perm[cycle[0]];
-	otmp = orie[cycle[0]];
+	ptmp = cp[c_cycles[face][0]];
+	otmp = co[c_cycles[face][0]];
 	for (i = 0; i < 3; i++) {
-		orie[cycle[i]] = (orie[cycle[i + 1]] + twist[i + 1]) % mod;
-		perm[cycle[i]] =  perm[cycle[i + 1]];
+		co[c_cycles[face][i]] = (co[c_cycles[face][i + 1]] + c_twists[face][i + 1]) % 3;
+		cp[c_cycles[face][i]] =  cp[c_cycles[face][i + 1]];
 	}
-	orie[cycle[3]] = (otmp + twist[0]) % mod;
-	perm[cycle[3]] =  ptmp;
-}
-
-/*
- * perform the given move on the array cube
- */
-void do_move(int mv)
-{
-	int face = mv / 3;
-
-	for (mv = mv % 3 + 1; mv; mv--)
-		move_pieces(cp, co, c_cycles[face], c_twists[face], 3);
+	co[c_cycles[face][3]] = (otmp + c_twists[face][0]) % 3;
+	cp[c_cycles[face][3]] =  ptmp;
 }
 
 /*
 }
 
 /*
+ * generic transition table initialization
+ */
+void init_trans(uint16_t tran_table[][3], int len, void (*set_coord)(int), int (*get_coord)(void))
+{
+	int i, face;
+
+	for (i = 0; i < len; i++) {
+		for (face = 0; face < 3; face++) {
+			set_coord(i);
+			do_move(face);
+			tran_table[i][face] = get_coord();
+		}
+	}
+}
+
+/*
+ * specific transition table initializations
+ */
+void init_trans_tables(void)
+{
+	init_trans(cp_trans, 5040, set_cp_coord, get_cp_coord );
+	init_trans(co_trans,  729, set_co_coord, get_co_coord );
+}
+
+/*
  * generic pruning table initialization
  */
 void init_prune(int coordi, uint16_t trans_tablei[][3], int coordj, uint16_t trans_tablej[][3], int maxi, int maxj, uint8_t prune_table[maxi][maxj], int mdepth, int depth, int last)
 {
 	int k, face, oldi = coordi, oldj = coordj;
 
-	if (depth == mdepth || prune_table[coordi][coordj] <= depth)
+	if (depth == mdepth + 1 || prune_table[coordi][coordj] <= depth)
 		return;
 
 	prune_table[coordi][coordj] = depth;
 void init_prune_tables(void)
 {
 	memset(cpco_prune, 0xff, sizeof(cpco_prune));
-	init_prune(0, cp_trans, 0, co_trans, 5040, 729, cpco_prune, 12, 0, -1);
-}
-
-/*
- * generic transition table initialization
- */
-void init_trans(uint16_t tran_table[][3], int len, void (*set_coord)(int), int (*get_coord)(void))
-{
-	int i, face;
-
-	for (i = 0; i < len; i++) {
-		for (face = 0; face < 3; face++) {
-			set_coord(i);
-			do_move(face * 3);
-			tran_table[i][face] = get_coord();
-		}
-	}
-}
-
-/*
- * specific transition table initializations
- */
-void init_trans_tables(void)
-{
-	init_trans(cp_trans, 5040, set_cp_coord,  get_cp_coord );
-	init_trans(co_trans,  729, set_co_coord,  get_co_coord );
+	init_prune(0, cp_trans, 0, co_trans, 5040, 729, cpco_prune, 11, 0, -1);
 }
 
 void print_move(int mv)

stand_alone/multi

 #!/bin/sh
-SOLVE="./solve"
+#SOLVE="./solve"
 #SOLVE="./2_solve"
+SOLVE="../solve -n 1"
 #SOLVE="../solve -n 1 -m 20"
 
 unset pids in out

stand_alone/results.awk

 		total += NF;
 	}
 
-	if (NR % m == 0)
+	if (m > 0 && NR % m == 0)
 		printout();
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.