h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

commit 754e632241859b224497ee4e0239670d5d90759f
parent 0a45da13ca06f7884872160a6756a04d1eb849c5
Author: enricotenuti <tenutz_27@outlook.it>
Date:   Fri, 30 Aug 2024 12:03:03 +0200

allowedH48 tests

Diffstat:
Msrc/core/moves.h | 4++--
Atest/082_allowednext_h48/00_empty_U.in | 3+++
Atest/082_allowednext_h48/00_empty_U.out | 1+
Atest/082_allowednext_h48/01_F.in | 4++++
Atest/082_allowednext_h48/01_F.out | 1+
Atest/082_allowednext_h48/02_U2.in | 3+++
Atest/082_allowednext_h48/02_U2.out | 1+
Atest/082_allowednext_h48/03_R_L.in | 5+++++
Atest/082_allowednext_h48/03_R_L.out | 1+
Atest/082_allowednext_h48/04_D.in | 3+++
Atest/082_allowednext_h48/04_D.out | 1+
Atest/082_allowednext_h48/05_U_F_B2.in | 5+++++
Atest/082_allowednext_h48/05_U_F_B2.out | 1+
Atest/082_allowednext_h48/06_empty_bound.in | 2++
Atest/082_allowednext_h48/06_empty_bound.out | 1+
Atest/082_allowednext_h48/07_F_bound.in | 3+++
Atest/082_allowednext_h48/07_F_bound.out | 1+
Atest/082_allowednext_h48/08_U_D_bound_inverse.in | 5+++++
Atest/082_allowednext_h48/08_U_D_bound_inverse.out | 1+
Atest/082_allowednext_h48/09_R_false_bound.in | 4++++
Atest/082_allowednext_h48/09_R_false_bound.out | 1+
Atest/082_allowednext_h48/allowednext_h48_tests.c | 38++++++++++++++++++++++++++++++++++++++
22 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/src/core/moves.h b/src/core/moves.h @@ -62,8 +62,8 @@ allowednextmoveH48(uint8_t *moves, uint8_t n, uint32_t h48branch) uint8_t axis1 = moveaxis(moves[n-1]); result = disable_moves(result, base1 * 3); - if (base1 >= 9) - result = disable_moves(result, (base1 * 3) - 9); + if (base1 % 2) + result = disable_moves(result, (base1 - 1) * 3); if (n == 1) return result; diff --git a/test/082_allowednext_h48/00_empty_U.in b/test/082_allowednext_h48/00_empty_U.in @@ -0,0 +1,3 @@ +0 +0 + diff --git a/test/082_allowednext_h48/00_empty_U.out b/test/082_allowednext_h48/00_empty_U.out @@ -0,0 +1 @@ +0x3FFFF diff --git a/test/082_allowednext_h48/01_F.in b/test/082_allowednext_h48/01_F.in @@ -0,0 +1,4 @@ +0 +1 +F + diff --git a/test/082_allowednext_h48/01_F.out b/test/082_allowednext_h48/01_F.out @@ -0,0 +1 @@ +0x38FFF diff --git a/test/082_allowednext_h48/02_U2.in b/test/082_allowednext_h48/02_U2.in @@ -0,0 +1,3 @@ +0 +1 +U diff --git a/test/082_allowednext_h48/02_U2.out b/test/082_allowednext_h48/02_U2.out @@ -0,0 +1 @@ +0x3FFF8 diff --git a/test/082_allowednext_h48/03_R_L.in b/test/082_allowednext_h48/03_R_L.in @@ -0,0 +1,5 @@ +0 +2 +R +L' + diff --git a/test/082_allowednext_h48/03_R_L.out b/test/082_allowednext_h48/03_R_L.out @@ -0,0 +1 @@ +0x3F03F diff --git a/test/082_allowednext_h48/04_D.in b/test/082_allowednext_h48/04_D.in @@ -0,0 +1,3 @@ +0 +1 +D diff --git a/test/082_allowednext_h48/04_D.out b/test/082_allowednext_h48/04_D.out @@ -0,0 +1 @@ +0x3FFC0 diff --git a/test/082_allowednext_h48/05_U_F_B2.in b/test/082_allowednext_h48/05_U_F_B2.in @@ -0,0 +1,5 @@ +0 +2 +U +F + diff --git a/test/082_allowednext_h48/05_U_F_B2.out b/test/082_allowednext_h48/05_U_F_B2.out @@ -0,0 +1 @@ +0x38FFF diff --git a/test/082_allowednext_h48/06_empty_bound.in b/test/082_allowednext_h48/06_empty_bound.in @@ -0,0 +1,2 @@ +2 +0 diff --git a/test/082_allowednext_h48/06_empty_bound.out b/test/082_allowednext_h48/06_empty_bound.out @@ -0,0 +1 @@ +0x2DB6D diff --git a/test/082_allowednext_h48/07_F_bound.in b/test/082_allowednext_h48/07_F_bound.in @@ -0,0 +1,3 @@ +2 +1 +F diff --git a/test/082_allowednext_h48/07_F_bound.out b/test/082_allowednext_h48/07_F_bound.out @@ -0,0 +1 @@ +0x28B6D diff --git a/test/082_allowednext_h48/08_U_D_bound_inverse.in b/test/082_allowednext_h48/08_U_D_bound_inverse.in @@ -0,0 +1,4 @@ +3 +2 +U +D2 +\ No newline at end of file diff --git a/test/082_allowednext_h48/08_U_D_bound_inverse.out b/test/082_allowednext_h48/08_U_D_bound_inverse.out @@ -0,0 +1 @@ +0x2DB40 diff --git a/test/082_allowednext_h48/09_R_false_bound.in b/test/082_allowednext_h48/09_R_false_bound.in @@ -0,0 +1,3 @@ +1 +1 +R +\ No newline at end of file diff --git a/test/082_allowednext_h48/09_R_false_bound.out b/test/082_allowednext_h48/09_R_false_bound.out @@ -0,0 +1 @@ +0x3FE3F diff --git a/test/082_allowednext_h48/allowednext_h48_tests.c b/test/082_allowednext_h48/allowednext_h48_tests.c @@ -0,0 +1,38 @@ +#include "../test.h" + +uint32_t allowednextmoveH48(uint8_t *, uint8_t, uint32_t); + +static char *moves[] = { + "U", "U2", "U'", + "D", "D2", "D'", + "R", "R2", "R'", + "L", "L2", "L'", + "F", "F2", "F'", + "B", "B2", "B'", +}; + +void run(void) { + char movestr[STRLENMAX]; + uint8_t m[100]; + int n, i, j, bound; + + fgets(movestr, STRLENMAX, stdin); + bound = atoi(movestr); + + fgets(movestr, STRLENMAX, stdin); + n = atoi(movestr); + + for (i = 0; i < n; i++) { + fgets(movestr, STRLENMAX, stdin); + movestr[strcspn(movestr, "\n")] = 0; + for (j = 0; j < 18; j++) + if (!strcmp(movestr, moves[j])) + m[i] = j; + } + + fprintf(stderr, "Last two: %s, %s\n", + n > 1 ? moves[m[n-2]] : "-", + n > 0 ? moves[m[n-1]] : "-"); + uint32_t allowed = allowednextmoveH48(m, n, bound); + printf("0x%05X\n", allowed); +}