From 99b746a01c11e061c4bd42cf096d27be9507ae21 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 15 Dec 2024 16:55:01 +0100 Subject: Fix rare bug, but one more bug to go --- src/core/moves.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core') diff --git a/src/core/moves.h b/src/core/moves.h index 037944b..3a1158b 100644 --- a/src/core/moves.h +++ b/src/core/moves.h @@ -12,6 +12,7 @@ STATIC cube_t move(cube_t, uint8_t); STATIC cube_t premove(cube_t, uint8_t); STATIC uint8_t inverse_move(uint8_t); STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *); +STATIC void sortparallel(uint8_t *, uint8_t); STATIC int readmoves(const char *, int, uint8_t *); STATIC cube_t applymoves(cube_t, const char *); @@ -229,6 +230,17 @@ invertmoves(uint8_t *moves, uint8_t nmoves, uint8_t *ret) } #pragma GCC pop_options +STATIC void +sortparallel(uint8_t *moves, uint8_t n) +{ + uint8_t i; + + for (i = 0; i < n-1; i++) + if (moveaxis(moves[i]) == moveaxis(moves[i+1]) && + movebase(moves[i]) == movebase(moves[i+1]) + 1) + SWAP(moves[i], moves[i+1]); +} + STATIC int readmoves(const char *buf, int max, uint8_t *ret) { -- cgit v1.3