New puzzle from James Harvey: 'Singles', an implementation of

Hitori. One infrastructure change in the process: latin.c has
acquired a utility function to generate a latin rectangle rather
than a full square.

[originally from svn r8828]
This commit is contained in:
Simon Tatham
2010-01-11 21:21:07 +00:00
parent 771f5446a8
commit 58e0d0bc2d
7 changed files with 2106 additions and 2 deletions

View File

@ -2,8 +2,8 @@
PUZZLES = blackbox bridges cube dominosa fifteen filling flip galaxies guess \
inertia keen lightup loopy map mines net netslide pattern pegs \
rect samegame sixteen slant solo tents towers twiddle unequal \
untangle
rect samegame singles sixteen slant solo tents towers twiddle \
unequal untangle
BASE = $(patsubst %,%-base.png,$(PUZZLES))
WEB = $(patsubst %,%-web.png,$(PUZZLES))
@ -70,6 +70,7 @@ netslide-ibase.png : override CROP=289x289 144x144+0+0
pattern-ibase.png : override CROP=384x384 223x223+0+0
pegs-ibase.png : override CROP=263x263 147x147+116+0
rect-ibase.png : override CROP=205x205 115x115+90+0
singles-ibase.png : override CROP=224x224 98x98+15+15
sixteen-ibase.png : override CROP=288x288 144x144+144+144
slant-ibase.png : override CROP=321x321 160x160+160+160
solo-ibase.png : override CROP=481x481 145x145+24+24

45
icons/singles.sav Normal file
View File

@ -0,0 +1,45 @@
SAVEFILE:41:Simon Tatham's Portable Puzzle Collection
VERSION :1:1
GAME :7:Singles
PARAMS :5:6x6dk
CPARAMS :5:6x6dk
SEED :15:781273601054598
DESC :36:361566412253452144234115163346553461
NSTATES :2:37
STATEPOS:2:22
MOVE :4:B1,0
MOVE :4:C0,0
MOVE :4:C1,1
MOVE :4:C2,0
MOVE :4:C0,1
MOVE :4:B0,2
MOVE :4:C0,3
MOVE :4:C1,2
MOVE :4:C4,3
MOVE :4:B3,3
MOVE :4:C3,2
MOVE :4:C2,3
MOVE :4:C3,4
MOVE :4:B2,4
MOVE :4:C1,4
MOVE :4:C2,5
MOVE :4:B1,5
MOVE :4:C0,5
MOVE :4:C0,4
MOVE :4:C1,3
MOVE :4:C3,5
MOVE :4:B5,4
MOVE :4:C4,4
MOVE :4:C5,5
MOVE :4:C5,3
MOVE :4:C4,5
MOVE :4:B4,0
MOVE :4:C3,0
MOVE :4:C4,1
MOVE :4:C5,0
MOVE :4:C5,1
MOVE :4:B4,2
MOVE :4:C5,2
MOVE :4:C3,1
MOVE :4:B2,1
MOVE :4:C2,2

18
latin.c
View File

@ -1236,6 +1236,24 @@ digit *latin_generate(int o, random_state *rs)
return sq;
}
digit *latin_generate_rect(int w, int h, random_state *rs)
{
int o = max(w, h), x, y;
digit *latin, *latin_rect;
latin = latin_generate(o, rs);
latin_rect = snewn(w*h, digit);
for (x = 0; x < w; x++) {
for (y = 0; y < h; y++) {
latin_rect[y*w + x] = latin[y*o + x];
}
}
sfree(latin);
return latin_rect;
}
/* --------------------------------------------------------
* Checking.
*/

View File

@ -112,6 +112,9 @@ void latin_solver_debug(unsigned char *cube, int o);
digit *latin_generate(int o, random_state *rs);
/* The order of the latin rectangle is max(w,h). */
digit *latin_generate_rect(int w, int h, random_state *rs);
int latin_check(digit *sq, int order); /* !0 => not a latin square */
void latin_debug(digit *sq, int order);

View File

@ -2651,6 +2651,57 @@ level, some backtracking will be required, but the solution should
still be unique. The remaining levels require increasingly complex
reasoning to avoid having to backtrack.
\C{singles} \i{Singles}
\cfg{winhelp-topic}{games.singles}
You have a grid of squares, all of which contain numbers. Your task
is to colour some of the squares black (removing the number) so as to satisfy
all of the following conditions:
\b No number occurs more than once in any row or column.
\b No black square is horizontally adjacent to any other black square.
\b The remaining white squares must all form one contiguous region.
Credit for this puzzle goes to \i{Nikoli} \k{nikoli-singles} who call it Hitori.
Singles was contributed to this collection by James Harvey.
\B{nikoli-hitori}
\W{http://www.nikoli.com/en/puzzles/hitori/index.html}\cw{http://www.nikoli.com/en/puzzles/hitori/index.html}
(beware of Flash)
\H{singles-controls} \i{Singles controls}
\IM{Singles controls} controls, for Singles
Left-clicking on an empty square will colour it black; left-clicking again
will replace the number. Right-clicking will add a circle (useful for
indicating that a cell is definitely not black).
You can also use the cursor keys to move around the grid. Pressing the
return or space keys will turn a square black or add a circle respectively,
and pressing the key again will replace the number or remove the circle.
(All the actions described in \k{common-actions} are also available.)
\H{singles-parameters} \I{parameters, for Singles}Singles parameters
These parameters are available from the \q{Custom...} option on the
\q{Type} menu.
\dt \e{Width}, \e{Height}
\dd Size of grid in squares.
\dt \e{Difficulty}
\dd Controls the difficulty of the generated puzzle.
\A{licence} \I{MIT licence}\ii{Licence}
This software is \i{copyright} 2004-2010 Simon Tatham.

23
singles.R Normal file
View File

@ -0,0 +1,23 @@
# -*- makefile -*-
SINGLES_EXTRA = dsf latin maxflow tree234
singles : [X] GTK COMMON singles SINGLES_EXTRA singles-icon|no-icon
singles : [G] WINDOWS COMMON singles SINGLES_EXTRA singles.res|noicon.res
ALL += singles[COMBINED] SINGLES_EXTRA
singlessolver : [U] singles[STANDALONE_SOLVER] SINGLES_EXTRA STANDALONE
singlessolver : [C] singles[STANDALONE_SOLVER] SINGLES_EXTRA STANDALONE
!begin gtk
GAMES += singles
!end
!begin >list.c
A(singles) \
!end
!begin >wingames.lst
singles.exe:Singles
!end

1963
singles.c Normal file

File diff suppressed because it is too large Load Diff