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 3c8f8c2e60cd089679cf5da5160baaf35977b220
parent 16cf844396181e743403b046c06a21f1dca39426
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Tue, 10 Sep 2024 09:58:17 +0200

Added next table offset to tableinfo

Diffstat:
Msrc/solvers/tables.h | 6+++++-
Mtest/090_tables_readwrite/00_table.in | 1+
Mtest/090_tables_readwrite/00_table.out | 1+
Mtest/090_tables_readwrite/tables_readwrite_tests.c | 3+++
4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/solvers/tables.h b/src/solvers/tables.h @@ -9,7 +9,8 @@ #define INFO_OFFSET_BITS (INFO_OFFSET_ENTRIES + sizeof(uint64_t)) #define INFO_OFFSET_BASE (INFO_OFFSET_BITS + sizeof(uint8_t)) #define INFO_OFFSET_MAXVALUE (INFO_OFFSET_BASE + sizeof(uint8_t)) -#define INFO_OFFSET_DISTRIBUTION (INFO_OFFSET_MAXVALUE + sizeof(uint8_t)) +#define INFO_OFFSET_NEXT (INFO_OFFSET_MAXVALUE + sizeof(uint8_t)) +#define INFO_OFFSET_DISTRIBUTION (INFO_OFFSET_NEXT + sizeof(uint64_t)) #define INFO_DISTRIBUTION_LEN 21 typedef struct { @@ -21,6 +22,7 @@ typedef struct { uint8_t bits; uint8_t base; uint8_t maxvalue; + uint64_t next; uint64_t distribution[INFO_DISTRIBUTION_LEN]; } tableinfo_t; @@ -49,6 +51,7 @@ readtableinfo(const void *buf, tableinfo_t *info) info->bits = *OFFSET(buf, INFO_OFFSET_BITS); info->base = *OFFSET(buf, INFO_OFFSET_BASE); info->maxvalue = *OFFSET(buf, INFO_OFFSET_MAXVALUE); + info->next = *(const uint64_t* )OFFSET(buf, INFO_OFFSET_NEXT); memcpy(info->distribution, OFFSET(buf, INFO_OFFSET_DISTRIBUTION), INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); @@ -85,6 +88,7 @@ writetableinfo(const tableinfo_t *info, void *buf) *OFFSET(buf, INFO_OFFSET_BITS) = info->bits; *OFFSET(buf, INFO_OFFSET_BASE) = info->base; *OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; + *(uint64_t *)OFFSET(buf, INFO_OFFSET_NEXT) = info->next; memcpy(OFFSET(buf, INFO_OFFSET_DISTRIBUTION), info->distribution, INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); diff --git a/test/090_tables_readwrite/00_table.in b/test/090_tables_readwrite/00_table.in @@ -7,6 +7,7 @@ Test solver 2 0 20 +100000000512 100 101 diff --git a/test/090_tables_readwrite/00_table.out b/test/090_tables_readwrite/00_table.out @@ -7,6 +7,7 @@ Test solver 2 0 20 +100000000512 100 101 diff --git a/test/090_tables_readwrite/tables_readwrite_tests.c b/test/090_tables_readwrite/tables_readwrite_tests.c @@ -13,6 +13,7 @@ typedef struct { uint8_t bits; uint8_t base; uint8_t maxvalue; + uint64_t next; uint64_t distribution[INFO_DISTRIBUTION_LEN]; } tableinfo_t; @@ -45,6 +46,7 @@ tableinfo_t test_readinfo(void) { ret.bits = (uint8_t)readn(); ret.base = (uint8_t)readn(); ret.maxvalue = (uint8_t)readn(); + ret.next = readn(); fgets(emptyline, 2, stdin); @@ -67,6 +69,7 @@ void test_writeinfo(tableinfo_t info) { printf("%" PRIu8 "\n", info.bits); printf("%" PRIu8 "\n", info.base); printf("%" PRIu8 "\n", info.maxvalue); + printf("%" PRIu64 "\n", info.next); printf("\n"); for (i = 0; i < INFO_DISTRIBUTION_LEN; i++)