<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puzzles/untangle.c, branch rockbox-devel</title>
<subtitle>My sgt-puzzles tree</subtitle>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/'/>
<entry>
<title>Untangle: add cursor control interface.</title>
<updated>2024-07-31T22:29:00+00:00</updated>
<author>
<name>Franklin Wei</name>
<email>franklin@rockbox.org</email>
</author>
<published>2024-07-21T09:32:09+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=c010ca122f8e5a9b9828a846cbbc0d32de489b20'/>
<id>c010ca122f8e5a9b9828a846cbbc0d32de489b20</id>
<content type='text'>
The cursor keys navigate amongst the points. CURSOR_SELECT toggles dragging;
CURSOR_SELECT2 and the Tab key cycle through the points.

The cursor navigation scheme jumps to the nearest point within the quadrant
of the cursor direction; this seems to yield fairly intuitive gameplay.
Unfortunately, the "quadrant-nearest-neighbors" digraph produced by this
scheme is not necessarily fully reciprocal; that is, pressing opposite
cursor keys in sequence does not always return to the original point. There
doesn't seem to be any immediately obvious way around this.

As for connectivity (i.e. whether all points are reachable from any given
point), I could not find a counterexample, but I don't yet have a formal
proof that this is the case in general. Hence, I've added the ability to
cycle through all the points with Tab. (This will probably also be useful
in conjunction with the "Numbers" point drawing preference.)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The cursor keys navigate amongst the points. CURSOR_SELECT toggles dragging;
CURSOR_SELECT2 and the Tab key cycle through the points.

The cursor navigation scheme jumps to the nearest point within the quadrant
of the cursor direction; this seems to yield fairly intuitive gameplay.
Unfortunately, the "quadrant-nearest-neighbors" digraph produced by this
scheme is not necessarily fully reciprocal; that is, pressing opposite
cursor keys in sequence does not always return to the original point. There
doesn't seem to be any immediately obvious way around this.

As for connectivity (i.e. whether all points are reachable from any given
point), I could not find a counterexample, but I don't yet have a formal
proof that this is the case in general. Hence, I've added the ability to
cycle through all the points with Tab. (This will probably also be useful
in conjunction with the "Numbers" point drawing preference.)
</pre>
</div>
</content>
</entry>
<entry>
<title>Untangle: turn #define VERTEX_NUMBERS into a preference.</title>
<updated>2023-11-18T13:56:42+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-11-18T13:56:42+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=cb8dcc34f7c656b8603a510617e35492a0d16b8c'/>
<id>cb8dcc34f7c656b8603a510617e35492a0d16b8c</id>
<content type='text'>
This compile-time definition switches the game into showing a distinct
non-negative integer for each vertex, instead of indistinguishable
blobs.

Its main use to me in the past has been when I'm trying to planarise
'real' graphs, that is, graphs I got from outside the game and wanted
a planar embedding of. Having made one in Untangle's UI I could then
read off which vertex was which.

That's an unusual use of the game, but _might_ be useful to someone
else. Perhaps a more interesting use of this feature would be to
direct someone else's play verbally - it would be much easier to tell
them which vertex to click on that way!
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This compile-time definition switches the game into showing a distinct
non-negative integer for each vertex, instead of indistinguishable
blobs.

Its main use to me in the past has been when I'm trying to planarise
'real' graphs, that is, graphs I got from outside the game and wanted
a planar embedding of. Having made one in Untangle's UI I could then
read off which vertex was which.

That's an unusual use of the game, but _might_ be useful to someone
else. Perhaps a more interesting use of this feature would be to
direct someone else's play verbally - it would be much easier to tell
them which vertex to click on that way!
</pre>
</div>
</content>
</entry>
<entry>
<title>Untangle: turn #define SHOW_CROSSINGS into a preference.</title>
<updated>2023-11-14T12:59:44+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-11-14T12:59:44+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=96d65e852cea8a95001fa70e3ec2996d4ea5e2b4'/>
<id>96d65e852cea8a95001fa70e3ec2996d4ea5e2b4</id>
<content type='text'>
I just found this #define in the Untangle source code, which I'd
completely forgotten was there. It causes each graph edge to be
highlighted in red if another edge crosses it, so that when you only
have a small number of crossings left to sort out, it's obvious where
they are.

