nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit 5cf4ca8743c0fc995d853a19f8b3a3c03dcfd3df
parent e1abf10596acdd424bff277f6372cff33b50dbac
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Mon,  8 May 2023 08:01:23 +0200

Check and remove trivial solutions (e.g. F2 B for EO)

Diffstat:
Msrc/solve.c | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/solve.c b/src/solve.c @@ -10,6 +10,7 @@ static void append_sol(DfsArg *); static bool allowed_next(Move m, Move l0, Move l1); static void get_state(Coordinate *[], Cube *, CubeState *); static int lower_bound(Coordinate *[], CubeState *); +static bool trivialshorten(DfsArg *); static void dfs(DfsArg *); static void dfs_niss(DfsArg *); static void dfs_move(Move, DfsArg *); @@ -68,6 +69,21 @@ lower_bound(Coordinate *coord[], CubeState *state) return ret; } +static bool +trivialshorten(DfsArg *arg) +{ + int bound; + + if (!commute(arg->last[0], arg->last[1])) + return false; + + dfs_move(inverse_move(arg->last[1]), arg); + bound = lower_bound(arg->s->coord, arg->state); + dfs_move(arg->last[1], arg); + + return bound == 0; +} + static void dfs(DfsArg *arg) { @@ -85,7 +101,7 @@ dfs(DfsArg *arg) if (bound == 0) { len = arg->current_alg->len == arg->d; niss = !(arg->st == NISS) || arg->has_nissed; - if (len && niss) + if (len && niss && !trivialshorten(arg)) append_sol(arg); return; }