simon-git: puzzles (main): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Mon Mar 29 21:04:08 BST 2021


TL;DR:
  1fcb61c Filling: fix assertion failure in 3x1 game generation.
  083de05 Filling: remove directional bias in grid generation.
  0f3c2f7 Filling grid gen: slightly randomise neighbour selection.

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:           2021-03-29 21:04:08

commit 1fcb61cffe538c11a11fc2ec94d6470a61df019e
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=1fcb61cffe538c11a11fc2ec94d6470a61df019e;hp=ff3e762fd0078836243011ca91210f32ea7d1cbd
Author: Simon Tatham <anakin at pobox.com>
Date:   Sun Mar 14 22:05:23 2021 +0000

    Filling: fix assertion failure in 3x1 game generation.
    
    This would come up on the game id "3x1#12345", for example. The
    failing assertion was (s->board[f] != EMPTY) in expand(), called in
    turn from learn_expand_or_one().
    
    It looks as if the problem was that the #define SENTINEL was set too
    small. It was intended to be a value that can't coincide with the true
    size of any region - and it was set to precisely the area of the whole
    board. But on a 3x1 grid, that _can_ coincide with the size of a
    region! So a board entry was set to a real region size, and then
    mistaken for SENTINEL by another part of the code.
    
    Easy fix: set SENTINEL to be sz+1. Now it really can't coincide with a
    region area.

 filling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 083de051cbc88f391c6bd28481b856013e293ce9
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=083de051cbc88f391c6bd28481b856013e293ce9;hp=1fcb61cffe538c11a11fc2ec94d6470a61df019e
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Mar 29 20:49:17 2021 +0100

    Filling: remove directional bias in grid generation.
    
    The method of generating a solved Filling grid (before winnowing
    clues) is to loop over every square of the board, and for each one, if
    it has a neighbour which is part of a different region of the same
    size (i.e. the board is not currently legal), fix it by merging with
    one of its neighbours. We pick a neighbour to merge with based on the
    size of its region - but we always loop over the four possible
    neighbours in the same order, which introduces a directional bias into
    the breaking of ties in that comparison.
    
    Now we iterate over the four directions in random order.

 filling.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

commit 0f3c2f7cd4c59e1eee6c44d800e266b57e2ec33f
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=0f3c2f7cd4c59e1eee6c44d800e266b57e2ec33f;hp=083de051cbc88f391c6bd28481b856013e293ce9
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Mar 29 20:50:28 2021 +0100

    Filling grid gen: slightly randomise neighbour selection.
    
    This is another modification to the same piece of code as the previous
    commit. Previously, a square with a neighbour in a same-sized region
    was fixed by choosing a neighbour to merge it with that was part of
    the smallest region. Now, it's _usually_ that, but sometimes it can be
    a larger neighbour instead.
    
    Partly, I hope this might remove a potential source of regularity in
    the random grids. But mostly, it prevents the grid generator from
    hanging completely on 2x2 grids (e.g. if you gave "2x2#12345" in the
    previous state of the code), because with the previous 'always
    minimal' rule, the generator would merge together two squares of the
    2x2 grid, then the other two, and then (due to maxsize==3) it would
    have no merge remaining to clear the final error. Now, every so often,
    it will take the unusual option of making a size-3 region instead,
    which allows game generation to succeed.

 filling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



More information about the tartarus-commits mailing list