aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-02-12 01:24:58 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-02-12 01:24:58 +0000
commitc139aba078f2ec46a0e0b44142b7c982519a8263 (patch)
tree179624c76450be041193bc9b7c29ff9f87028d01
parent97b03cc67a31c1d0869a21c50b9ca31f78775ff9 (diff)
downloadpuzzles-c139aba078f2ec46a0e0b44142b7c982519a8263.zip
puzzles-c139aba078f2ec46a0e0b44142b7c982519a8263.tar.gz
puzzles-c139aba078f2ec46a0e0b44142b7c982519a8263.tar.bz2
puzzles-c139aba078f2ec46a0e0b44142b7c982519a8263.tar.xz
Allow more general cross-shaped boards in Pegs
I found a plausible looking Web page claiming that various different sizes of cross are soluble, and some of them are quite widespread. I've enabled the ones that are symmetric enough that the existing game generator can lay them out.
-rw-r--r--pegs.c34
-rw-r--r--puzzles.but5
2 files changed, 32 insertions, 7 deletions
diff --git a/pegs.c b/pegs.c
index 2005a9e..1cfa9c7 100644
--- a/pegs.c
+++ b/pegs.c
@@ -71,7 +71,11 @@ static game_params *default_params(void)
}
static const struct game_params pegs_presets[] = {
+ {5, 7, TYPE_CROSS},
{7, 7, TYPE_CROSS},
+ {5, 9, TYPE_CROSS},
+ {7, 9, TYPE_CROSS},
+ {9, 9, TYPE_CROSS},
{7, 7, TYPE_OCTAGON},
{5, 5, TYPE_RANDOM},
{7, 7, TYPE_RANDOM},
@@ -90,7 +94,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
*ret = pegs_presets[i];
strcpy(str, pegs_titletypes[ret->type]);
- if (ret->type == TYPE_RANDOM)
+ if (ret->type == TYPE_CROSS || ret->type == TYPE_RANDOM)
sprintf(str + strlen(str), " %dx%d", ret->w, ret->h);
*name = dupstr(str);
@@ -189,12 +193,32 @@ static const char *validate_params(const game_params *params, bool full)
return "Width times height must not be unreasonably large";
/*
- * It might be possible to implement generalisations of Cross
- * and Octagon, but only if I can find a proof that they're all
+ * At http://www.gibell.net/pegsolitaire/GenCross/GenCrossBoards0.html
+ * George I. Bell asserts that various generalised cross-shaped
+ * boards are soluble starting (and finishing) with the centre
+ * hole. We permit the symmetric ones. Bell's notation for each
+ * soluble board is listed.
+ */
+ if (full && params->type == TYPE_CROSS) {
+ if (!((params->w == 9 && params->h == 5) || /* (3,1,3,1) */
+ (params->w == 5 && params->h == 9) || /* (1,3,1,3) */
+ (params->w == 9 && params->h == 9) || /* (3,3,3,3) */
+ (params->w == 7 && params->h == 5) || /* (2,1,2,1) */
+ (params->w == 5 && params->h == 7) || /* (1,2,1,2) */
+ (params->w == 9 && params->h == 7) || /* (3,2,3,2) */
+ (params->w == 7 && params->h == 9) || /* (2,3,2,3) */
+ (params->w == 7 && params->h == 7))) /* (2,2,2,2) */
+ return "This board type is only supported at "
+ "5x7, 5x9, 7x7, 7x9, and 9x9";
+ }
+
+ /*
+ * It might be possible to implement generalisations of
+ * Octagon, but only if I can find a proof that they're all
* soluble. For the moment, therefore, I'm going to disallow
- * them at any size other than the standard one.
+ * it at any size other than the standard one.
*/
- if (full && (params->type == TYPE_CROSS || params->type == TYPE_OCTAGON)) {
+ if (full && params->type == TYPE_OCTAGON) {
if (params->w != 7 || params->h != 7)
return "This board type is only supported at 7x7";
}
diff --git a/puzzles.but b/puzzles.but
index d56d26c..095be0b 100644
--- a/puzzles.but
+++ b/puzzles.but
@@ -1446,8 +1446,9 @@ These parameters are available from the \q{Custom...} option on the
\dd Controls whether you are given a board of a standard shape or a
randomly generated shape. The two standard shapes currently
-supported are \q{Cross} and \q{Octagon} (also commonly known as the
-English and European traditional board layouts respectively).
+supported are \q{Cross} (in various sizes) and \q{Octagon}.
+The 7\by\.7 Cross is the traditional English board layout.
+The Octagon is the traditional French one.
Selecting \q{Random} will give you a different board shape every
time (but always one that is known to have a solution).