From 8a91354f7b94c669c77fe628a81f9bfe9f599ef0 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 14 Oct 2024 00:05:43 +0200 Subject: Interface changes, progress with python --- tools/100_checkdata/checkdata.c | 2 +- tools/200_stats_tables_h48/stats_tables_h48.c | 16 ++++++++-------- tools/300_solve_small/solve_small.c | 3 ++- tools/nissy_extra.h | 5 +++-- tools/tool.h | 25 +++++++++++++------------ 5 files changed, 27 insertions(+), 24 deletions(-) (limited to 'tools') 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; static void run(void) { - int64_t size, result; + long long int size, result; char *buf; FILE *f; 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 { int64_t v[12][100]; } thread_arg_t; -uint64_t rand64(void) { - uint64_t i, ret; +uint64_t randll(void) { + long long int i, ret; for (i = 0, ret = 0; i < 64; i++) - ret |= (uint64_t)(rand() % 2) << i; + ret |= (long long int)(rand() % 2) << i; return ret; } @@ -30,16 +30,16 @@ static void * run_thread(void *arg) { char s[12], cube[22]; - int64_t ep, eo, cp, co; + long long int ep, eo, cp, co; int i, j; thread_arg_t *a = (thread_arg_t *)arg; for (i = 0; i < a->n; i++) { - ep = rand64(); - eo = rand64(); - cp = rand64(); - co = rand64(); + ep = randll(); + eo = randll(); + cp = randll(); + co = randll(); nissy_getcube(ep, eo, cp, co, "fix", cube); nissy_solve(cube, "h48stats", NISSY_NISSFLAG_NORMAL, 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) { for (i = 0; scrambles[i] != NULL; i++) { printf("%d. %s\n", i+1, scrambles[i]); printf("Solving scramble %s\n", scrambles[i]); - if (nissy_frommoves(scrambles[i], cube) == -1) { + if (nissy_applymoves(NISSY_SOLVED_CUBE, scrambles[i], cube) + == -1) { printf("Invalid scramble\n"); continue; } 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. size_t gendata_h48_derive(uint8_t, const void *, void *); int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); -int64_t nissy_datainfo(uint64_t, const char *, void (*)(const char *, ...)); -int64_t nissy_derivedata(const char *, const void *, void *); +long long int nissy_datainfo( + uint64_t, const char *, void (*)(const char *, ...)); +long 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 *, ...); static void log_stdout(const char *, ...); static double timerun(void (*)(void)); static void writetable(const char *, int64_t, const char *); -static int64_t generatetable(const char *, char **); -static int64_t derivetable(const char *, const char *, const char *, char **); +static long long int generatetable(const char *, char **); +static long long int derivetable( + const char *, const char *, const char *, char **); static int getdata(const char *, char **, const char *); static void gendata_run(const char *, uint64_t[static 21]); static void derivedata_run( @@ -84,10 +85,10 @@ writetable(const char *buf, int64_t size, const char *filename) } } -static int64_t +static long long int generatetable(const char *solver, char **buf) { - int64_t size, gensize; + long long int size, gensize; size = nissy_datasize(solver); if (size == -1) { @@ -101,7 +102,7 @@ generatetable(const char *solver, char **buf) if (gensize != size) { printf("Error generating table"); if (gensize != -1) - printf(" (got %" PRId64 " bytes)", gensize); + printf(" (got %lld bytes)", gensize); printf("\n"); return -2; } @@ -109,7 +110,7 @@ generatetable(const char *solver, char **buf) return gensize; } -static int64_t +static long long int derivetable( const char *solver_large, const char *solver_small, @@ -118,7 +119,7 @@ derivetable( ) { uint8_t h, k; - int64_t size, gensize; + long long int size, gensize; char *fulltable; if (getdata(solver_large, &fulltable, filename_large) != 0) { @@ -161,7 +162,7 @@ getdata( char **buf, const char *filename ) { - int64_t size, sizeread; + long long int size, sizeread; FILE *f; if ((f = fopen(filename, "rb")) == NULL) { @@ -201,7 +202,7 @@ gendata_run( const char *solver, uint64_t expected[static 21] ) { - int64_t size; + long long int size; char *buf, filename[1024]; sprintf(filename, "tables/%s", solver); @@ -214,7 +215,7 @@ gendata_run( default: nissy_datainfo(size, buf, write_stdout); printf("\n"); - printf("Succesfully generated %" PRId64 " bytes. " + printf("Succesfully generated %lld bytes. " "See above for details on the tables.\n", size); /* TODO: check that the table is correct */ @@ -234,7 +235,7 @@ derivedata_run( const char *filename_small ) { - int64_t size; + long long int size; char *buf; buf = NULL; @@ -247,7 +248,7 @@ derivedata_run( default: nissy_datainfo(size, buf, write_stdout); printf("\n"); - printf("Succesfully generated %" PRId64 " bytes. " + printf("Succesfully generated %lld bytes. " "See above for details on the tables.\n", size); writetable(buf, size, filename_small); -- cgit v1.3