From 719080e6a88c4e17ba33a8dfec817e2d89ee666e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 15 Jan 2022 19:16:34 +0100 Subject: Added one adhoc test (cornerhtr from CO) --- adhoc/README | 3 ++ adhoc/compile.sh | 15 ++++++ adhoc/cornersdrhtr.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ adhoc/run | Bin 0 -> 322392 bytes 4 files changed, 146 insertions(+) create mode 100644 adhoc/README create mode 100755 adhoc/compile.sh create mode 100644 adhoc/cornersdrhtr.c create mode 100755 adhoc/run (limited to 'adhoc') diff --git a/adhoc/README b/adhoc/README new file mode 100644 index 0000000..8f72c6e --- /dev/null +++ b/adhoc/README @@ -0,0 +1,3 @@ +This folder contains some ad-hoc code that is not included in the main nissy +program. You probably don't need it, but it may be worth looking into if you +are trying to extend nissy by writing your own steps or other functions. diff --git a/adhoc/compile.sh b/adhoc/compile.sh new file mode 100755 index 0000000..aa541c7 --- /dev/null +++ b/adhoc/compile.sh @@ -0,0 +1,15 @@ +#/!bin/sh + +mkdir build +cd build +cp -R ../../src ./ +rm src/shell.c +cp ../$1 src/ +cp ../../Makefile ./ +make +cp nissy ../run +rm src/* +rmdir src +rm * +cd .. +rmdir build diff --git a/adhoc/cornersdrhtr.c b/adhoc/cornersdrhtr.c new file mode 100644 index 0000000..2a5a6e6 --- /dev/null +++ b/adhoc/cornersdrhtr.c @@ -0,0 +1,128 @@ +#include "commands.h" + +/* Some of the following functions are new, some are copied from steps.c */ +bool +allowed(Move m) +{ + return base_move(m) == U || m == R2 || m == F2; +} + +bool +allowed_next(Move l2, Move l1, Move m) +{ + return base_move(m) != base_move(l1); +} + +bool +check_cornershtr(Cube c) +{ + return coord_cornershtr.index(c) == 0; +} + +bool +check_coud_and_dbl(Cube c) +{ + return c.coud == 0 && what_corner_at(c, DBL) == DBL; +} + +static int +estimate_cornershtr_HTM(DfsArg *arg) +{ + return ptableval(&pd_cornershtr_HTM, arg->cube); +} + +static bool +validate_singlecw_ending(Alg *alg) +{ + int i; + bool nor, inv; + Move l2 = NULLMOVE, l1 = NULLMOVE, l2i = NULLMOVE, l1i = NULLMOVE; + + for (i = 0; i < alg->len; i++) { + if (alg->inv[i]) { + l2i = l1i; + l1i = alg->move[i]; + } else { + l2 = l1; + l1 = alg->move[i]; + } + } + + nor = l1 ==base_move(l1) && (!commute(l1, l2) ||l2 ==base_move(l2)); + inv = l1i==base_move(l1i) && (!commute(l1i,l2i)||l2i==base_move(l2i)); + + return nor && inv; +} + +int +main() +{ + Moveset moveset_UR2F2 = { + .allowed = allowed, + .allowed_next = allowed_next, + }; + + init_moveset(&moveset_UR2F2); + + /* + * This step is the same as cornershtr_HTM in steps.c, except for + * the ready() function (which is not relevant anyway, it is there + * more for testing than anything else) and the moveset. + */ + Step step = { + .final = false, + .is_done = check_cornershtr, + .estimate = estimate_cornershtr_HTM, + .ready = check_coud_and_dbl, + .is_valid = validate_singlecw_ending, + .moveset = &moveset_UR2F2, + + .pre_trans = uf, + + .tables = {&pd_cornershtr_HTM}, + .ntables = 1, + }; + + SolveOptions opts = { + .min_moves = 0, + .max_moves = 20, + .max_solutions = 1, + .nthreads = 4, + .optimal = 0, + .can_niss = false, + .verbose = false, + .all = false, + .print_number = false, + .count_only = false + }; + + init_symcoord(); + + bool cphtr_state_done[BINOM8ON4*6]; + for (unsigned long int i = 0; i < BINOM8ON4*6; i++) + cphtr_state_done[i] = false; + + for (unsigned long int i = 0; i < FACTORIAL8; i++) { + AlgList *sols; + Cube c = {0}; + c.cp = i; /* inconsistent state because of side CO */ + + if (what_corner_at(c, DBL) != DBL || + cphtr_state_done[coord_cphtr.index(c)]) + continue; + + fprintf(stderr, "Doing cp %ld (cphtr state %ld)\n", + i, coord_cphtr.index(c)); + + cphtr_state_done[coord_cphtr.index(c)] = true; + /* Comment next two lines to get non-reduced list */ + Cube mirror = apply_trans(ur_mirror, c); + cphtr_state_done[coord_cphtr.index(mirror)] = true; + + sols = solve(c, &step, &opts); + printf("%.2d\t", sols->first->alg->len); + print_alglist(sols, opts.print_number); + } + + return 0; +} diff --git a/adhoc/run b/adhoc/run new file mode 100755 index 0000000..27541c2 Binary files /dev/null and b/adhoc/run differ -- cgit v1.3