diff options
| author | Simon Tatham <anakin@pobox.com> | 2023-04-10 14:56:34 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2023-04-10 14:59:05 +0100 |
| commit | 6fb890e0ea20a3c366ffd2de45d26a0c1c454dd6 (patch) | |
| tree | 1672404818caa3f82491962ad4b4ba855414d46a /auxiliary | |
| parent | 71cf891fdc3ab237ecf0e5d1aae39b6c9fe97a4d (diff) | |
| download | puzzles-6fb890e0ea20a3c366ffd2de45d26a0c1c454dd6.zip puzzles-6fb890e0ea20a3c366ffd2de45d26a0c1c454dd6.tar.gz puzzles-6fb890e0ea20a3c366ffd2de45d26a0c1c454dd6.tar.bz2 puzzles-6fb890e0ea20a3c366ffd2de45d26a0c1c454dd6.tar.xz | |
Reference my just-published article about aperiodic tilings.
In commit 8d6647548f7d005 I added the Hats grid type to Loopy, and
mentioned in the commit message that I was very pleased with the
algorithm I came up with.
In fact, I was so pleased with it that I've decided it deserves a
proper public writeup. So I've spent the Easter weekend producing one:
https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/aperiodic-tilings/
In this commit I adjust the header comments in both penrose.c and
hat.c to refer to the article (replacing a previous comment in
penrose.c to a much less polished page containing a copy of my
jotting-grade personal notes that I sent James Harvey once). Also,
added some code to hatgen.c to output Python hat descriptions in a
similar style to hat-test, which I used to generate a couple of the
more difficult diagrams in the new article, and didn't want to lose.
Diffstat (limited to 'auxiliary')
| -rw-r--r-- | auxiliary/hatgen.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/auxiliary/hatgen.c b/auxiliary/hatgen.c index 30242c9..84ced0f 100644 --- a/auxiliary/hatgen.c +++ b/auxiliary/hatgen.c @@ -1330,6 +1330,26 @@ static void draw_hats_svg(const Hat *hats, size_t n, printf("</svg>\n"); } +static void draw_hats_python(const Hat *hats, size_t n) +{ + size_t i, j; + + printf("def hats(hat):\n"); + for (i = 0; i < n; i++) { + const Hat *hat = &hats[i]; + Point vertices[HAT_NVERT]; + size_t nv = hat_vertices(*hat, vertices); + + printf(" hat('%c', %d, None, [", + "HTPF"[hat->parent->type], hat->index); + for (j = 0; j < nv; j++) { + Point v = vertices[j]; + printf("%s(%d,%d)", j ? ", " : "", (v.x * 2 + v.y) / 3, v.y); + } + printf("])\n"); + } +} + typedef enum KiteStep { KS_LEFT, KS_RIGHT, KS_F_LEFT, KS_F_RIGHT } KiteStep; static inline Point kite_step(Point k, KiteStep step) @@ -1459,6 +1479,31 @@ int main(int argc, char **argv) return 0; } + if (argv[1][0] == 'P' && argv[1][1] && strchr("HTPF", argv[1][1])) { + int niter = atoi(argv[1] + 2); + MetatileType type = (argv[1][1] == 'H' ? MT_H : + argv[1][1] == 'T' ? MT_T : + argv[1][1] == 'P' ? MT_P : MT_F); + MetatileSet *tiles = metatile_initial_set(type); + + while (niter-- > 0) { + MetatileSet *t2 = metatile_set_expand(tiles); + metatile_free_set(tiles); + tiles = t2; + } + + { + size_t nh; + Hat *h = metatile_set_to_hats(tiles, &nh, NULL); + draw_hats_python(h, nh); + sfree(h); + } + + metatile_free_set(tiles); + + return 0; + } + if (!strcmp(argv[1], "--tables")) { size_t i, j, k; |