diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-08 06:26:12 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-08 06:26:12 +0100 |
| commit | 110e079f81277b40ec76be0b86b074a632496109 (patch) | |
| tree | 45c725b7ade224f12647566311f56f0f7df469f0 /src/solvers/coord/gendata_coord.h | |
| parent | fd71dea0577ddcafa335ed56b0fe498306d9fb99 (diff) | |
| download | nissy-core-110e079f81277b40ec76be0b86b074a632496109.tar.gz nissy-core-110e079f81277b40ec76be0b86b074a632496109.zip | |
renamed some files
Diffstat (limited to 'src/solvers/coord/gendata_coord.h')
| -rw-r--r-- | src/solvers/coord/gendata_coord.h | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/src/solvers/coord/gendata_coord.h b/src/solvers/coord/gendata_coord.h deleted file mode 100644 index 3d385e9..0000000 --- a/src/solvers/coord/gendata_coord.h +++ /dev/null | |||
| @@ -1,136 +0,0 @@ | |||
| 1 | STATIC size_t gendata_coordinate(const coord_t *, void *); | ||
| 2 | STATIC size_t gendata_coordinate_name(const char *, void *); | ||
| 3 | STATIC tableinfo_t genptable_coordinate(const coord_t *, const void *, uint8_t *); | ||
| 4 | STATIC uint8_t get_coord_pval(const coord_t *, const uint8_t *, uint64_t); | ||
| 5 | STATIC void set_coord_pval(const coord_t *, uint8_t *, uint64_t, uint8_t); | ||
| 6 | |||
| 7 | STATIC size_t | ||
| 8 | gendata_coordinate_name(const char *name, void *buf) | ||
| 9 | { | ||
| 10 | coord_t *coord; | ||
| 11 | |||
| 12 | coord = parse_coord(name, strlen(name)); | ||
| 13 | if (coord == NULL) { | ||
| 14 | LOG("Cannot generate data for coordinate '%s': not found\n", | ||
| 15 | name); | ||
| 16 | return 0; | ||
| 17 | } | ||
| 18 | |||
| 19 | return gendata_coordinate(coord, buf); | ||
| 20 | } | ||
| 21 | |||
| 22 | STATIC size_t | ||
| 23 | gendata_coordinate(const coord_t *coord, void *buf) | ||
| 24 | { | ||
| 25 | uint64_t coord_dsize, tablesize, ninfo; | ||
| 26 | void *pruningbuf, *coord_data; | ||
| 27 | uint8_t *table; | ||
| 28 | tableinfo_t coord_data_info, pruning_info; | ||
| 29 | |||
| 30 | coord_data = buf == NULL ? NULL : ((uint8_t *)buf) + INFOSIZE; | ||
| 31 | coord_dsize = coord->gendata(coord_data); | ||
| 32 | ninfo = coord_dsize == 0 ? 1 : 2; | ||
| 33 | tablesize = DIV_ROUND_UP(coord->max, 2); | ||
| 34 | |||
| 35 | if (buf == NULL) | ||
| 36 | goto gendata_coordinate_return_size; | ||
| 37 | |||
| 38 | if (ninfo == 2) { | ||
| 39 | coord_data_info = (tableinfo_t) { | ||
| 40 | .solver = "coord helper table for ", | ||
| 41 | .type = TABLETYPE_SPECIAL, | ||
| 42 | .infosize = INFOSIZE, | ||
| 43 | .fullsize = INFOSIZE + coord_dsize, | ||
| 44 | .hash = 0, /* TODO */ | ||
| 45 | .next = INFOSIZE + coord_dsize, | ||
| 46 | |||
| 47 | /* Unknown / non-applicable values */ | ||
| 48 | .entries = 0, | ||
| 49 | .classes = 0, | ||
| 50 | .bits = 0, | ||
| 51 | .base = 0, | ||
| 52 | .maxvalue = 0, | ||
| 53 | }; | ||
| 54 | |||
| 55 | append_coord_name(coord, coord_data_info.solver); | ||
| 56 | |||
| 57 | writetableinfo(&coord_data_info, INFOSIZE + coord_dsize, buf); | ||
| 58 | |||
| 59 | pruningbuf = ((uint8_t *)buf) + INFOSIZE + coord_dsize; | ||
| 60 | } else { | ||
| 61 | pruningbuf = buf; | ||
| 62 | } | ||
| 63 | |||
| 64 | table = ((uint8_t *)pruningbuf) + INFOSIZE; | ||
| 65 | pruning_info = genptable_coordinate(coord, coord_data, table); | ||
| 66 | writetableinfo(&pruning_info, INFOSIZE + tablesize, pruningbuf); | ||
| 67 | |||
| 68 | gendata_coordinate_return_size: | ||
| 69 | return ninfo * INFOSIZE + coord_dsize + tablesize; | ||
| 70 | } | ||
| 71 | |||
| 72 | STATIC tableinfo_t | ||
| 73 | genptable_coordinate(const coord_t *coord, const void *data, uint8_t *table) | ||
| 74 | { | ||
| 75 | uint64_t tablesize, i, j, d, tot; | ||
| 76 | tableinfo_t info; | ||
| 77 | uint8_t m; | ||
| 78 | cube_t c, cc; | ||
| 79 | |||
| 80 | tablesize = DIV_ROUND_UP(coord->max, 2); | ||
| 81 | |||
| 82 | memset(table, 0xFF, tablesize); | ||
| 83 | |||
| 84 | info = (tableinfo_t) { | ||
| 85 | .solver = "coordinate solver for ", | ||
| 86 | .type = TABLETYPE_PRUNING, | ||
| 87 | .infosize = INFOSIZE, | ||
| 88 | .fullsize = INFOSIZE + tablesize, | ||
| 89 | .hash = 0, /* TODO */ | ||
| 90 | .entries = coord->max, | ||
| 91 | .classes = 0, | ||
| 92 | .bits = 4, | ||
| 93 | .base = 0, | ||
| 94 | .maxvalue = 0, | ||
| 95 | .next = 0 | ||
| 96 | }; | ||
| 97 | |||
| 98 | memset(info.distribution, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | ||
| 99 | append_coord_name(coord, info.solver); | ||
| 100 | |||
| 101 | i = coord->coord(SOLVED_CUBE, data); | ||
| 102 | set_coord_pval(coord, table, i, 0); | ||
| 103 | info.distribution[0] = 1; | ||
| 104 | for (d = 1, tot = 1; tot < coord->max; d++) { | ||
| 105 | for (i = 0; i < coord->max; i++) { | ||
| 106 | if (get_coord_pval(coord, table, i) == d-1) { | ||
| 107 | c = coord->cube(i, data); | ||
| 108 | for (m = 0; m < 18; m++) { | ||
| 109 | cc = move(c, m); | ||
| 110 | j = coord->coord(cc, data); | ||
| 111 | if (get_coord_pval(coord, table, j) > d) { | ||
| 112 | set_coord_pval(coord, table, j, d); | ||
| 113 | tot++; | ||
| 114 | info.distribution[d]++; | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } | ||
| 120 | info.maxvalue = d-1; | ||
| 121 | |||
| 122 | return info; | ||
| 123 | } | ||
| 124 | |||
| 125 | STATIC uint8_t | ||
| 126 | get_coord_pval(const coord_t *coord, const uint8_t *table, uint64_t i) | ||
| 127 | { | ||
| 128 | return (table[COORD_INDEX(i)] & COORD_MASK(i)) >> COORD_SHIFT(i); | ||
| 129 | } | ||
| 130 | |||
| 131 | STATIC void | ||
| 132 | set_coord_pval(const coord_t *coord, uint8_t *table, uint64_t i, uint8_t val) | ||
| 133 | { | ||
| 134 | table[COORD_INDEX(i)] = (table[COORD_INDEX(i)] & (~COORD_MASK(i))) | ||
| 135 | | (val << COORD_SHIFT(i)); | ||
| 136 | } | ||
