<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puzzles/singles.c, branch devel</title>
<subtitle>My sgt-puzzles tree</subtitle>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/'/>
<entry>
<title>Singles: fix error highlighting when grid is disconnected.</title>
<updated>2023-10-24T17:54:26+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-10-24T17:52:12+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=35f796542ee5d7e775643f526973aa75f483bf20'/>
<id>35f796542ee5d7e775643f526973aa75f483bf20</id>
<content type='text'>
The loop that selects one of the disconnected regions (represented as
equivalence classes in a dsf) to _not_ highlight as an error was
failing to call dsf_canonify() to get the canonical element of the
class.

Instead, it was relying on having met the canonical element of the
class first, because it iterates up the array in order, and in the old
dsf implementation, canonical elements were always minimal ones. But
the DSF refactoring made that untrue, so now we have to explicitly
canonify each value we come to.

Thanks to Steffen Bauer for the diagnosis and suggested fix.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The loop that selects one of the disconnected regions (represented as
equivalence classes in a dsf) to _not_ highlight as an error was
failing to call dsf_canonify() to get the canonical element of the
class.

Instead, it was relying on having met the canonical element of the
class first, because it iterates up the array in order, and in the old
dsf implementation, canonical elements were always minimal ones. But
the DSF refactoring made that untrue, so now we have to explicitly
canonify each value we come to.

Thanks to Steffen Bauer for the diagnosis and suggested fix.
</pre>
</div>
</content>
</entry>
<entry>
<title>Singles: prevent hangs at low puzzle sizes.</title>
<updated>2023-08-27T12:26:01+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-08-27T12:22:45+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=67496e74f68db900d8117be6de3c75285c29c489'/>
<id>67496e74f68db900d8117be6de3c75285c29c489</id>
<content type='text'>
A user reports that trying to generate a 2x2 or 3x3 puzzle at Tricky
difficulty causes the generator to hang, for the usual reason that
there aren't any - puzzles of that size are either ambiguous or Easy.

The usual response in this code base is to quietly downgrade the
puzzle difficulty when absolutely necessary, so here's some code to do
that (and also for 2x3, which the user didn't test, but unsurprisingly
behaves the same way).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A user reports that trying to generate a 2x2 or 3x3 puzzle at Tricky
difficulty causes the generator to hang, for the usual reason that
there aren't any - puzzles of that size are either ambiguous or Easy.

The usual response in this code base is to quietly downgrade the
puzzle difficulty when absolutely necessary, so here's some code to do
that (and also for 2x3, which the user didn't test, but unsurprisingly
behaves the same way).
</pre>
</div>
</content>
</entry>
<entry>
<title>Singles: fix spelling in a validate_params error.</title>
<updated>2023-08-27T12:24:31+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-08-27T12:11:13+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=d3f825c98c2877ca3e2763492ba99973c1b9dc5f'/>
<id>d3f825c98c2877ca3e2763492ba99973c1b9dc5f</id>
<content type='text'>
'height', not 'neight'. Apparently has been misspelled since the
puzzle was first committed. I suppose they look similar enough that it
never caused a problem.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
'height', not 'neight'. Apparently has been misspelled since the
puzzle was first committed. I suppose they look similar enough that it
never caused a problem.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add user preference for Singles' show_black_nums</title>
<updated>2023-08-13T15:44:24+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-12T13:15:45+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=92ac45fe240b2063455b0b01dedc6ef6996f18af'/>
<id>92ac45fe240b2063455b0b01dedc6ef6996f18af</id>
<content type='text'>
I missed this in my main commit for UI preferences
(4227ac1fd5dc25c247e7526526079b85e1890766) because it wasn't documented.
Now it is documented and it has a preference.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I missed this in my main commit for UI preferences
(4227ac1fd5dc25c247e7526526079b85e1890766) because it wasn't documented.
Now it is documented and it has a preference.
</pre>
</div>
</content>
</entry>
<entry>
<title>Singles: use new move_cursor() features</title>
<updated>2023-08-13T15:44:24+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-10T23:59:30+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=f13fbf2285b1731dcc592f5a657dcbda2bbf3a02'/>
<id>f13fbf2285b1731dcc592f5a657dcbda2bbf3a02</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>move_cursor(): handle visible flag; return useful value</title>
<updated>2023-08-09T10:44:25+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-09T08:43:04+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=5ec86c03a8bc911bb3dbd77fb7c827eeca975594'/>
<id>5ec86c03a8bc911bb3dbd77fb7c827eeca975594</id>
<content type='text'>
This adds an extra parameter to move_cursor() that's an optional pointer
to a bool indicating whether the cursor is visible.  This allows for
centralising the common idiom of having the keyboard cursor become
visible when a cursor key is pressed.  Consistently with the vast
majority of existing puzzles, the cursor moves even if it was invisible
before, and becomes visible even if it can't move.

The function now also returns one of the special constants that can be
returned by interpret_move(), so that the caller can correctly return
MOVE_UI_UPDATE or MOVE_NO_EFFECT without needing to carefully check for
changes itself.

Callers are updated only to the extent that they all pass NULL as the
new argument.  Most of them could now be substantially simplified.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds an extra parameter to move_cursor() that's an optional pointer
to a bool indicating whether the cursor is visible.  This allows for
centralising the common idiom of having the keyboard cursor become
visible when a cursor key is pressed.  Consistently with the vast
majority of existing puzzles, the cursor moves even if it was invisible
before, and becomes visible even if it can't move.

The function now also returns one of the special constants that can be
returned by interpret_move(), so that the caller can correctly return
MOVE_UI_UPDATE or MOVE_NO_EFFECT without needing to carefully check for
changes itself.

