aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-14 00:05:43 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-14 14:45:22 +0200
commit8a91354f7b94c669c77fe628a81f9bfe9f599ef0 (patch)
treeba29a8b0416cb3464b49fd7cfb69e7f407b892c8 /tools
parent7dbd34574f629cacf3b89292d2a06ad0ae612f26 (diff)
downloadnissy-core-8a91354f7b94c669c77fe628a81f9bfe9f599ef0.tar.gz
nissy-core-8a91354f7b94c669c77fe628a81f9bfe9f599ef0.zip
Interface changes, progress with python
Diffstat (limited to 'tools')
-rw-r--r--tools/100_checkdata/checkdata.c2
-rw-r--r--tools/200_stats_tables_h48/stats_tables_h48.c16
-rw-r--r--tools/300_solve_small/solve_small.c3
-rw-r--r--tools/nissy_extra.h5
-rw-r--r--tools/tool.h25
5 files changed, 27 insertions, 24 deletions
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c
index 2005f17..fe94427 100644
--- a/tools/100_checkdata/checkdata.c
+++ b/tools/100_checkdata/checkdata.c
@@ -5,7 +5,7 @@ char *solver, *filename;
5 5
6static void 6static void
7run(void) { 7run(void) {
8 int64_t size, result; 8 long long int size, result;
9 char *buf; 9 char *buf;
10 FILE *f; 10 FILE *f;
11 11
diff --git a/tools/200_stats_tables_h48/stats_tables_h48.c b/tools/200_stats_tables_h48/stats_tables_h48.c
index 11df137..8e80269 100644
--- a/tools/200_stats_tables_h48/stats_tables_h48.c
+++ b/tools/200_stats_tables_h48/stats_tables_h48.c
@@ -17,11 +17,11 @@ typedef struct {
17 int64_t v[12][100]; 17 int64_t v[12][100];
18} thread_arg_t; 18} thread_arg_t;
19 19
20uint64_t rand64(void) { 20uint64_t randll(void) {
21 uint64_t i, ret; 21 long long int i, ret;
22 22
23 for (i = 0, ret = 0; i < 64; i++) 23 for (i = 0, ret = 0; i < 64; i++)
24 ret |= (uint64_t)(rand() % 2) << i; 24 ret |= (long long int)(rand() % 2) << i;
25 25
26 return ret; 26 return ret;
27} 27}
@@ -30,16 +30,16 @@ static void *
30run_thread(void *arg) 30run_thread(void *arg)
31{ 31{
32 char s[12], cube[22]; 32 char s[12], cube[22];
33 int64_t ep, eo, cp, co; 33 long long int ep, eo, cp, co;
34 int i, j; 34 int i, j;
35 35
36 thread_arg_t *a = (thread_arg_t *)arg; 36 thread_arg_t *a = (thread_arg_t *)arg;
37 37
38 for (i = 0; i < a->n; i++) { 38 for (i = 0; i < a->n; i++) {
39 ep = rand64(); 39 ep = randll();
40 eo = rand64(); 40 eo = randll();
41 cp = rand64(); 41 cp = randll();
42 co = rand64(); 42 co = randll();
43 nissy_getcube(ep, eo, cp, co, "fix", cube); 43 nissy_getcube(ep, eo, cp, co, "fix", cube);
44 nissy_solve(cube, "h48stats", NISSY_NISSFLAG_NORMAL, 44 nissy_solve(cube, "h48stats", NISSY_NISSFLAG_NORMAL,
45 0, MAXMOVES, 1, -1, size, buf, 12, s); 45 0, MAXMOVES, 1, -1, size, buf, 12, s);
diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c
index 5400436..622c36e 100644
--- a/tools/300_solve_small/solve_small.c
+++ b/tools/300_solve_small/solve_small.c
@@ -23,7 +23,8 @@ void run(void) {
23 for (i = 0; scrambles[i] != NULL; i++) { 23 for (i = 0; scrambles[i] != NULL; i++) {
24 printf("%d. %s\n", i+1, scrambles[i]); 24 printf("%d. %s\n", i+1, scrambles[i]);
25 printf("Solving scramble %s\n", scrambles[i]); 25 printf("Solving scramble %s\n", scrambles[i]);
26 if (nissy_frommoves(scrambles[i], cube) == -1) { 26 if (nissy_applymoves(NISSY_SOLVED_CUBE, scrambles[i], cube)
27 == -1) {
27 printf("Invalid scramble\n"); 28 printf("Invalid scramble\n");
28 continue; 29 continue;
29 } 30 }
diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h
index fd44f2c..60f7942 100644
--- a/tools/nissy_extra.h
+++ b/tools/nissy_extra.h
@@ -10,5 +10,6 @@ for testing purposes only.
10 10
11size_t gendata_h48_derive(uint8_t, const void *, void *); 11size_t gendata_h48_derive(uint8_t, const void *, void *);
12int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); 12int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]);
13int64_t nissy_datainfo(uint64_t, const char *, void (*)(const char *, ...)); 13long long int nissy_datainfo(
14int64_t nissy_derivedata(const char *, const void *, void *); 14 uint64_t, const char *, void (*)(const char *, ...));
15long long int nissy_derivedata(const char *, const void *, void *);
diff --git a/tools/tool.h b/tools/tool.h
index 2fc0224..8fa726a 100644
--- a/tools/tool.h
+++ b/tools/tool.h
@@ -13,8 +13,9 @@ static void log_stderr(const char *, ...);
13static void log_stdout(const char *, ...); 13static void log_stdout(const char *, ...);
14static double timerun(void (*)(void)); 14static double timerun(void (*)(void));
15static void writetable(const char *, int64_t, const char *); 15static void writetable(const char *, int64_t, const char *);
16static int64_t generatetable(const char *, char **); 16static long long int generatetable(const char *, char **);
17static int64_t derivetable(const char *, const char *, const char *, char **); 17static long long int derivetable(
18 const char *, const char *, const char *, char **);
18static int getdata(const char *, char **, const char *); 19static int getdata(const char *, char **, const char *);
19static void gendata_run(const char *, uint64_t[static 21]); 20static void gendata_run(const char *, uint64_t[static 21]);
20static void derivedata_run( 21static void derivedata_run(
@@ -84,10 +85,10 @@ writetable(const char *buf, int64_t size, const char *filename)
84 } 85 }
85} 86}
86 87
87static int64_t 88static long long int
88generatetable(const char *solver, char **buf) 89generatetable(const char *solver, char **buf)
89{ 90{
90 int64_t size, gensize; 91 long long int size, gensize;
91 92
92 size = nissy_datasize(solver); 93 size = nissy_datasize(solver);
93 if (size == -1) { 94 if (size == -1) {
@@ -101,7 +102,7 @@ generatetable(const char *solver, char **buf)
101 if (gensize != size) { 102 if (gensize != size) {
102 printf("Error generating table"); 103 printf("Error generating table");
103 if (gensize != -1) 104 if (gensize != -1)
104 printf(" (got %" PRId64 " bytes)", gensize); 105 printf(" (got %lld bytes)", gensize);
105 printf("\n"); 106 printf("\n");
106 return -2; 107 return -2;
107 } 108 }
@@ -109,7 +110,7 @@ generatetable(const char *solver, char **buf)
109 return gensize; 110 return gensize;
110} 111}
111 112
112static int64_t 113static long long int
113derivetable( 114derivetable(
114 const char *solver_large, 115 const char *solver_large,
115 const char *solver_small, 116 const char *solver_small,
@@ -118,7 +119,7 @@ derivetable(
118) 119)
119{ 120{
120 uint8_t h, k; 121 uint8_t h, k;
121 int64_t size, gensize; 122 long long int size, gensize;
122 char *fulltable; 123 char *fulltable;
123 124
124 if (getdata(solver_large, &fulltable, filename_large) != 0) { 125 if (getdata(solver_large, &fulltable, filename_large) != 0) {
@@ -161,7 +162,7 @@ getdata(
161 char **buf, 162 char **buf,
162 const char *filename 163 const char *filename
163) { 164) {
164 int64_t size, sizeread; 165 long long int size, sizeread;
165 FILE *f; 166 FILE *f;
166 167
167 if ((f = fopen(filename, "rb")) == NULL) { 168 if ((f = fopen(filename, "rb")) == NULL) {
@@ -201,7 +202,7 @@ gendata_run(
201 const char *solver, 202 const char *solver,
202 uint64_t expected[static 21] 203 uint64_t expected[static 21]
203) { 204) {
204 int64_t size; 205 long long int size;
205 char *buf, filename[1024]; 206 char *buf, filename[1024];
206 207
207 sprintf(filename, "tables/%s", solver); 208 sprintf(filename, "tables/%s", solver);
@@ -214,7 +215,7 @@ gendata_run(
214 default: 215 default:
215 nissy_datainfo(size, buf, write_stdout); 216 nissy_datainfo(size, buf, write_stdout);
216 printf("\n"); 217 printf("\n");
217 printf("Succesfully generated %" PRId64 " bytes. " 218 printf("Succesfully generated %lld bytes. "
218 "See above for details on the tables.\n", size); 219 "See above for details on the tables.\n", size);
219 220
220 /* TODO: check that the table is correct */ 221 /* TODO: check that the table is correct */
@@ -234,7 +235,7 @@ derivedata_run(
234 const char *filename_small 235 const char *filename_small
235) 236)
236{ 237{
237 int64_t size; 238 long long int size;
238 char *buf; 239 char *buf;
239 240
240 buf = NULL; 241 buf = NULL;
@@ -247,7 +248,7 @@ derivedata_run(
247 default: 248 default:
248 nissy_datainfo(size, buf, write_stdout); 249 nissy_datainfo(size, buf, write_stdout);
249 printf("\n"); 250 printf("\n");
250 printf("Succesfully generated %" PRId64 " bytes. " 251 printf("Succesfully generated %lld bytes. "
251 "See above for details on the tables.\n", size); 252 "See above for details on the tables.\n", size);
252 253
253 writetable(buf, size, filename_small); 254 writetable(buf, size, filename_small);

Generated with cgit - Back to sebastiano.tronto.net