aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2022-10-28 08:01:01 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2022-10-28 08:01:01 +0200
commit1ac26de8dcb76323a5f96eab200a027236cb55d0 (patch)
treeccc1e9e6b13868b9cb485c1386fe00a4110ee829
parent4da48094d65b4269be7a4d7d2dc9c7d72f2e6869 (diff)
downloadnissy-1ac26de8dcb76323a5f96eab200a027236cb55d0.tar.gz
nissy-1ac26de8dcb76323a5f96eab200a027236cb55d0.zip
Quick push warning message
-rw-r--r--README.md7
-rw-r--r--TODO.md6
-rw-r--r--src/cubetypes.h1
-rw-r--r--src/fst.c1
-rw-r--r--tests/test_fst.c159
5 files changed, 136 insertions, 38 deletions
diff --git a/README.md b/README.md
index 2d83f0c..8aa6a2d 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,10 @@
1# WARNING
2
3I am currently rewriting some important parts of the code
4and the git version is not working.
5You can download the last stable version from the
6[download page](https://nissy.tronto.net/download).
7
1# Nissy 8# Nissy
2 9
3A Rubik's cube solver and FMC assistant. 10A Rubik's cube solver and FMC assistant.
diff --git a/TODO.md b/TODO.md
index d0281d3..a149c2f 100644
--- a/TODO.md
+++ b/TODO.md
@@ -9,7 +9,11 @@ It's more of a personal reminder than anything else.
9 of the files includes + doing more stuff. A static "initiliazed" 9 of the files includes + doing more stuff. A static "initiliazed"
10 variable is probably needed too. 10 variable is probably needed too.
11### testing! 11### testing!
12* test fst and other things... 12* test fst: implement fst_consistent
13* test fst: init_fst is necessary before testing move and inverse
14* separate "commands" for testing different parts (e.g. ./test coord)
15* test coordinate (needed anyway to test fst)
16* other tests (start from bottom: utils.c)
13* move test_coord to the testing folder 17* move test_coord to the testing folder
14### Solving standard coordinates 18### Solving standard coordinates
15* add Void * extradata to DfsArg and a custom move function 19* add Void * extradata to DfsArg and a custom move function
diff --git a/src/cubetypes.h b/src/cubetypes.h
index d4fa241..565dddb 100644
--- a/src/cubetypes.h
+++ b/src/cubetypes.h
@@ -103,6 +103,7 @@ typedef struct threaddatagenpt ThreadDataGenpt;
103typedef struct transgroup TransGroup; 103typedef struct transgroup TransGroup;
104 104
105typedef bool (*Checker) (Cube *); 105typedef bool (*Checker) (Cube *);
106typedef bool (*CubeTester) (Cube *, Alg *);
106typedef bool (*DfsMover) (DfsArg *); 107typedef bool (*DfsMover) (DfsArg *);
107typedef void (*DfsExtraCopier) (void *, void *); 108typedef void (*DfsExtraCopier) (void *, void *);
108typedef bool (*Validator) (Alg *); 109typedef bool (*Validator) (Alg *);
diff --git a/src/fst.c b/src/fst.c
index 2aa6219..aa9e41e 100644
--- a/src/fst.c
+++ b/src/fst.c
@@ -43,6 +43,7 @@ cube_to_fst(Cube *cube)
43 ret.fr_eofb = coord_eofb.i[0]->index(&c); 43 ret.fr_eofb = coord_eofb.i[0]->index(&c);
44 ret.fr_eposepe = coord_eposepe.i[0]->index(&c); 44 ret.fr_eposepe = coord_eposepe.i[0]->index(&c);
45 ret.fr_coud = coord_coud.i[0]->index(&c); 45 ret.fr_coud = coord_coud.i[0]->index(&c);
46 copy_cube(cube, &c);
46 apply_trans(rd, &c); 47 apply_trans(rd, &c);
47 ret.rd_eofb = coord_eofb.i[0]->index(&c); 48 ret.rd_eofb = coord_eofb.i[0]->index(&c);
48 ret.rd_eposepe = coord_eposepe.i[0]->index(&c); 49 ret.rd_eposepe = coord_eposepe.i[0]->index(&c);
diff --git a/tests/test_fst.c b/tests/test_fst.c
index 5f48f6c..ad1caba 100644
--- a/tests/test_fst.c
+++ b/tests/test_fst.c
@@ -1,24 +1,62 @@
1#include "inc.h" 1#include "inc.h"
2#include "../src/fst.h" 2#include "../src/fst.h"
3 3
4static bool test_cube_to_fst_to_cube(Cube *c); 4static bool cube_to_fst_to_cube(Cube *c, Alg *a);
5static bool fst_consistent(Cube *c, Alg *a);
6static bool fst_move_test(Cube *c, Alg *a);
7static bool fst_inverse_test(Cube *c, Alg *a);
8static bool try_str(CubeTester f, char *algstr, char *msg);
9static bool try_all_str(CubeTester f, char *msg);
5 10
6static bool test_cube_to_fst_to_cube_solved(); 11static bool test_fst_consistent_algs();
7static bool test_cube_to_fst_to_cube_unsolved(); 12static bool test_cube_to_fst_to_cube_algs();
13static bool test_fst_move_algs();
14static bool test_fst_inverse_algs();
8 15
9static Tester test[] = { 16static Tester test[] = {
10 test_cube_to_fst_to_cube_solved, 17 test_fst_consistent_algs,
11 test_cube_to_fst_to_cube_unsolved, 18 test_cube_to_fst_to_cube_algs,
19 test_fst_move_algs,
20 test_fst_inverse_algs,
12 NULL 21 NULL
13}; 22};
14 23
15static char *name[] = { 24static char *name[] = {
16 "Cube to FST to cube (solved)", 25 "Consistency of FST (converted from cube)",
17 "Cube to FST to cube (unsolved)", 26 "Cube to FST to cube",
27 "FST move",
28 "FST inverse",
18}; 29};
19 30
31static char *algs[] = {
32 "",
33 "U", "U2", "U'", "D", "D2", "D'", "R", "R2", "R'",
34 "L", "L2", "L'", "F", "F2", "F'", "B", "B2", "B'",
35 "U2 R2 U2 R2 U2",
36 "U2 F2 R2 B2 U2 D2 F2 L2 B2",
37 "RUR'URU2R'",
38 "L2 D R U2 B2 L",
39 "R'U'F",
40 "F2 U' R2 D' B2 D2 R2 D2 R2 U' F L' U' R B F2 R B' D2",
41 "D L2 F2 R2 D R2 U L2 U' B2 D L' F2 U2 B' L D' U' R' B2 F2",
42 "F' L2 F' D' R F2 L U L' D2 R2 F2 D2 R2 B' L2 B2 U2 F D2 B",
43 NULL,
44};
45
46static bool
47fst_consistent(Cube *c, Alg *a)
48{
49 FstCube fst;
50
51 fst = cube_to_fst(c);
52
53 /* TODO: check consistency of fr_* and rd_* with uf_* */
54
55 return true;
56}
57
20static bool 58static bool
21test_cube_to_fst_to_cube(Cube *c) 59cube_to_fst_to_cube(Cube *c, Alg *a)
22{ 60{
23 Cube d; 61 Cube d;
24 FstCube fst; 62 FstCube fst;
@@ -40,46 +78,93 @@ test_cube_to_fst_to_cube(Cube *c)
40} 78}
41 79
42static bool 80static bool
43test_cube_to_fst_to_cube_solved() 81fst_move_test(Cube *c, Alg *a)
82{
83 int i;
84 Cube d;
85 FstCube fst;
86
87 fst = cube_to_fst(c);
88
89 for (i = 0; i < a->len; i++) {
90 if (a->inv[i] || a->move[i] > B3) {
91 printf("Cannot apply the following alg to FST: ");
92 print_alg(a, false);
93 return false;
94 }
95 fst = fst_move(a->move[i], fst);
96 }
97
98 fst_to_cube(fst, &d);
99
100 return equal(c, &d);
101}
102
103static bool
104fst_inverse_test(Cube *c, Alg *a)
44{ 105{
106 Cube d;
107
108 fst_to_cube(fst_inverse(cube_to_fst(c)), &d);
109 invert_cube(c);
110
111 return equal(c, &d);
112}
113
114static bool
115try_str(CubeTester f, char *algstr, char *msg)
116{
117 bool b;
118 Alg *a;
45 Cube c; 119 Cube c;
46 120
121 a = new_alg(algstr);
47 make_solved(&c); 122 make_solved(&c);
48 return test_cube_to_fst_to_cube(&c); 123 apply_alg(a, &c);
124
125 if (!(b = f(&c, a)))
126 printf("%s with alg %s\n", msg, algstr);
127
128 free_alg(a);
129
130 return b;
49} 131}
50 132
51static bool 133static bool
52test_cube_to_fst_to_cube_unsolved() 134try_all_str(CubeTester f, char *msg)
53{ 135{
54 bool b; 136 bool b;
55 int i; 137 int i;
56 Alg *a;
57 Cube c;
58 char *algs[] = {
59 "U2 R2 U2 R2 U2",
60 "U2 F2 R2 B2 U2 D2 F2 L2 B2",
61 "RUR'URU2R'",
62 "L2 D R U2 B2 L",
63 "R'U'F",
64 "F2 U' R2 D' B2 D2 R2 D2 R2 U' F L' U' R B F2 R B' D2",
65 "D L2 F2 R2 D R2 U L2 U' B2 D L' F2 U2 B' L D' U' R' B2 F2",
66 "F' L2 F' D' R F2 L U L' D2 R2 F2 D2 R2 B' L2 B2 U2 F D2 B",
67 NULL,
68 };
69 138
70 for (i = 0; algs[i] != NULL; i++) { 139 b = true;
71 make_solved(&c); 140 for (i = 0; algs[i] != NULL; i++)
72 a = new_alg(algs[i]); 141 b = b && try_str(f, algs[i], msg);
73 apply_alg(a, &c); 142
74 b = test_cube_to_fst_to_cube(&c); 143 return b;
75 free_alg(a); 144}
76 if (!b) { 145
77 printf("Cube to FST to cube failed with alg %s\n", 146static bool
78 algs[i]); 147test_cube_to_fst_to_cube_algs()
79 return false; 148{
80 } 149 return try_all_str(cube_to_fst_to_cube, "Cube to FST to cube failed");
81 } 150}
82 return true; 151
152static bool
153test_fst_consistent_algs()
154{
155 return try_all_str(fst_consistent, "FST from cube not consistent");
156}
157
158static bool
159test_fst_move_algs()
160{
161 return try_all_str(fst_move_test, "FST move incorrect");
162}
163
164static bool
165test_fst_inverse_algs()
166{
167 return try_all_str(fst_inverse_test, "FST test incorrect");
83} 168}
84 169
85void test_fst_all() { 170void test_fst_all() {

Generated with cgit - Back to sebastiano.tronto.net