2 * sixteen.c: `16-puzzle', a sliding-tiles jigsaw which differs
3 * from the 15-puzzle in that you toroidally rotate a row or column
16 #define PREFERRED_TILE_SIZE 48
17 #define TILE_SIZE (ds->tilesize)
18 #define BORDER TILE_SIZE
19 #define HIGHLIGHT_WIDTH (TILE_SIZE / 20)
20 #define COORD(x) ( (x) * TILE_SIZE + BORDER )
21 #define FROMCOORD(x) ( ((x) - BORDER + 2*TILE_SIZE) / TILE_SIZE - 2 )
23 #define ANIM_TIME 0.13F
24 #define FLASH_FRAME 0.13F
26 #define X(state, i) ( (i) % (state)->w )
27 #define Y(state, i) ( (i) / (state)->w )
28 #define C(state, x, y) ( (y) * (state)->w + (x) )
47 int just_used_solve
; /* used to suppress undo animation */
48 int used_solve
; /* used to suppress completion flash */
49 int movecount
, movetarget
;
50 int last_movement_sense
;
53 static game_params
*default_params(void)
55 game_params
*ret
= snew(game_params
);
63 static int game_fetch_preset(int i
, char **name
, game_params
**params
)
70 case 0: w
= 3, h
= 3; break;
71 case 1: w
= 4, h
= 3; break;
72 case 2: w
= 4, h
= 4; break;
73 case 3: w
= 5, h
= 4; break;
74 case 4: w
= 5, h
= 5; break;
75 default: return FALSE
;
78 sprintf(buf
, "%dx%d", w
, h
);
80 *params
= ret
= snew(game_params
);
87 static void free_params(game_params
*params
)
92 static game_params
*dup_params(game_params
*params
)
94 game_params
*ret
= snew(game_params
);
95 *ret
= *params
; /* structure copy */
99 static void decode_params(game_params
*ret
, char const *string
)
101 ret
->w
= ret
->h
= atoi(string
);
103 while (*string
&& isdigit(*string
)) string
++;
104 if (*string
== 'x') {
106 ret
->h
= atoi(string
);
107 while (*string
&& isdigit((unsigned char)*string
))
110 if (*string
== 'm') {
112 ret
->movetarget
= atoi(string
);
113 while (*string
&& isdigit((unsigned char)*string
))
118 static char *encode_params(game_params
*params
, int full
)
122 sprintf(data
, "%dx%d", params
->w
, params
->h
);
123 /* Shuffle limit is part of the limited parameters, because we have to
124 * supply the target move count. */
125 if (params
->movetarget
)
126 sprintf(data
+ strlen(data
), "m%d", params
->movetarget
);
131 static config_item
*game_configure(game_params
*params
)
136 ret
= snewn(4, config_item
);
138 ret
[0].name
= "Width";
139 ret
[0].type
= C_STRING
;
140 sprintf(buf
, "%d", params
->w
);
141 ret
[0].sval
= dupstr(buf
);
144 ret
[1].name
= "Height";
145 ret
[1].type
= C_STRING
;
146 sprintf(buf
, "%d", params
->h
);
147 ret
[1].sval
= dupstr(buf
);
150 ret
[2].name
= "Number of shuffling moves";
151 ret
[2].type
= C_STRING
;
152 sprintf(buf
, "%d", params
->movetarget
);
153 ret
[2].sval
= dupstr(buf
);
164 static game_params
*custom_params(config_item
*cfg
)
166 game_params
*ret
= snew(game_params
);
168 ret
->w
= atoi(cfg
[0].sval
);
169 ret
->h
= atoi(cfg
[1].sval
);
170 ret
->movetarget
= atoi(cfg
[2].sval
);
175 static char *validate_params(game_params
*params
)
177 if (params
->w
< 2 || params
->h
< 2)
178 return "Width and height must both be at least two";
183 static int perm_parity(int *perm
, int n
)
189 for (i
= 0; i
< n
-1; i
++)
190 for (j
= i
+1; j
< n
; j
++)
191 if (perm
[i
] > perm
[j
])
197 static char *new_game_desc(game_params
*params
, random_state
*rs
,
198 game_aux_info
**aux
, int interactive
)
206 n
= params
->w
* params
->h
;
208 tiles
= snewn(n
, int);
210 if (params
->movetarget
) {
212 int max
= (params
->w
> params
->h ? params
->w
: params
->h
);
213 int *prevmoves
= snewn(max
, int);
216 * Shuffle the old-fashioned way, by making a series of
217 * single moves on the grid.
220 for (i
= 0; i
< n
; i
++)
223 for (i
= 0; i
< params
->movetarget
; i
++) {
224 int start
, offset
, len
, direction
, index
;
228 * Choose a move to make. We can choose from any row
232 j
= random_upto(rs
, params
->w
+ params
->h
);
242 index
= j
- params
->w
;
243 start
= index
* params
->w
;
248 direction
= -1 + 2 * random_upto(rs
, 2);
251 * To at least _try_ to avoid boring cases, check
252 * that this move doesn't directly undo a previous
253 * one, or repeat it so many times as to turn it
254 * into fewer moves in the opposite direction. (For
255 * example, in a row of length 4, we're allowed to
256 * move it the same way twice, but not three
259 * We track this for each individual row/column,
260 * and clear all the counters as soon as a
261 * perpendicular move is made. This isn't perfect
262 * (it _can't_ guaranteeably be perfect - there
263 * will always come a move count beyond which a
264 * shorter solution will be possible than the one
265 * which constructed the position) but it should
266 * sort out all the obvious cases.
268 if (offset
== prevoffset
) {
269 tmp
= prevmoves
[index
] + direction
;
270 if (abs(2*tmp
) > len
|| abs(tmp
) < abs(prevmoves
[index
]))
274 /* If we didn't `continue', we've found an OK move to make. */
275 if (offset
!= prevoffset
) {
277 for (i
= 0; i
< max
; i
++)
281 prevmoves
[index
] += direction
;
289 start
+= (len
-1) * offset
;
293 for (j
= 0; j
+1 < len
; j
++)
294 tiles
[start
+ j
*offset
] = tiles
[start
+ (j
+1)*offset
];
295 tiles
[start
+ (len
-1) * offset
] = tmp
;
302 used
= snewn(n
, int);
304 for (i
= 0; i
< n
; i
++) {
310 * If both dimensions are odd, there is a parity
313 if (params
->w
& params
->h
& 1)
319 * Place everything except (possibly) the last two tiles.
321 for (x
= 0, i
= n
; i
> stop
; i
--) {
322 int k
= i
> 1 ?
random_upto(rs
, i
) : 0;
325 for (j
= 0; j
< n
; j
++)
326 if (!used
[j
] && (k
-- == 0))
329 assert(j
< n
&& !used
[j
]);
332 while (tiles
[x
] >= 0)
340 * Find the last two locations, and the last two
343 while (tiles
[x
] >= 0)
348 while (tiles
[x
] >= 0)
353 for (i
= 0; i
< n
; i
++)
357 for (i
= p1
+1; i
< n
; i
++)
363 * Try the last two tiles one way round. If that fails,
368 if (perm_parity(tiles
, n
) != 0) {
371 assert(perm_parity(tiles
, n
) == 0);
379 * Now construct the game description, by describing the tile
380 * array as a simple sequence of comma-separated integers.
384 for (i
= 0; i
< n
; i
++) {
388 k
= sprintf(buf
, "%d,", tiles
[i
]+1);
390 ret
= sresize(ret
, retlen
+ k
+ 1, char);
391 strcpy(ret
+ retlen
, buf
);
394 ret
[retlen
-1] = '\0'; /* delete last comma */
401 static void game_free_aux_info(game_aux_info
*aux
)
403 assert(!"Shouldn't happen");
407 static char *validate_desc(game_params
*params
, char *desc
)
413 area
= params
->w
* params
->h
;
417 used
= snewn(area
, int);
418 for (i
= 0; i
< area
; i
++)
421 for (i
= 0; i
< area
; i
++) {
425 if (*p
< '0' || *p
> '9') {
426 err
= "Not enough numbers in string";
429 while (*p
>= '0' && *p
<= '9')
431 if (i
< area
-1 && *p
!= ',') {
432 err
= "Expected comma after number";
435 else if (i
== area
-1 && *p
) {
436 err
= "Excess junk at end of string";
440 if (n
< 1 || n
> area
) {
441 err
= "Number out of range";
445 err
= "Number used twice";
450 if (*p
) p
++; /* eat comma */
458 static game_state
*new_game(midend_data
*me
, game_params
*params
, char *desc
)
460 game_state
*state
= snew(game_state
);
464 state
->w
= params
->w
;
465 state
->h
= params
->h
;
466 state
->n
= params
->w
* params
->h
;
467 state
->tiles
= snewn(state
->n
, int);
471 for (i
= 0; i
< state
->n
; i
++) {
473 state
->tiles
[i
] = atoi(p
);
474 while (*p
&& *p
!= ',')
476 if (*p
) p
++; /* eat comma */
480 state
->completed
= state
->movecount
= 0;
481 state
->movetarget
= params
->movetarget
;
482 state
->used_solve
= state
->just_used_solve
= FALSE
;
483 state
->last_movement_sense
= 0;
488 static game_state
*dup_game(game_state
*state
)
490 game_state
*ret
= snew(game_state
);
495 ret
->tiles
= snewn(state
->w
* state
->h
, int);
496 memcpy(ret
->tiles
, state
->tiles
, state
->w
* state
->h
* sizeof(int));
497 ret
->completed
= state
->completed
;
498 ret
->movecount
= state
->movecount
;
499 ret
->movetarget
= state
->movetarget
;
500 ret
->used_solve
= state
->used_solve
;
501 ret
->just_used_solve
= state
->just_used_solve
;
502 ret
->last_movement_sense
= state
->last_movement_sense
;
507 static void free_game(game_state
*state
)
513 static char *solve_game(game_state
*state
, game_state
*currstate
,
514 game_aux_info
*aux
, char **error
)
519 static char *game_text_format(game_state
*state
)
521 char *ret
, *p
, buf
[80];
522 int x
, y
, col
, maxlen
;
525 * First work out how many characters we need to display each
528 col
= sprintf(buf
, "%d", state
->n
);
531 * Now we know the exact total size of the grid we're going to
532 * produce: it's got h rows, each containing w lots of col, w-1
533 * spaces and a trailing newline.
535 maxlen
= state
->h
* state
->w
* (col
+1);
537 ret
= snewn(maxlen
+1, char);
540 for (y
= 0; y
< state
->h
; y
++) {
541 for (x
= 0; x
< state
->w
; x
++) {
542 int v
= state
->tiles
[state
->w
*y
+x
];
543 sprintf(buf
, "%*d", col
, v
);
553 assert(p
- ret
== maxlen
);
558 static game_ui
*new_ui(game_state
*state
)
563 static void free_ui(game_ui
*ui
)
567 static void game_changed_state(game_ui
*ui
, game_state
*oldstate
,
568 game_state
*newstate
)
572 struct game_drawstate
{
579 static char *interpret_move(game_state
*state
, game_ui
*ui
, game_drawstate
*ds
,
580 int x
, int y
, int button
)
586 if (button
!= LEFT_BUTTON
&& button
!= RIGHT_BUTTON
)
591 if (cx
== -1 && cy
>= 0 && cy
< state
->h
)
593 else if (cx
== state
->w
&& cy
>= 0 && cy
< state
->h
)
595 else if (cy
== -1 && cx
>= 0 && cx
< state
->w
)
597 else if (cy
== state
->h
&& cx
>= 0 && cx
< state
->w
)
600 return NULL
; /* invalid click location */
602 /* reverse direction if right hand button is pressed */
603 if (button
== RIGHT_BUTTON
) {
609 sprintf(buf
, "R%d,%d", cy
, dx
);
611 sprintf(buf
, "C%d,%d", cx
, dy
);
615 static game_state
*execute_move(game_state
*from
, char *move
)
621 if (!strcmp(move
, "S")) {
624 ret
= dup_game(from
);
627 * Simply replace the grid with a solved one. For this game,
628 * this isn't a useful operation for actually telling the user
629 * what they should have done, but it is useful for
630 * conveniently being able to get hold of a clean state from
631 * which to practise manoeuvres.
633 for (i
= 0; i
< ret
->n
; i
++)
635 ret
->used_solve
= ret
->just_used_solve
= TRUE
;
636 ret
->completed
= ret
->movecount
= 1;
641 if (move
[0] == 'R' && sscanf(move
+1, "%d,%d", &cy
, &dx
) == 2 &&
642 cy
>= 0 && cy
< from
->h
) {
645 } else if (move
[0] == 'C' && sscanf(move
+1, "%d,%d", &cx
, &dy
) == 2 &&
646 cx
>= 0 && cx
< from
->w
) {
652 ret
= dup_game(from
);
653 ret
->just_used_solve
= FALSE
; /* zero this in a hurry */
656 tx
= (cx
- dx
+ from
->w
) % from
->w
;
657 ty
= (cy
- dy
+ from
->h
) % from
->h
;
658 ret
->tiles
[C(ret
, cx
, cy
)] = from
->tiles
[C(from
, tx
, ty
)];
665 ret
->last_movement_sense
= dx
+dy
;
668 * See if the game has been completed.
670 if (!ret
->completed
) {
671 ret
->completed
= ret
->movecount
;
672 for (n
= 0; n
< ret
->n
; n
++)
673 if (ret
->tiles
[n
] != n
+1)
674 ret
->completed
= FALSE
;
680 /* ----------------------------------------------------------------------
684 static void game_size(game_params
*params
, game_drawstate
*ds
,
685 int *x
, int *y
, int expand
)
689 * Each window dimension equals the tile size times two more
690 * than the grid dimension (the border is the same size as the
693 tsx
= *x
/ (params
->w
+ 2);
694 tsy
= *y
/ (params
->h
+ 2);
700 ds
->tilesize
= min(ts
, PREFERRED_TILE_SIZE
);
702 *x
= TILE_SIZE
* params
->w
+ 2 * BORDER
;
703 *y
= TILE_SIZE
* params
->h
+ 2 * BORDER
;
706 static float *game_colours(frontend
*fe
, game_state
*state
, int *ncolours
)
708 float *ret
= snewn(3 * NCOLOURS
, float);
712 frontend_default_colour(fe
, &ret
[COL_BACKGROUND
* 3]);
715 * Drop the background colour so that the highlight is
716 * noticeably brighter than it while still being under 1.
718 max
= ret
[COL_BACKGROUND
*3];
719 for (i
= 1; i
< 3; i
++)
720 if (ret
[COL_BACKGROUND
*3+i
] > max
)
721 max
= ret
[COL_BACKGROUND
*3+i
];
722 if (max
* 1.2F
> 1.0F
) {
723 for (i
= 0; i
< 3; i
++)
724 ret
[COL_BACKGROUND
*3+i
] /= (max
* 1.2F
);
727 for (i
= 0; i
< 3; i
++) {
728 ret
[COL_HIGHLIGHT
* 3 + i
] = ret
[COL_BACKGROUND
* 3 + i
] * 1.2F
;
729 ret
[COL_LOWLIGHT
* 3 + i
] = ret
[COL_BACKGROUND
* 3 + i
] * 0.8F
;
730 ret
[COL_TEXT
* 3 + i
] = 0.0;
733 *ncolours
= NCOLOURS
;
737 static game_drawstate
*game_new_drawstate(game_state
*state
)
739 struct game_drawstate
*ds
= snew(struct game_drawstate
);
745 ds
->bgcolour
= COL_BACKGROUND
;
746 ds
->tiles
= snewn(ds
->w
*ds
->h
, int);
747 ds
->tilesize
= 0; /* haven't decided yet */
748 for (i
= 0; i
< ds
->w
*ds
->h
; i
++)
754 static void game_free_drawstate(game_drawstate
*ds
)
760 static void draw_tile(frontend
*fe
, game_drawstate
*ds
,
761 game_state
*state
, int x
, int y
,
762 int tile
, int flash_colour
)
765 draw_rect(fe
, x
, y
, TILE_SIZE
, TILE_SIZE
,
771 coords
[0] = x
+ TILE_SIZE
- 1;
772 coords
[1] = y
+ TILE_SIZE
- 1;
773 coords
[2] = x
+ TILE_SIZE
- 1;
776 coords
[5] = y
+ TILE_SIZE
- 1;
777 draw_polygon(fe
, coords
, 3, TRUE
, COL_LOWLIGHT
);
778 draw_polygon(fe
, coords
, 3, FALSE
, COL_LOWLIGHT
);
782 draw_polygon(fe
, coords
, 3, TRUE
, COL_HIGHLIGHT
);
783 draw_polygon(fe
, coords
, 3, FALSE
, COL_HIGHLIGHT
);
785 draw_rect(fe
, x
+ HIGHLIGHT_WIDTH
, y
+ HIGHLIGHT_WIDTH
,
786 TILE_SIZE
- 2*HIGHLIGHT_WIDTH
, TILE_SIZE
- 2*HIGHLIGHT_WIDTH
,
789 sprintf(str
, "%d", tile
);
790 draw_text(fe
, x
+ TILE_SIZE
/2, y
+ TILE_SIZE
/2,
791 FONT_VARIABLE
, TILE_SIZE
/3, ALIGN_VCENTRE
| ALIGN_HCENTRE
,
794 draw_update(fe
, x
, y
, TILE_SIZE
, TILE_SIZE
);
797 static void draw_arrow(frontend
*fe
, game_drawstate
*ds
,
798 int x
, int y
, int xdx
, int xdy
)
801 int ydy
= -xdx
, ydx
= xdy
;
803 #define POINT(n, xx, yy) ( \
804 coords[2*(n)+0] = x + (xx)*xdx + (yy)*ydx, \
805 coords[2*(n)+1] = y + (xx)*xdy + (yy)*ydy)
807 POINT(0, TILE_SIZE
/ 2, 3 * TILE_SIZE
/ 4); /* top of arrow */
808 POINT(1, 3 * TILE_SIZE
/ 4, TILE_SIZE
/ 2); /* right corner */
809 POINT(2, 5 * TILE_SIZE
/ 8, TILE_SIZE
/ 2); /* right concave */
810 POINT(3, 5 * TILE_SIZE
/ 8, TILE_SIZE
/ 4); /* bottom right */
811 POINT(4, 3 * TILE_SIZE
/ 8, TILE_SIZE
/ 4); /* bottom left */
812 POINT(5, 3 * TILE_SIZE
/ 8, TILE_SIZE
/ 2); /* left concave */
813 POINT(6, TILE_SIZE
/ 4, TILE_SIZE
/ 2); /* left corner */
815 draw_polygon(fe
, coords
, 7, TRUE
, COL_LOWLIGHT
);
816 draw_polygon(fe
, coords
, 7, FALSE
, COL_TEXT
);
819 static void game_redraw(frontend
*fe
, game_drawstate
*ds
, game_state
*oldstate
,
820 game_state
*state
, int dir
, game_ui
*ui
,
821 float animtime
, float flashtime
)
826 int frame
= (int)(flashtime
/ FLASH_FRAME
);
827 bgcolour
= (frame
% 2 ? COL_LOWLIGHT
: COL_HIGHLIGHT
);
829 bgcolour
= COL_BACKGROUND
;
835 TILE_SIZE
* state
->w
+ 2 * BORDER
,
836 TILE_SIZE
* state
->h
+ 2 * BORDER
, COL_BACKGROUND
);
837 draw_update(fe
, 0, 0,
838 TILE_SIZE
* state
->w
+ 2 * BORDER
,
839 TILE_SIZE
* state
->h
+ 2 * BORDER
);
842 * Recessed area containing the whole puzzle.
844 coords
[0] = COORD(state
->w
) + HIGHLIGHT_WIDTH
- 1;
845 coords
[1] = COORD(state
->h
) + HIGHLIGHT_WIDTH
- 1;
846 coords
[2] = COORD(state
->w
) + HIGHLIGHT_WIDTH
- 1;
847 coords
[3] = COORD(0) - HIGHLIGHT_WIDTH
;
848 coords
[4] = coords
[2] - TILE_SIZE
;
849 coords
[5] = coords
[3] + TILE_SIZE
;
850 coords
[8] = COORD(0) - HIGHLIGHT_WIDTH
;
851 coords
[9] = COORD(state
->h
) + HIGHLIGHT_WIDTH
- 1;
852 coords
[6] = coords
[8] + TILE_SIZE
;
853 coords
[7] = coords
[9] - TILE_SIZE
;
854 draw_polygon(fe
, coords
, 5, TRUE
, COL_HIGHLIGHT
);
855 draw_polygon(fe
, coords
, 5, FALSE
, COL_HIGHLIGHT
);
857 coords
[1] = COORD(0) - HIGHLIGHT_WIDTH
;
858 coords
[0] = COORD(0) - HIGHLIGHT_WIDTH
;
859 draw_polygon(fe
, coords
, 5, TRUE
, COL_LOWLIGHT
);
860 draw_polygon(fe
, coords
, 5, FALSE
, COL_LOWLIGHT
);
863 * Arrows for making moves.
865 for (i
= 0; i
< state
->w
; i
++) {
866 draw_arrow(fe
, ds
, COORD(i
), COORD(0), +1, 0);
867 draw_arrow(fe
, ds
, COORD(i
+1), COORD(state
->h
), -1, 0);
869 for (i
= 0; i
< state
->h
; i
++) {
870 draw_arrow(fe
, ds
, COORD(state
->w
), COORD(i
), 0, +1);
871 draw_arrow(fe
, ds
, COORD(0), COORD(i
+1), 0, -1);
878 * Now draw each tile.
881 clip(fe
, COORD(0), COORD(0), TILE_SIZE
*state
->w
, TILE_SIZE
*state
->h
);
883 for (i
= 0; i
< state
->n
; i
++) {
886 * Figure out what should be displayed at this
887 * location. It's either a simple tile, or it's a
888 * transition between two tiles (in which case we say
889 * -1 because it must always be drawn).
892 if (oldstate
&& oldstate
->tiles
[i
] != state
->tiles
[i
])
899 if (ds
->bgcolour
!= bgcolour
|| /* always redraw when flashing */
900 ds
->tiles
[i
] != t
|| ds
->tiles
[i
] == -1 || t
== -1) {
904 * Figure out what to _actually_ draw, and where to
908 int x0
, y0
, x1
, y1
, dx
, dy
;
915 sense
= -oldstate
->last_movement_sense
;
917 sense
= state
->last_movement_sense
;
923 * FIXME: must be prepared to draw a double
924 * tile in some situations.
928 * Find the coordinates of this tile in the old and
931 x1
= COORD(X(state
, i
));
932 y1
= COORD(Y(state
, i
));
933 for (j
= 0; j
< oldstate
->n
; j
++)
934 if (oldstate
->tiles
[j
] == state
->tiles
[i
])
936 assert(j
< oldstate
->n
);
937 x0
= COORD(X(state
, j
));
938 y0
= COORD(Y(state
, j
));
942 dx
!= TILE_SIZE
* sense
) {
943 dx
= (dx
< 0 ? dx
+ TILE_SIZE
* state
->w
:
944 dx
- TILE_SIZE
* state
->w
);
945 assert(abs(dx
) == TILE_SIZE
);
949 dy
!= TILE_SIZE
* sense
) {
950 dy
= (dy
< 0 ? dy
+ TILE_SIZE
* state
->h
:
951 dy
- TILE_SIZE
* state
->h
);
952 assert(abs(dy
) == TILE_SIZE
);
955 c
= (animtime
/ ANIM_TIME
);
956 if (c
< 0.0F
) c
= 0.0F
;
957 if (c
> 1.0F
) c
= 1.0F
;
959 x
= x0
+ (int)(c
* dx
);
960 y
= y0
+ (int)(c
* dy
);
961 x2
= x1
- dx
+ (int)(c
* dx
);
962 y2
= y1
- dy
+ (int)(c
* dy
);
964 x
= COORD(X(state
, i
));
965 y
= COORD(Y(state
, i
));
969 draw_tile(fe
, ds
, state
, x
, y
, t
, bgcolour
);
970 if (x2
!= -1 || y2
!= -1)
971 draw_tile(fe
, ds
, state
, x2
, y2
, t
, bgcolour
);
978 ds
->bgcolour
= bgcolour
;
981 * Update the status bar.
987 * Don't show the new status until we're also showing the
988 * new _state_ - after the game animation is complete.
993 if (state
->used_solve
)
994 sprintf(statusbuf
, "Moves since auto-solve: %d",
995 state
->movecount
- state
->completed
);
997 sprintf(statusbuf
, "%sMoves: %d",
998 (state
->completed ?
"COMPLETED! " : ""),
999 (state
->completed ? state
->completed
: state
->movecount
));
1000 if (state
->movetarget
)
1001 sprintf(statusbuf
+strlen(statusbuf
), " (target %d)",
1005 status_bar(fe
, statusbuf
);
1009 static float game_anim_length(game_state
*oldstate
,
1010 game_state
*newstate
, int dir
, game_ui
*ui
)
1012 if ((dir
> 0 && newstate
->just_used_solve
) ||
1013 (dir
< 0 && oldstate
->just_used_solve
))
1019 static float game_flash_length(game_state
*oldstate
,
1020 game_state
*newstate
, int dir
, game_ui
*ui
)
1022 if (!oldstate
->completed
&& newstate
->completed
&&
1023 !oldstate
->used_solve
&& !newstate
->used_solve
)
1024 return 2 * FLASH_FRAME
;
1029 static int game_wants_statusbar(void)
1034 static int game_timing_state(game_state
*state
)
1040 #define thegame sixteen
1043 const struct game thegame
= {
1044 "Sixteen", "games.sixteen",
1051 TRUE
, game_configure
, custom_params
,
1060 TRUE
, game_text_format
,
1069 game_free_drawstate
,
1073 game_wants_statusbar
,
1074 FALSE
, game_timing_state
,
1075 0, /* mouse_priorities */