<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puzzles/guess.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>Appropriately generate MOVE_NO_EFFECT from '\b' in Guess</title>
<updated>2023-08-09T10:47:41+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-09T10:42:51+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=785de41a92dcd45a71c322bafa8af737bb1eb7aa'/>
<id>785de41a92dcd45a71c322bafa8af737bb1eb7aa</id>
<content type='text'>
This is the case that I care about for KaiOS.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is the case that I care about for KaiOS.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use move_cursor() for cursor movement in Guess</title>
<updated>2023-08-09T10:47:41+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-09T10:30:24+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=8c768e7444707b1985788d610e8f14148bc36ab6'/>
<id>8c768e7444707b1985788d610e8f14148bc36ab6</id>
<content type='text'>
This makes interpret_move() properly return MOVE_NO_EFFECT when the
cursor can't move, and simplifies the code as well.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This makes interpret_move() properly return MOVE_NO_EFFECT when the
cursor can't move, and simplifies the code as well.
</pre>
</div>
</content>
</entry>
<entry>
<title>Guess: define constants for flags OR'ed into peg colours</title>
<updated>2023-08-08T23:14:37+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-08T23:14:37+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=7ada9a5742dd4766cc42909ac01bbb2505f74e47'/>
<id>7ada9a5742dd4766cc42909ac01bbb2505f74e47</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Guess: move hold marker upward by two pixels</title>
<updated>2023-08-08T08:35:06+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-08T08:35:06+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=78af0c821aa01f9e4a127b5b5f197fd1c8a22686'/>
<id>78af0c821aa01f9e4a127b5b5f197fd1c8a22686</id>
<content type='text'>
This means that it now potentially overlaps the peg above it (part of
the current guess), rather than potentially overlapping the empty hole
below.  More importantly, it means that the hold marker is erased by
the erasure of the rest of the peg area, so there's no need to
explicitly draw absent hold markers in the background colour.  That in
turn means that absent hold markers don't nibble the tops off all the
pegs at some tile sizes.

Instead of this fix, I could have properly made the hold markers part
of the first row of empty holes, but that would have been rather
fiddly and I've long thought that the hold markers were too far from
the peg that they're holding.

I've also removed part of a comment about the drawing order of hold
markers that seems to have been obsolete even before this commit.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This means that it now potentially overlaps the peg above it (part of
the current guess), rather than potentially overlapping the empty hole
below.  More importantly, it means that the hold marker is erased by
the erasure of the rest of the peg area, so there's no need to
explicitly draw absent hold markers in the background colour.  That in
turn means that absent hold markers don't nibble the tops off all the
pegs at some tile sizes.

Instead of this fix, I could have properly made the hold markers part
of the first row of empty holes, but that would have been rather
fiddly and I've long thought that the hold markers were too far from
the peg that they're holding.

I've also removed part of a comment about the drawing order of hold
markers that seems to have been obsolete even before this commit.
</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>Add preferences for existing UI style controls</title>
<updated>2023-05-30T17:57:15+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-05-30T17:57:15+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=4227ac1fd5dc25c247e7526526079b85e1890766'/>
<id>4227ac1fd5dc25c247e7526526079b85e1890766</id>
<content type='text'>
Some puzzles have keys that make changes to the display style in ways
that would probably have been user preferences if they had existed.
I've added a user preference for each of these.  The keys still work,
and unlike the preferences can be changed without saving any state.

The affected settings are:
 * Labelling colours with numbers in Guess ("L" key)
 * Labelling regions with numbers in Map ("L" key)
 * Whether monsters are shown as letters or pictures in Undead ("A" key)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Some puzzles have keys that make changes to the display style in ways
that would probably have been user preferences if they had existed.
I've added a user preference for each of these.  The keys still work,
and unlike the preferences can be changed without saving any state.

The affected settings are:
 * Labelling colours with numbers in Guess ("L" key)
 * Labelling regions with numbers in Map ("L" key)
 * Whether monsters are shown as letters or pictures in Undead ("A" key)
