Hats tiling: more uniform parent selection.

This tweak improves the uniformity of the generated patches of hat
tiling, by selecting from (the closest 32-bit approximation I can get
to) the limiting probability distribution of finite patches in the
whole plane.

This shouldn't invalidate any grid description that contains enough
coordinates to uniquely specify a piece of tiling - in particular, any
generated by the game itself. But if anyone's been brave enough to
hand-type a grid description in the last two days and left off some of
the coordinates, then those might be invalidated.
This commit is contained in:
Simon Tatham
2023-03-28 20:27:27 +01:00
parent 2b1167d82a
commit 6f75879e9f
3 changed files with 176 additions and 96 deletions

View File

@ -1476,10 +1476,6 @@ int main(int argc, char **argv)
printf(" };\n\n");
{
struct Parent {
MetatileType t;
unsigned index;
} parents[4][4*MT_MAXEXPAND];
size_t psizes[4] = {0, 0, 0, 0};
size_t csizes[4] = {0, 0, 0, 0};
@ -1492,8 +1488,6 @@ int main(int argc, char **argv)
" ", HTPF[i]);
for (j = 0; j < nt; j++) {
MetatileType c = t[j].type;
parents[c][psizes[c]].t = i;
parents[c][psizes[c]].index = j;
psizes[c]++;
csizes[i]++;
printf(" TT_%c,", HTPF[c]);
@ -1509,26 +1503,6 @@ int main(int argc, char **argv)
for (i = 0; i < 4; i++)
printf(" %u,\n", (unsigned)csizes[i]);
printf("};\n\n");
for (i = 0; i < 4; i++) {
printf("static const MetatilePossibleParent "
"permitted_parents_%c[] = {\n", HTPF[i]);
for (j = 0; j < psizes[i]; j++)
printf(" { TT_%c, %u },\n", HTPF[parents[i][j].t],
parents[i][j].index);
printf("};\n");
}
printf("static const MetatilePossibleParent *const "
"permitted_parents[] = {\n");
for (i = 0; i < 4; i++)
printf(" permitted_parents_%c,\n", HTPF[i]);
printf("};\n");
printf("static const size_t n_permitted_parents[] = {\n");
for (i = 0; i < 4; i++)
printf(" %u,\n", (unsigned)psizes[i]);
printf("};\n\n");
}
{