Now we have a preferences system, there's no need to make this a
compile-time option! We can make it run-time selectable, for users who
want the extra help.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I just found this #define in the Untangle source code, which I'd
completely forgotten was there. It causes each graph edge to be
highlighted in red if another edge crosses it, so that when you only
have a small number of crossings left to sort out, it's obvious where
they are.

Now we have a preferences system, there's no need to make this a
compile-time option! We can make it run-time selectable, for users who
want the extra help.
</pre>
</div>
</content>
</entry>
<entry>
<title>Untangle: make snapping grid invariant under window resize</title>
<updated>2023-08-14T16:13:01+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-14T16:13:01+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=eeec6b867af104a93a615a285a29fab91d8709d4'/>
<id>eeec6b867af104a93a615a285a29fab91d8709d4</id>
<content type='text'>
In grid-snapping mode, Untangle was still recording vertex positions
in increments of one pixel.  This meant that if you positioned
vertices on a small window, then enlarged the window and positioned
more vertices, the two sets of vertices generally wouldn't line up
with one another.  This was annoying, and obviously silly when
Untangle has a resolution-independent co-ordinate system.  So now the
snapped positions are recorded in a form that doesn't depend on the
tilesize.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In grid-snapping mode, Untangle was still recording vertex positions
in increments of one pixel.  This meant that if you positioned
vertices on a small window, then enlarged the window and positioned
more vertices, the two sets of vertices generally wouldn't line up
with one another.  This was annoying, and obviously silly when
Untangle has a resolution-independent co-ordinate system.  So now the
snapped positions are recorded in a form that doesn't depend on the
tilesize.
</pre>
</div>
</content>
</entry>
<entry>
<title>Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Untangle</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:31:37+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=be9e4f89579331eea8df13d8ef3ef7366a4cffab'/>
<id>be9e4f89579331eea8df13d8ef3ef7366a4cffab</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</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>Untangle: add a 'snap to grid' user preference.</title>
<updated>2023-05-01T13:30:54+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-05-01T13:24:56+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=e0bb6d3b8546ea67e79cb190a96c26961ddacdf6'/>
<id>e0bb6d3b8546ea67e79cb190a96c26961ddacdf6</id>
<content type='text'>
Requested by a user who otherwise found themself spending too much
time struggling to get lines nicely horizontal or vertical.

The implementation is easy, but the question is what size of grid is
appropriate. Untangle's own generated games are constructed by making
a planar graph drawn on an extremely coarse grid - but snapping to
_that_ grid would give away information about the puzzle solution, and
also, Untangle wouldn't know any similar information about graphs
generated by any other method.

So a better approach is to choose a size of grid that guarantees that
_any_ graph with n vertices can be drawn on it with nonintersecting
straight edges. That sounds like a tricky maths problem - but happily,
the solution is given in a book I already had a copy of. References in
a comment (plus a proof of a pedantic followup detail about multiple
planar embeddings).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Requested by a user who otherwise found themself spending too much
time struggling to get lines nicely horizontal or vertical.

The implementation is easy, but the question is what size of grid is
appropriate. Untangle's own generated games are constructed by making
a planar graph drawn on an extremely coarse grid - but snapping to
_that_ grid would give away information about the puzzle solution, and
also, Untangle wouldn't know any similar information about graphs
generated by any other method.

So a better approach is to choose a size of grid that guarantees that
_any_ graph with n vertices can be drawn on it with nonintersecting
straight edges. That sounds like a tricky maths problem - but happily,
the solution is given in a book I already had a copy of. References in
a comment (plus a proof of a pedantic followup detail about multiple
planar embeddings).
</pre>
</div>
</content>
</entry>
<entry>
<title>Untangle: replace manual int64 bodging with int64_t.</title>
<updated>2023-05-01T13:30:54+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-05-01T12:49:54+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=628cc6785b2cfa3d4ee6101667e4bb9e11095eec'/>
<id>628cc6785b2cfa3d4ee6101667e4bb9e11095eec</id>
<content type='text'>
Where possible, that is. If our compilation environment has provided
int64_t, we can just make our int64 type be that, and not have to mess
around with multi-word arithmetic at all.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Where possible, that is. If our compilation environment has provided
int64_t, we can just make our int64 type be that, and not have to mess
around with multi-word arithmetic at all.
</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>
</feed>