</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>Add a game_state argument to decode_ui()</title>
<updated>2023-04-08T19:08:16+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-02-13T23:22:59+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=9be7db547aa2eba68492dc3326ea36ebeeb63505'/>
<id>9be7db547aa2eba68492dc3326ea36ebeeb63505</id>
<content type='text'>
Some games would like a way to check that the parameters in the encoded
UI string are consistent with the game parameters.  Since this might
depend on the current state of the game (this being what changed_state()
is for), implement this by adding a game_state parameter to decode_ui().
Nothing currently uses it, though Guess usefully could.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Some games would like a way to check that the parameters in the encoded
UI string are consistent with the game parameters.  Since this might
depend on the current state of the game (this being what changed_state()
is for), implement this by adding a game_state parameter to decode_ui().
Nothing currently uses it, though Guess usefully could.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fall back to &lt;math.h&gt; if &lt;tgmath.h&gt; doesn't work.</title>
<updated>2023-04-06T06:08:04+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-04-06T06:07:30+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=3b9cafa09f783ccadda14d11fc8b73dc496368c0'/>
<id>3b9cafa09f783ccadda14d11fc8b73dc496368c0</id>
<content type='text'>
This fixes a build failure introduced by commit 2e48ce132e011e8
yesterday.

When I saw that commit I expected the most likely problem would be in
the NestedVM build, which is currently the thing with the most most
out-of-date C implementation. And indeed the NestedVM toolchain
doesn't have &lt;tgmath.h&gt; - but much more surprisingly, our _Windows_
builds failed too, with a compile error inside &lt;tgmath.h&gt; itself!

I haven't looked closely into the problem yet. Our Windows builds are
done with clang, which comes with its own &lt;tgmath.h&gt; superseding the
standard Windows one. So you'd _hope_ that clang could make sense of
its own header! But perhaps the problem is that this is an unusual
compile mode and hasn't been tested.

My fix is to simply add a cmake check for &lt;tgmath.h&gt; - which doesn't
just check the file's existence, it actually tries compiling a file
that #includes it, so it will detect 'file exists but is mysteriously
broken' just as easily as 'not there at all'. So this makes the builds
start working again, precisely on Ben's theory of opportunistically
using &lt;tgmath.h&gt; where possible and falling back to &lt;math.h&gt;
otherwise.

It looks ugly, though! I'm half tempted to make a new header file
whose job is to include a standard set of system headers, just so that
that nasty #ifdef doesn't have to sit at the top of almost all the
source files. But for the moment this at least gets the build working
again.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes a build failure introduced by commit 2e48ce132e011e8
yesterday.

When I saw that commit I expected the most likely problem would be in
the NestedVM build, which is currently the thing with the most most
out-of-date C implementation. And indeed the NestedVM toolchain
doesn't have &lt;tgmath.h&gt; - but much more surprisingly, our _Windows_
builds failed too, with a compile error inside &lt;tgmath.h&gt; itself!

I haven't looked closely into the problem yet. Our Windows builds are
done with clang, which comes with its own &lt;tgmath.h&gt; superseding the
standard Windows one. So you'd _hope_ that clang could make sense of
its own header! But perhaps the problem is that this is an unusual
compile mode and hasn't been tested.

My fix is to simply add a cmake check for &lt;tgmath.h&gt; - which doesn't
just check the file's existence, it actually tries compiling a file
that #includes it, so it will detect 'file exists but is mysteriously
broken' just as easily as 'not there at all'. So this makes the builds
start working again, precisely on Ben's theory of opportunistically
using &lt;tgmath.h&gt; where possible and falling back to &lt;math.h&gt;
otherwise.

It looks ugly, though! I'm half tempted to make a new header file
whose job is to include a standard set of system headers, just so that
that nasty #ifdef doesn't have to sit at the top of almost all the
source files. But for the moment this at least gets the build working
again.
</pre>
</div>
</content>
</entry>
</feed>
