From 754e632241859b224497ee4e0239670d5d90759f Mon Sep 17 00:00:00 2001 From: enricotenuti Date: Fri, 30 Aug 2024 12:03:03 +0200 Subject: allowedH48 tests --- src/core/moves.h | 4 +-- test/082_allowednext_h48/00_empty_U.in | 3 ++ test/082_allowednext_h48/00_empty_U.out | 1 + test/082_allowednext_h48/01_F.in | 4 +++ test/082_allowednext_h48/01_F.out | 1 + test/082_allowednext_h48/02_U2.in | 3 ++ test/082_allowednext_h48/02_U2.out | 1 + test/082_allowednext_h48/03_R_L.in | 5 +++ test/082_allowednext_h48/03_R_L.out | 1 + test/082_allowednext_h48/04_D.in | 3 ++ test/082_allowednext_h48/04_D.out | 1 + test/082_allowednext_h48/05_U_F_B2.in | 5 +++ test/082_allowednext_h48/05_U_F_B2.out | 1 + test/082_allowednext_h48/06_empty_bound.in | 2 ++ test/082_allowednext_h48/06_empty_bound.out | 1 + test/082_allowednext_h48/07_F_bound.in | 3 ++ test/082_allowednext_h48/07_F_bound.out | 1 + test/082_allowednext_h48/08_U_D_bound_inverse.in | 4 +++ test/082_allowednext_h48/08_U_D_bound_inverse.out | 1 + test/082_allowednext_h48/09_R_false_bound.in | 3 ++ test/082_allowednext_h48/09_R_false_bound.out | 1 + test/082_allowednext_h48/allowednext_h48_tests.c | 38 +++++++++++++++++++++++ 22 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 test/082_allowednext_h48/00_empty_U.in create mode 100644 test/082_allowednext_h48/00_empty_U.out create mode 100644 test/082_allowednext_h48/01_F.in create mode 100644 test/082_allowednext_h48/01_F.out create mode 100644 test/082_allowednext_h48/02_U2.in create mode 100644 test/082_allowednext_h48/02_U2.out create mode 100644 test/082_allowednext_h48/03_R_L.in create mode 100644 test/082_allowednext_h48/03_R_L.out create mode 100644 test/082_allowednext_h48/04_D.in create mode 100644 test/082_allowednext_h48/04_D.out create mode 100644 test/082_allowednext_h48/05_U_F_B2.in create mode 100644 test/082_allowednext_h48/05_U_F_B2.out create mode 100644 test/082_allowednext_h48/06_empty_bound.in create mode 100644 test/082_allowednext_h48/06_empty_bound.out create mode 100644 test/082_allowednext_h48/07_F_bound.in create mode 100644 test/082_allowednext_h48/07_F_bound.out create mode 100644 test/082_allowednext_h48/08_U_D_bound_inverse.in create mode 100644 test/082_allowednext_h48/08_U_D_bound_inverse.out create mode 100644 test/082_allowednext_h48/09_R_false_bound.in create mode 100644 test/082_allowednext_h48/09_R_false_bound.out create mode 100644 test/082_allowednext_h48/allowednext_h48_tests.c diff --git a/src/core/moves.h b/src/core/moves.h index b28822a..9753993 100644 --- 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 new file mode 100644 index 0000000..28271a6 --- /dev/null +++ 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 new file mode 100644 index 0000000..8607955 --- /dev/null +++ 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 new file mode 100644 index 0000000..e7ae375 --- /dev/null +++ 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 new file mode 100644 index 0000000..5d6f843 --- /dev/null +++ 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 new file mode 100644 index 0000000..2c5ee5f --- /dev/null +++ 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 new file mode 100644 index 0000000..a9a5adb --- /dev/null +++ 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 new file mode 100644 index 0000000..b6c0625 --- /dev/null +++ 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 new file mode 100644 index 0000000..a4aa4b2 --- /dev/null +++ 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 new file mode 100644 index 0000000..83da556 --- /dev/null +++ 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 new file mode 100644 index 0000000..fe91843 --- /dev/null +++ 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 new file mode 100644 index 0000000..67e090f --- /dev/null +++ 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 new file mode 100644 index 0000000..5d6f843 --- /dev/null +++ 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 new file mode 100644 index 0000000..389e262 --- /dev/null +++ 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 new file mode 100644 index 0000000..eb601fc --- /dev/null +++ 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 new file mode 100644 index 0000000..b3ae33d --- /dev/null +++ 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 new file mode 100644 index 0000000..0dc8997 --- /dev/null +++ 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 new file mode 100644 index 0000000..707f7e0 --- /dev/null +++ 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 new file mode 100644 index 0000000..6f47cf0 --- /dev/null +++ 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 new file mode 100644 index 0000000..0b1d441 --- /dev/null +++ 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 new file mode 100644 index 0000000..121bfeb --- /dev/null +++ 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 new file mode 100644 index 0000000..4cee695 --- /dev/null +++ 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); +} -- cgit v1.3