aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-07-14 21:28:37 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-07-14 21:28:37 +0200
commit61e03f9f4eecf3d5811b11c44c9ef778f0a93bc7 (patch)
treea7a6edc2e44689ed62472bdece1d9bf6a300419f
parenta016aa7f78c86c59bab3ae4970f8cc339186bc91 (diff)
downloadnissy-core-61e03f9f4eecf3d5811b11c44c9ef778f0a93bc7.tar.gz
nissy-core-61e03f9f4eecf3d5811b11c44c9ef778f0a93bc7.zip
Found a sneaky bug (it's all a mess now)
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--TODO.txt9
-rw-r--r--src/solve_h48.h40
-rw-r--r--test/101_cocsep_transform_invariant/00_solved.in1
-rw-r--r--test/101_cocsep_transform_invariant/00_solved.out (renamed from test/103_gendata_h48_h0/00_h_0.in)0
-rw-r--r--test/101_cocsep_transform_invariant/01_U.in1
-rw-r--r--test/101_cocsep_transform_invariant/01_U.out0
-rw-r--r--test/101_cocsep_transform_invariant/02_scrambled.in1
-rw-r--r--test/101_cocsep_transform_invariant/02_scrambled.out0
-rw-r--r--test/101_cocsep_transform_invariant/cocsep_transform_invariant.c33
-rw-r--r--test/102_cocsep_selfsim/00_all.in (renamed from test/101_cocsep_selfsim/00_all.in)0
-rw-r--r--test/102_cocsep_selfsim/00_all.out (renamed from test/101_cocsep_selfsim/00_all.out)0
-rw-r--r--test/102_cocsep_selfsim/cocsep_selfsim_tests.c (renamed from test/101_cocsep_selfsim/cocsep_selfsim_tests.c)2
-rw-r--r--test/103_cocsep_ttrep/00_all.in0
-rw-r--r--test/103_cocsep_ttrep/00_all.out0
-rw-r--r--test/103_cocsep_ttrep/cocsep_ttrep_tests.c33
-rw-r--r--test/110_coord_invcoord_h48/00_all.in (renamed from test/102_coord_invcoord_h48/00_all.in)0
-rw-r--r--test/110_coord_invcoord_h48/00_all.out (renamed from test/102_coord_invcoord_h48/00_all.out)0
-rw-r--r--test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c (renamed from test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c)0
-rw-r--r--test/111_gendata_h48_h0/00_h_0.in0
-rw-r--r--test/111_gendata_h48_h0/00_h_0.out (renamed from test/103_gendata_h48_h0/00_h_0.out)0
-rw-r--r--test/111_gendata_h48_h0/gendata_h48_tests.c (renamed from test/103_gendata_h48_h0/gendata_h48_tests.c)0
-rw-r--r--test/112_h48set/00_small.in (renamed from test/104_h48set/00_small.in)0
-rw-r--r--test/112_h48set/00_small.out (renamed from test/104_h48set/00_small.out)0
-rw-r--r--test/112_h48set/01_large.in (renamed from test/104_h48set/01_large.in)0
-rw-r--r--test/112_h48set/01_large.out (renamed from test/104_h48set/01_large.out)0
-rw-r--r--test/112_h48set/h48set_tests.c (renamed from test/104_h48set/h48set_tests.c)0
27 files changed, 111 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 8ff5f47..5130940 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ clean:
15 rm -rf *.o run 15 rm -rf *.o run
16 16
17test: debugcube.o 17test: debugcube.o
18 CC="${CC} ${DBGFLAGS}" ./test/test.sh 18 CC="${CC} -D${CUBETYPE} ${DBGFLAGS}" ./test/test.sh
19 19
20tool: cube.o 20tool: cube.o
21 mkdir -p tools/results 21 mkdir -p tools/results
diff --git a/TODO.txt b/TODO.txt
index 46c1656..6ca924a 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,3 +1,12 @@
1Bug in cocsepdata
2 - Add tests for ttrep
3 - check that ttrep indeed brings to representative
4 - Fix?
5 - Once fixed, fix other tests
6 - maybe add longtest, e.g. as a tool?
7 - Clean up mixed bfs fromdone / fromnew, use as new for h0k4
8 - Re-do stats
9
1Check stats for all tables using H48stats solver 10Check stats for all tables using H48stats solver
2 - try DFS for h0 solver 11 - try DFS for h0 solver
3 - compare results, the bfs method could be wrong 12 - compare results, the bfs method could be wrong
diff --git a/src/solve_h48.h b/src/solve_h48.h
index 26cbc73..c3316e1 100644
--- a/src/solve_h48.h
+++ b/src/solve_h48.h
@@ -244,7 +244,7 @@ invcoord_h48(int64_t i, const cube_t *crep, uint8_t h)
244/* 244/*
245Each element of the cocsep table is a uint32_t used as follows: 245Each element of the cocsep table is a uint32_t used as follows:
246 - Lowest 8-bit block: pruning value 246 - Lowest 8-bit block: pruning value
247 - Second-lower 8-bit block: "ttrep" (transformation to representative) 247 - Second-lowest 8-bit block: "ttrep" (transformation to representative)
248 - Top 16-bit block: symcoord value 248 - Top 16-bit block: symcoord value
249After the data as described above, more auxiliary information is appended: 249After the data as described above, more auxiliary information is appended:
250 - A uint32_t representing the number of symmetry classes 250 - A uint32_t representing the number of symmetry classes
@@ -331,7 +331,7 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg)
331 if (arg->selfsim != NULL) 331 if (arg->selfsim != NULL)
332 arg->selfsim[*arg->n] |= is << t; 332 arg->selfsim[*arg->n] |= is << t;
333 set_visited(arg->visited, j); 333 set_visited(arg->visited, j);
334 tinv = inverse_trans(t); 334 tinv = inverse_trans(t) * (1-is);
335 olddepth = (uint8_t)(arg->buf32[j] & 0xFF); 335 olddepth = (uint8_t)(arg->buf32[j] & 0xFF);
336 cc += olddepth == 0xFF; 336 cc += olddepth == 0xFF;
337 337
@@ -425,13 +425,12 @@ gendata_h48h0k4_bfs(bfsarg_esep_t *arg)
425TODO: the new method gives a slightly different answer. If the new 425TODO: the new method gives a slightly different answer. If the new
426method is correct, then the old bfs method is wrong. Which one is it? 426method is correct, then the old bfs method is wrong. Which one is it?
427Try also DFS and compare results (it could be faster). 427Try also DFS and compare results (it could be faster).
428/* 428*/
429 if (2 * arg->done < (int64_t)ESEP_MAX(0)) 429 if (2 * arg->done < (int64_t)ESEP_MAX(0))
430 return gendata_h48h0k4_bfs_fromdone(arg); 430 return gendata_h48h0k4_bfs_fromdone(arg);
431 else 431 else
432 return gendata_h48h0k4_bfs_fromnew(arg); 432 return gendata_h48h0k4_bfs_fromnew(arg);
433*/ 433// return gendata_h48h0k4_bfs_fromnew(arg);
434 return gendata_h48h0k4_bfs_fromdone(arg);
435} 434}
436 435
437_static int64_t 436_static int64_t
@@ -439,7 +438,8 @@ gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *arg)
439{ 438{
440 uint8_t c, m, x; 439 uint8_t c, m, x;
441 uint32_t cc; 440 uint32_t cc;
442 int64_t i, j, k, t, cocsep_coord, sim; 441 int64_t i, j, k, t, cocsep_coord;
442 uint64_t sim;
443 cube_t cube, moved, transd; 443 cube_t cube, moved, transd;
444 444
445 for (i = 0, cc = 0; i < (int64_t)ESEP_MAX(0); i++) { 445 for (i = 0, cc = 0; i < (int64_t)ESEP_MAX(0); i++) {
@@ -461,10 +461,29 @@ gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *arg)
461 set_esep_pval(arg->buf32, j, arg->depth); 461 set_esep_pval(arg->buf32, j, arg->depth);
462 cc += x != arg->depth; 462 cc += x != arg->depth;
463 cocsep_coord = j / H48_ESIZE(0); 463 cocsep_coord = j / H48_ESIZE(0);
464 sim = arg->selfsim[cocsep_coord] >> 1; 464 sim = arg->selfsim[cocsep_coord] >> UINT64_C(1);
465 for (t = 1; t < 48 && sim; t++, sim >>= 1) { 465 for (t = 1; t < 48 && sim; t++, sim >>= UINT64_C(1)) {
466 if (!(sim & 1)) 466 if (!(sim & UINT64_C(1))) {
467 transd = transform(moved, t);
468 k = coord_h48(transd, arg->cocsepdata, 0);
469 if (k != j) {
470LOG("t=%" PRId64 ", tinv=%" PRIu8 "\n", t, inverse_trans(t));
471int64_t ccm = coord_cocsep(moved);
472int64_t repm = coord_cocsep(arg->crep[j/H48_ESIZE(0)]);
473LOG("moved: full %" PRId64 ", cocsep %" PRId64 ", rep %" PRId64 ", ttrep %" PRId32 "\n", j, ccm, repm, TTREP(arg->cocsepdata[ccm]));
474int64_t cct = coord_cocsep(transd);
475int64_t rept = coord_cocsep(arg->crep[k/H48_ESIZE(0)]);
476LOG("moved: full %" PRId64 ", cocsep %" PRId64 ", rep %" PRId64 ", ttrep %" PRId32 "\n", j, cct, rept, TTREP(arg->cocsepdata[cct]));
477/*
478 char q[150];
479 writecube_H48(moved, q);
480 LOG("%s\n", q)
481 writecube_H48(transd, q);
482 LOG("%s\n", q)
483*/
484 }
467 continue; 485 continue;
486 }
468 transd = transform(moved, t); 487 transd = transform(moved, t);
469 k = coord_h48(transd, arg->cocsepdata, 0); 488 k = coord_h48(transd, arg->cocsepdata, 0);
470 x = get_esep_pval(arg->buf32, k); 489 x = get_esep_pval(arg->buf32, k);
@@ -497,7 +516,10 @@ gendata_h48h0k4_bfs_fromnew(bfsarg_esep_t *arg)
497 j = coord_h48(moved, arg->cocsepdata, 0); 516 j = coord_h48(moved, arg->cocsepdata, 0);
498 x = get_esep_pval(arg->buf32, j); 517 x = get_esep_pval(arg->buf32, j);
499 if (x < arg->depth) 518 if (x < arg->depth)
519{
520if (x < arg->depth -1) LOG("WAT %" PRIu8 " while scanning %" PRIu8 "\n",x, arg->depth);
500 goto neighbor_found; 521 goto neighbor_found;
522}
501 } 523 }
502 continue; 524 continue;
503neighbor_found: 525neighbor_found:
diff --git a/test/101_cocsep_transform_invariant/00_solved.in b/test/101_cocsep_transform_invariant/00_solved.in
new file mode 100644
index 0000000..dff224d
--- /dev/null
+++ b/test/101_cocsep_transform_invariant/00_solved.in
@@ -0,0 +1 @@
UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
diff --git a/test/103_gendata_h48_h0/00_h_0.in b/test/101_cocsep_transform_invariant/00_solved.out
index e69de29..e69de29 100644
--- a/test/103_gendata_h48_h0/00_h_0.in
+++ b/test/101_cocsep_transform_invariant/00_solved.out
diff --git a/test/101_cocsep_transform_invariant/01_U.in b/test/101_cocsep_transform_invariant/01_U.in
new file mode 100644
index 0000000..b5b36ad
--- /dev/null
+++ b/test/101_cocsep_transform_invariant/01_U.in
@@ -0,0 +1 @@
UR0 UL0 DB0 DF0 UB0 UF0 DL0 DR0 FR0 FL0 BL0 BR0 UBR0 UFL0 DFL0 DBR0 UFR0 UBL0 DFR0 DBL0
diff --git a/test/101_cocsep_transform_invariant/01_U.out b/test/101_cocsep_transform_invariant/01_U.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/101_cocsep_transform_invariant/01_U.out
diff --git a/test/101_cocsep_transform_invariant/02_scrambled.in b/test/101_cocsep_transform_invariant/02_scrambled.in
new file mode 100644
index 0000000..f6e1f48
--- /dev/null
+++ b/test/101_cocsep_transform_invariant/02_scrambled.in
@@ -0,0 +1 @@
DL1 BR0 DR0 UR1 DF0 FL1 BL0 UL0 FR0 UF0 DB1 UB0 UFR0 DBL1 DBR0 UFL1 DFR1 DFL1 UBL2 UBR0
diff --git a/test/101_cocsep_transform_invariant/02_scrambled.out b/test/101_cocsep_transform_invariant/02_scrambled.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/101_cocsep_transform_invariant/02_scrambled.out
diff --git a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
new file mode 100644
index 0000000..b0286e5
--- /dev/null
+++ b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
@@ -0,0 +1,33 @@
1#include "../test.h"
2
3#define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16))
4#define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16))
5
6#define COCSEP_CLASSES 3393
7
8size_t gendata_cocsep(void *, uint64_t *, cube_t *);
9cube_t transform(cube_t, uint8_t);
10int64_t coord_cocsep(cube_t);
11
12void run(void) {
13 uint8_t t;
14 uint32_t buf[300000];
15 uint64_t selfsim[COCSEP_CLASSES];
16 int64_t coord, tcoord;
17 char str[STRLENMAX];
18 cube_t cube, transd, rep[COCSEP_CLASSES];
19
20 fgets(str, STRLENMAX, stdin);
21 cube = readcube("H48", str);
22
23 gendata_cocsep(buf, selfsim, rep);
24
25 coord = (int64_t)COCLASS(buf[coord_cocsep(cube)]);
26 for (t = 0; t < 48; t++) {
27 transd = transform(cube, t);
28 tcoord = (int64_t)COCLASS(buf[coord_cocsep(transd)]);
29 if (coord != tcoord)
30 printf("Error: expected %" PRId64
31 " but got %" PRId64 "\n", coord, tcoord);
32 }
33}
diff --git a/test/101_cocsep_selfsim/00_all.in b/test/102_cocsep_selfsim/00_all.in
index 07bda04..07bda04 100644
--- a/test/101_cocsep_selfsim/00_all.in
+++ b/test/102_cocsep_selfsim/00_all.in
diff --git a/test/101_cocsep_selfsim/00_all.out b/test/102_cocsep_selfsim/00_all.out
index cc96363..cc96363 100644
--- a/test/101_cocsep_selfsim/00_all.out
+++ b/test/102_cocsep_selfsim/00_all.out
diff --git a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
index 9d9a8b2..7211e2e 100644
--- a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c
+++ b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
@@ -3,7 +3,7 @@
3 * and the cube that is one quarter-turn-move off (all such cases are 3 * and the cube that is one quarter-turn-move off (all such cases are
4 * equivalent due to symmetry). Adding more tests requires figuring out 4 * equivalent due to symmetry). Adding more tests requires figuring out
5 * by hand which one is the first position in its class to be reached. 5 * by hand which one is the first position in its class to be reached.
6 * Note that the .out file need a space before each newline. 6 * Note that the .out files need a space before each newline.
7 */ 7 */
8#include "../test.h" 8#include "../test.h"
9 9
diff --git a/test/103_cocsep_ttrep/00_all.in b/test/103_cocsep_ttrep/00_all.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/103_cocsep_ttrep/00_all.in
diff --git a/test/103_cocsep_ttrep/00_all.out b/test/103_cocsep_ttrep/00_all.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/103_cocsep_ttrep/00_all.out
diff --git a/test/103_cocsep_ttrep/cocsep_ttrep_tests.c b/test/103_cocsep_ttrep/cocsep_ttrep_tests.c
new file mode 100644
index 0000000..78f8014
--- /dev/null
+++ b/test/103_cocsep_ttrep/cocsep_ttrep_tests.c
@@ -0,0 +1,33 @@
1#include "../test.h"
2
3#define COCSEP_CLASSES 3393
4
5uint8_t inverse_trans(uint8_t);
6cube_t transform_corners(cube_t);
7int64_t coord_cocsep(cube_t);
8size_t gendata_cocsep(void *, uint64_t *, cube_t *);
9
10void run(void) {
11 uint8_t t, tinv;
12 uint32_t buf[300000], tt;
13 uint64_t selfsim[COCSEP_CLASSES];
14 int64_t i, j;
15 cube_t rep[COCSEP_CLASSES], c, d;
16
17 gendata_cocsep(buf, selfsim, rep);
18
19 for (i = 0; i < COCSEP_CLASSES; i++) {
20 c = rep[i];
21 for (t = 0; t < 48; t++) {
22 tinv = inverse_trans(t);
23 d = transform_corners(c);
24 j = coord_cocsep(d);
25 tt = (buf[j] & (0xFF << 8)) >> 8;
26 if (tt != tinv)
27 printf("cocsep %" PRId64 " <- %" PRId64 ": "
28 "expected t %" PRIu8 " (inverse of %"
29 PRIu8 "), got %" PRIu32 "\n",
30 i, j, tinv, t, tt);
31 }
32 }
33}
diff --git a/test/102_coord_invcoord_h48/00_all.in b/test/110_coord_invcoord_h48/00_all.in
index a2f9540..a2f9540 100644
--- a/test/102_coord_invcoord_h48/00_all.in
+++ b/test/110_coord_invcoord_h48/00_all.in
diff --git a/test/102_coord_invcoord_h48/00_all.out b/test/110_coord_invcoord_h48/00_all.out
index e84be4b..e84be4b 100644
--- a/test/102_coord_invcoord_h48/00_all.out
+++ b/test/110_coord_invcoord_h48/00_all.out
diff --git a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
index 77dea81..77dea81 100644
--- a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c
+++ b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
diff --git a/test/111_gendata_h48_h0/00_h_0.in b/test/111_gendata_h48_h0/00_h_0.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/111_gendata_h48_h0/00_h_0.in
diff --git a/test/103_gendata_h48_h0/00_h_0.out b/test/111_gendata_h48_h0/00_h_0.out
index cc5cf9b..cc5cf9b 100644
--- a/test/103_gendata_h48_h0/00_h_0.out
+++ b/test/111_gendata_h48_h0/00_h_0.out
diff --git a/test/103_gendata_h48_h0/gendata_h48_tests.c b/test/111_gendata_h48_h0/gendata_h48_tests.c
index e9de3c0..e9de3c0 100644
--- a/test/103_gendata_h48_h0/gendata_h48_tests.c
+++ b/test/111_gendata_h48_h0/gendata_h48_tests.c
diff --git a/test/104_h48set/00_small.in b/test/112_h48set/00_small.in
index d788d5b..d788d5b 100644
--- a/test/104_h48set/00_small.in
+++ b/test/112_h48set/00_small.in
diff --git a/test/104_h48set/00_small.out b/test/112_h48set/00_small.out
index 29c08e5..29c08e5 100644
--- a/test/104_h48set/00_small.out
+++ b/test/112_h48set/00_small.out
diff --git a/test/104_h48set/01_large.in b/test/112_h48set/01_large.in
index a70ef9a..a70ef9a 100644
--- a/test/104_h48set/01_large.in
+++ b/test/112_h48set/01_large.in
diff --git a/test/104_h48set/01_large.out b/test/112_h48set/01_large.out
index 6632336..6632336 100644
--- a/test/104_h48set/01_large.out
+++ b/test/112_h48set/01_large.out
diff --git a/test/104_h48set/h48set_tests.c b/test/112_h48set/h48set_tests.c
index d9310a9..d9310a9 100644
--- a/test/104_h48set/h48set_tests.c
+++ b/test/112_h48set/h48set_tests.c

Generated with cgit - Back to sebastiano.tronto.net