simon-git: puzzles (main): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sun Apr 2 14:38:30 BST 2023


TL;DR:
  71e1776 Move hat-test into its own source file.
  8324429 Move other test main()s out of library source files.
  2296d6f Remove penrose_count_tiles().
  7956148 hat-test: fix array underrun.
  2499eb4 hat-test: more scaling and clipping options.

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: main
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2023-04-02 14:38:30

commit 71e1776094aa9240e9772b7fbc99dd5e2f4e1acb
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=71e1776094aa9240e9772b7fbc99dd5e2f4e1acb;hp=0bd1a8057841386754f9f4a8a268616c7ce80e80
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Apr 2 10:20:37 2023 +0100

    Move hat-test into its own source file.
    
    I noticed while hacking on hat-test recently that it's quite awkward
    to be compiling a test main() program that lives in a source file also
    built into the Puzzles support library, because every modification to
    main() also triggers a rebuild of the library, and thence of all the
    actual puzzles. So it's better if such a test main() has its own
    source file.
    
    In order to make hat-test work standalone, I've had to move a lot of
    hat.c's internal declarations out into a second header file. This also
    means making a bunch of internal functions global, which means they're
    also in the namespace of programs other than hat-test, which means in
    turn that they should have names with less implicit context.

 CMakeLists.txt           |   1 -
 auxiliary/CMakeLists.txt |   1 +
 auxiliary/hat-test.c     | 622 ++++++++++++++++++++++++++++++
 hat-internal.h           | 271 +++++++++++++
 hat.c                    | 984 +++--------------------------------------------
 5 files changed, 956 insertions(+), 923 deletions(-)

commit 83244294f56cbf4c6ac03564489d1775054bbcfc
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=83244294f56cbf4c6ac03564489d1775054bbcfc;hp=71e1776094aa9240e9772b7fbc99dd5e2f4e1acb
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Apr 2 10:42:42 2023 +0100

    Move other test main()s out of library source files.
    
    Having stated the principle in the previous commit, I should apply it
    consistently. A source file linked into the Puzzles library of common
    support code should not also define a main() under ifdef.
    
    This commit only goes as far as the _library_ support modules. It
    would be a much bigger job to do the same for all the actual _puzzles_
    that have test main()s or standalone-solver main()s. And it's not
    necessary, because modifying one of those source files only triggers a
    rebuild of _one_ puzzle, not absolutely everything. (Not to mention
    that it's quite likely the puzzle and the test main() will need to be
    modified in conjunction anyway.)
    
    As in the previous commit, this has required exposing a few internal
    API functions as global, and maybe editing them a bit. In particular,
    the one-shot internal function that divvy_rectangle() loops on until
    it succeeds is now exposed as divvy_rectangle_attempt(), which means
    the test program doesn't have to condition a failure counter into the
    real function.
    
    I've thrown away penrose-vector-test completely, because that didn't
    look like a test program with any ongoing use at all - it was surely
    vestigial, while James was getting the vector representation up and
    running in the first place.

 CMakeLists.txt                 |  10 -
 auxiliary/CMakeLists.txt       |   8 +
 auxiliary/combi-test.c         |  25 ++
 auxiliary/divvy-test.c         | 103 ++++++
 auxiliary/latin-test.c         | 110 ++++++
 auxiliary/matching.c           | 397 +++++++++++++++++++++
 obfusc.c => auxiliary/obfusc.c |   0
 auxiliary/penrose-test.c       |  95 +++++
 auxiliary/sort-test.c          |  70 ++++
 auxiliary/tree234-test.c       | 746 +++++++++++++++++++++++++++++++++++++++
 combi.c                        |  32 --
 divvy.c                        | 122 +------
 latin.c                        | 117 -------
 matching.c                     | 427 +----------------------
 matching.h                     |  28 ++
 penrose.c                      | 128 -------
 puzzles.h                      |   2 +
 sort.c                         |  71 ----
 tree234.c                      | 770 +----------------------------------------
 tree234.h                      |  24 +-
 20 files changed, 1613 insertions(+), 1672 deletions(-)

commit 2296d6f078f543f8c17d9f9181ec10bd228110f2
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=2296d6f078f543f8c17d9f9181ec10bd228110f2;hp=83244294f56cbf4c6ac03564489d1775054bbcfc
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Apr 2 13:07:25 2023 +0100

    Remove penrose_count_tiles().
    
    Nothing uses it, and that's not surprising, because if anything had,
    we'd have noticed that it never actually got written!

 penrose.c | 5 -----
 penrose.h | 3 ---
 2 files changed, 8 deletions(-)

commit 79561485919e0dc867b5c5190c00aa90c5112b37
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=79561485919e0dc867b5c5190c00aa90c5112b37;hp=2296d6f078f543f8c17d9f9181ec10bd228110f2
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Apr 2 14:10:31 2023 +0100

    hat-test: fix array underrun.
    
    Having _checked_ whether a hat index in my four-colouring maps was -1, I
    then went ahead and used it as an array index anyway, oops!

 auxiliary/hat-test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

commit 2499eb47fa4e0c86bc1b6100b4922026670b2ad8
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=2499eb47fa4e0c86bc1b6100b4922026670b2ad8;hp=79561485919e0dc867b5c5190c00aa90c5112b37
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Apr 2 14:30:30 2023 +0100

    hat-test: more scaling and clipping options.
    
    This adds the ability to turn off hat-test's normal scaling of the
    bounding box to fit on an A4 page, which I intended for printing test
    patches (but never actually found a need to print one). The --unscaled
    mode seems more useful if you're planning to turn the output into an
    image, e.g. to use as a desktop background.
    
    Also added --clip, which generates a rectangle completely covered in
    hats (i.e. shows any hat that overlaps the output rectangle at all),
    as opposed to the normal mode which omits any hat that doesn't fit
    _entirely_ in the output rectangle (more similar to what Loopy wants).
    
    Actually generating a desktop background by this method is still a bit
    fiddly to get right, but it's better than before.

 auxiliary/hat-test.c | 66 ++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 54 insertions(+), 12 deletions(-)



More information about the tartarus-commits mailing list