Callers are updated only to the extent that they all pass NULL as the
new argument.  Most of them could now be substantially simplified.
</pre>
</div>
</content>
</entry>
<entry>
<title>Rename UI_UPDATE as MOVE_UI_UPDATE</title>
<updated>2023-06-10T23:33:27+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-06-04T17:42:58+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=a9af3fda1d784c42d486a019a0a4e947f762af70'/>
<id>a9af3fda1d784c42d486a019a0a4e947f762af70</id>
<content type='text'>
All the other constants named UI_* are special key names that can be
passed to midend_process_key(), but UI_UPDATE is a special return value
from the back-end interpret_move() function instead.  This renaming
makes the distinction clear and provides a naming convention for future
special return values from interpret_move().
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
All the other constants named UI_* are special key names that can be
passed to midend_process_key(), but UI_UPDATE is a special return value
from the back-end interpret_move() function instead.  This renaming
makes the distinction clear and provides a naming convention for future
special return values from interpret_move().
</pre>
</div>
</content>
</entry>
<entry>
<title>New backend functions: get_prefs and set_prefs.</title>
<updated>2023-04-23T12:25:06+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-04-21T14:50:05+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=0058331aeb027f7441a04d99cc7c1e445bd896d9'/>
<id>0058331aeb027f7441a04d99cc7c1e445bd896d9</id>
<content type='text'>
These are similar to the existing pair configure() and custom_params()
in that get_prefs() returns an array of config_item describing a set
of dialog-box controls to present to the user, and set_prefs()
receives the same array with answers filled in and implements the
answers. But where configure() and custom_params() operate on a
game_params structure, the new pair operate on a game_ui, and are
intended to permit GUI configuration of all the settings I just moved
into that structure.

However, nothing actually _calls_ these routines yet. All I've done in
this commit is to add them to 'struct game' and implement them for the
functions that need them.

Also, config_item has new fields, permitting each config option to
define a machine-readable identifying keyword as well as the
user-facing description. For options of type C_CHOICES, each choice
also has a keyword. These keyword fields are only defined at all by
the new get_prefs() function - they're left uninitialised in existing
uses of the dialog system. The idea is to use them when writing out
the user's preferences into a configuration file on disk, although I
haven't actually done any of that work in this commit.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are similar to the existing pair configure() and custom_params()
in that get_prefs() returns an array of config_item describing a set
of dialog-box controls to present to the user, and set_prefs()
receives the same array with answers filled in and implements the
answers. But where configure() and custom_params() operate on a
game_params structure, the new pair operate on a game_ui, and are
intended to permit GUI configuration of all the settings I just moved
into that structure.

However, nothing actually _calls_ these routines yet. All I've done in
this commit is to add them to 'struct game' and implement them for the
functions that need them.

Also, config_item has new fields, permitting each config option to
define a machine-readable identifying keyword as well as the
user-facing description. For options of type C_CHOICES, each choice
also has a keyword. These keyword fields are only defined at all by
the new get_prefs() function - they're left uninitialised in existing
uses of the dialog system. The idea is to use them when writing out
the user's preferences into a configuration file on disk, although I
haven't actually done any of that work in this commit.
</pre>
</div>
</content>
</entry>
<entry>
<title>Pass a game_ui to compute_size, print_size and print.</title>
<updated>2023-04-21T15:18:04+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-04-21T14:30:41+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=a4fca3286f3aa630a3641e50a8e1f44ab1504a29'/>
<id>a4fca3286f3aa630a3641e50a8e1f44ab1504a29</id>
<content type='text'>
I'm about to move some of the bodgy getenv-based options so that they
become fields in game_ui. So these functions, which could previously
access those options directly via getenv, will now need to be given a
game_ui where they can look them up.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I'm about to move some of the bodgy getenv-based options so that they
become fields in game_ui. So these functions, which could previously
access those options directly via getenv, will now need to be given a
game_ui where they can look them up.
</pre>
</div>
</content>
</entry>
<entry>
<title>Reorganise the dsf API into three kinds of dsf.</title>
<updated>2023-04-20T17:39:41+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-04-20T16:27:21+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=c5e253a9f9d3d651227ccad56e2c7526ee1f3eba'/>
<id>c5e253a9f9d3d651227ccad56e2c7526ee1f3eba</id>
<content type='text'>
This is preparing to separate out the auxiliary functionality, and
perhaps leave space for making more of it in future.

The previous name 'edsf' was too vague: the 'e' stood for 'extended',
and didn't say anything about _how_ it was extended. It's now called a
'flip dsf', since it tracks whether elements in the same class are
flipped relative to each other. More importantly, clients that are
going to use the flip tracking must say so when they allocate the dsf.

And Keen's need to track the minimal element of an equivalence class
is going to become a non-default feature, so there needs to be a new
kind of dsf that specially tracks those, and Keen will have to call it.

While I'm here, I've renamed the three dsf creation functions so that
they start with 'dsf_' like all the rest of the dsf API.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is preparing to separate out the auxiliary functionality, and
perhaps leave space for making more of it in future.

The previous name 'edsf' was too vague: the 'e' stood for 'extended',
and didn't say anything about _how_ it was extended. It's now called a
'flip dsf', since it tracks whether elements in the same class are
flipped relative to each other. More importantly, clients that are
going to use the flip tracking must say so when they allocate the dsf.

And Keen's need to track the minimal element of an equivalence class
is going to become a non-default feature, so there needs to be a new
kind of dsf that specially tracks those, and Keen will have to call it.

While I'm here, I've renamed the three dsf creation functions so that
they start with 'dsf_' like all the rest of the dsf API.
</pre>
</div>
</content>
</entry>
</feed>
