Introduce the concept of a `game_aux_info' structure. This is
[sgt/puzzles] / sixteen.c
1 /*
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
4 * at a time.
5 */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <assert.h>
11 #include <ctype.h>
12 #include <math.h>
13
14 #include "puzzles.h"
15
16 #define TILE_SIZE 48
17 #define BORDER TILE_SIZE /* big border to fill with arrows */
18 #define HIGHLIGHT_WIDTH (TILE_SIZE / 20)
19 #define COORD(x) ( (x) * TILE_SIZE + BORDER )
20 #define FROMCOORD(x) ( ((x) - BORDER + 2*TILE_SIZE) / TILE_SIZE - 2 )
21
22 #define ANIM_TIME 0.13F
23 #define FLASH_FRAME 0.13F
24
25 #define X(state, i) ( (i) % (state)->w )
26 #define Y(state, i) ( (i) / (state)->w )
27 #define C(state, x, y) ( (y) * (state)->w + (x) )
28
29 enum {
30 COL_BACKGROUND,
31 COL_TEXT,
32 COL_HIGHLIGHT,
33 COL_LOWLIGHT,
34 NCOLOURS
35 };
36
37 struct game_params {
38 int w, h;
39 };
40
41 struct game_state {
42 int w, h, n;
43 int *tiles;
44 int completed;
45 int movecount;
46 int last_movement_sense;
47 };
48
49 static game_params *default_params(void)
50 {
51 game_params *ret = snew(game_params);
52
53 ret->w = ret->h = 4;
54
55 return ret;
56 }
57
58 static int game_fetch_preset(int i, char **name, game_params **params)
59 {
60 game_params *ret;
61 int w, h;
62 char buf[80];
63
64 switch (i) {
65 case 0: w = 3, h = 3; break;
66 case 1: w = 4, h = 3; break;
67 case 2: w = 4, h = 4; break;
68 case 3: w = 5, h = 4; break;
69 case 4: w = 5, h = 5; break;
70 default: return FALSE;
71 }
72
73 sprintf(buf, "%dx%d", w, h);
74 *name = dupstr(buf);
75 *params = ret = snew(game_params);
76 ret->w = w;
77 ret->h = h;
78 return TRUE;
79 }
80
81 static void free_params(game_params *params)
82 {
83 sfree(params);
84 }
85
86 static game_params *dup_params(game_params *params)
87 {
88 game_params *ret = snew(game_params);
89 *ret = *params; /* structure copy */
90 return ret;
91 }
92
93 static game_params *decode_params(char const *string)
94 {
95 game_params *ret = default_params();
96
97 ret->w = ret->h = atoi(string);
98 while (*string && isdigit(*string)) string++;
99 if (*string == 'x') {
100 string++;
101 ret->h = atoi(string);
102 }
103
104 return ret;
105 }
106
107 static char *encode_params(game_params *params)
108 {
109 char data[256];
110
111 sprintf(data, "%dx%d", params->w, params->h);
112
113 return dupstr(data);
114 }
115
116 static config_item *game_configure(game_params *params)
117 {
118 config_item *ret;
119 char buf[80];
120
121 ret = snewn(3, config_item);
122
123 ret[0].name = "Width";
124 ret[0].type = C_STRING;
125 sprintf(buf, "%d", params->w);
126 ret[0].sval = dupstr(buf);
127 ret[0].ival = 0;
128
129 ret[1].name = "Height";
130 ret[1].type = C_STRING;
131 sprintf(buf, "%d", params->h);
132 ret[1].sval = dupstr(buf);
133 ret[1].ival = 0;
134
135 ret[2].name = NULL;
136 ret[2].type = C_END;
137 ret[2].sval = NULL;
138 ret[2].ival = 0;
139
140 return ret;
141 }
142
143 static game_params *custom_params(config_item *cfg)
144 {
145 game_params *ret = snew(game_params);
146
147 ret->w = atoi(cfg[0].sval);
148 ret->h = atoi(cfg[1].sval);
149
150 return ret;
151 }
152
153 static char *validate_params(game_params *params)
154 {
155 if (params->w < 2 && params->h < 2)
156 return "Width and height must both be at least two";
157
158 return NULL;
159 }
160
161 static int perm_parity(int *perm, int n)
162 {
163 int i, j, ret;
164
165 ret = 0;
166
167 for (i = 0; i < n-1; i++)
168 for (j = i+1; j < n; j++)
169 if (perm[i] > perm[j])
170 ret = !ret;
171
172 return ret;
173 }
174
175 static char *new_game_seed(game_params *params, random_state *rs,
176 game_aux_info **aux)
177 {
178 int stop, n, i, x;
179 int x1, x2, p1, p2;
180 int *tiles, *used;
181 char *ret;
182 int retlen;
183
184 n = params->w * params->h;
185
186 tiles = snewn(n, int);
187 used = snewn(n, int);
188
189 for (i = 0; i < n; i++) {
190 tiles[i] = -1;
191 used[i] = FALSE;
192 }
193
194 /*
195 * If both dimensions are odd, there is a parity constraint.
196 */
197 if (params->w & params->h & 1)
198 stop = 2;
199 else
200 stop = 0;
201
202 /*
203 * Place everything except (possibly) the last two tiles.
204 */
205 for (x = 0, i = n; i > stop; i--) {
206 int k = i > 1 ? random_upto(rs, i) : 0;
207 int j;
208
209 for (j = 0; j < n; j++)
210 if (!used[j] && (k-- == 0))
211 break;
212
213 assert(j < n && !used[j]);
214 used[j] = TRUE;
215
216 while (tiles[x] >= 0)
217 x++;
218 assert(x < n);
219 tiles[x] = j;
220 }
221
222 if (stop) {
223 /*
224 * Find the last two locations, and the last two pieces.
225 */
226 while (tiles[x] >= 0)
227 x++;
228 assert(x < n);
229 x1 = x;
230 x++;
231 while (tiles[x] >= 0)
232 x++;
233 assert(x < n);
234 x2 = x;
235
236 for (i = 0; i < n; i++)
237 if (!used[i])
238 break;
239 p1 = i;
240 for (i = p1+1; i < n; i++)
241 if (!used[i])
242 break;
243 p2 = i;
244
245 /*
246 * Try the last two tiles one way round. If that fails, swap
247 * them.
248 */
249 tiles[x1] = p1;
250 tiles[x2] = p2;
251 if (perm_parity(tiles, n) != 0) {
252 tiles[x1] = p2;
253 tiles[x2] = p1;
254 assert(perm_parity(tiles, n) == 0);
255 }
256 }
257
258 /*
259 * Now construct the game seed, by describing the tile array as
260 * a simple sequence of comma-separated integers.
261 */
262 ret = NULL;
263 retlen = 0;
264 for (i = 0; i < n; i++) {
265 char buf[80];
266 int k;
267
268 k = sprintf(buf, "%d,", tiles[i]+1);
269
270 ret = sresize(ret, retlen + k + 1, char);
271 strcpy(ret + retlen, buf);
272 retlen += k;
273 }
274 ret[retlen-1] = '\0'; /* delete last comma */
275
276 sfree(tiles);
277 sfree(used);
278
279 return ret;
280 }
281
282 void game_free_aux_info(game_aux_info *aux)
283 {
284 assert(!"Shouldn't happen");
285 }
286
287
288 static char *validate_seed(game_params *params, char *seed)
289 {
290 char *p, *err;
291 int i, area;
292 int *used;
293
294 area = params->w * params->h;
295 p = seed;
296 err = NULL;
297
298 used = snewn(area, int);
299 for (i = 0; i < area; i++)
300 used[i] = FALSE;
301
302 for (i = 0; i < area; i++) {
303 char *q = p;
304 int n;
305
306 if (*p < '0' || *p > '9') {
307 err = "Not enough numbers in string";
308 goto leave;
309 }
310 while (*p >= '0' && *p <= '9')
311 p++;
312 if (i < area-1 && *p != ',') {
313 err = "Expected comma after number";
314 goto leave;
315 }
316 else if (i == area-1 && *p) {
317 err = "Excess junk at end of string";
318 goto leave;
319 }
320 n = atoi(q);
321 if (n < 1 || n > area) {
322 err = "Number out of range";
323 goto leave;
324 }
325 if (used[n-1]) {
326 err = "Number used twice";
327 goto leave;
328 }
329 used[n-1] = TRUE;
330
331 if (*p) p++; /* eat comma */
332 }
333
334 leave:
335 sfree(used);
336 return err;
337 }
338
339 static game_state *new_game(game_params *params, char *seed)
340 {
341 game_state *state = snew(game_state);
342 int i;
343 char *p;
344
345 state->w = params->w;
346 state->h = params->h;
347 state->n = params->w * params->h;
348 state->tiles = snewn(state->n, int);
349
350 p = seed;
351 i = 0;
352 for (i = 0; i < state->n; i++) {
353 assert(*p);
354 state->tiles[i] = atoi(p);
355 while (*p && *p != ',')
356 p++;
357 if (*p) p++; /* eat comma */
358 }
359 assert(!*p);
360
361 state->completed = state->movecount = 0;
362 state->last_movement_sense = 0;
363
364 return state;
365 }
366
367 static game_state *dup_game(game_state *state)
368 {
369 game_state *ret = snew(game_state);
370
371 ret->w = state->w;
372 ret->h = state->h;
373 ret->n = state->n;
374 ret->tiles = snewn(state->w * state->h, int);
375 memcpy(ret->tiles, state->tiles, state->w * state->h * sizeof(int));
376 ret->completed = state->completed;
377 ret->movecount = state->movecount;
378 ret->last_movement_sense = state->last_movement_sense;
379
380 return ret;
381 }
382
383 static void free_game(game_state *state)
384 {
385 sfree(state);
386 }
387
388 static char *game_text_format(game_state *state)
389 {
390 char *ret, *p, buf[80];
391 int x, y, col, maxlen;
392
393 /*
394 * First work out how many characters we need to display each
395 * number.
396 */
397 col = sprintf(buf, "%d", state->n);
398
399 /*
400 * Now we know the exact total size of the grid we're going to
401 * produce: it's got h rows, each containing w lots of col, w-1
402 * spaces and a trailing newline.
403 */
404 maxlen = state->h * state->w * (col+1);
405
406 ret = snewn(maxlen, char);
407 p = ret;
408
409 for (y = 0; y < state->h; y++) {
410 for (x = 0; x < state->w; x++) {
411 int v = state->tiles[state->w*y+x];
412 sprintf(buf, "%*d", col, v);
413 memcpy(p, buf, col);
414 p += col;
415 if (x+1 == state->w)
416 *p++ = '\n';
417 else
418 *p++ = ' ';
419 }
420 }
421
422 assert(p - ret == maxlen);
423 *p = '\0';
424 return ret;
425 }
426
427 static game_ui *new_ui(game_state *state)
428 {
429 return NULL;
430 }
431
432 static void free_ui(game_ui *ui)
433 {
434 }
435
436 static game_state *make_move(game_state *from, game_ui *ui,
437 int x, int y, int button)
438 {
439 int cx, cy;
440 int dx, dy, tx, ty, n;
441 game_state *ret;
442
443 if (button != LEFT_BUTTON && button != RIGHT_BUTTON)
444 return NULL;
445
446 cx = FROMCOORD(x);
447 cy = FROMCOORD(y);
448 if (cx == -1 && cy >= 0 && cy < from->h)
449 n = from->w, dx = +1, dy = 0;
450 else if (cx == from->w && cy >= 0 && cy < from->h)
451 n = from->w, dx = -1, dy = 0;
452 else if (cy == -1 && cx >= 0 && cx < from->w)
453 n = from->h, dy = +1, dx = 0;
454 else if (cy == from->h && cx >= 0 && cx < from->w)
455 n = from->h, dy = -1, dx = 0;
456 else
457 return NULL; /* invalid click location */
458
459 /* reverse direction if right hand button is pressed */
460 if (button == RIGHT_BUTTON)
461 {
462 dx = -dx; if (dx) cx = from->w - 1 - cx;
463 dy = -dy; if (dy) cy = from->h - 1 - cy;
464 }
465
466 ret = dup_game(from);
467
468 do {
469 cx += dx;
470 cy += dy;
471 tx = (cx + dx + from->w) % from->w;
472 ty = (cy + dy + from->h) % from->h;
473 ret->tiles[C(ret, cx, cy)] = from->tiles[C(from, tx, ty)];
474 } while (--n > 0);
475
476 ret->movecount++;
477
478 ret->last_movement_sense = -(dx+dy);
479
480 /*
481 * See if the game has been completed.
482 */
483 if (!ret->completed) {
484 ret->completed = ret->movecount;
485 for (n = 0; n < ret->n; n++)
486 if (ret->tiles[n] != n+1)
487 ret->completed = FALSE;
488 }
489
490 return ret;
491 }
492
493 /* ----------------------------------------------------------------------
494 * Drawing routines.
495 */
496
497 struct game_drawstate {
498 int started;
499 int w, h, bgcolour;
500 int *tiles;
501 };
502
503 static void game_size(game_params *params, int *x, int *y)
504 {
505 *x = TILE_SIZE * params->w + 2 * BORDER;
506 *y = TILE_SIZE * params->h + 2 * BORDER;
507 }
508
509 static float *game_colours(frontend *fe, game_state *state, int *ncolours)
510 {
511 float *ret = snewn(3 * NCOLOURS, float);
512 int i;
513 float max;
514
515 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
516
517 /*
518 * Drop the background colour so that the highlight is
519 * noticeably brighter than it while still being under 1.
520 */
521 max = ret[COL_BACKGROUND*3];
522 for (i = 1; i < 3; i++)
523 if (ret[COL_BACKGROUND*3+i] > max)
524 max = ret[COL_BACKGROUND*3+i];
525 if (max * 1.2F > 1.0F) {
526 for (i = 0; i < 3; i++)
527 ret[COL_BACKGROUND*3+i] /= (max * 1.2F);
528 }
529
530 for (i = 0; i < 3; i++) {
531 ret[COL_HIGHLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 1.2F;
532 ret[COL_LOWLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 0.8F;
533 ret[COL_TEXT * 3 + i] = 0.0;
534 }
535
536 *ncolours = NCOLOURS;
537 return ret;
538 }
539
540 static game_drawstate *game_new_drawstate(game_state *state)
541 {
542 struct game_drawstate *ds = snew(struct game_drawstate);
543 int i;
544
545 ds->started = FALSE;
546 ds->w = state->w;
547 ds->h = state->h;
548 ds->bgcolour = COL_BACKGROUND;
549 ds->tiles = snewn(ds->w*ds->h, int);
550 for (i = 0; i < ds->w*ds->h; i++)
551 ds->tiles[i] = -1;
552
553 return ds;
554 }
555
556 static void game_free_drawstate(game_drawstate *ds)
557 {
558 sfree(ds->tiles);
559 sfree(ds);
560 }
561
562 static void draw_tile(frontend *fe, game_state *state, int x, int y,
563 int tile, int flash_colour)
564 {
565 if (tile == 0) {
566 draw_rect(fe, x, y, TILE_SIZE, TILE_SIZE,
567 flash_colour);
568 } else {
569 int coords[6];
570 char str[40];
571
572 coords[0] = x + TILE_SIZE - 1;
573 coords[1] = y + TILE_SIZE - 1;
574 coords[2] = x + TILE_SIZE - 1;
575 coords[3] = y;
576 coords[4] = x;
577 coords[5] = y + TILE_SIZE - 1;
578 draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT);
579 draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT);
580
581 coords[0] = x;
582 coords[1] = y;
583 draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
584 draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT);
585
586 draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
587 TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
588 flash_colour);
589
590 sprintf(str, "%d", tile);
591 draw_text(fe, x + TILE_SIZE/2, y + TILE_SIZE/2,
592 FONT_VARIABLE, TILE_SIZE/3, ALIGN_VCENTRE | ALIGN_HCENTRE,
593 COL_TEXT, str);
594 }
595 draw_update(fe, x, y, TILE_SIZE, TILE_SIZE);
596 }
597
598 static void draw_arrow(frontend *fe, int x, int y, int xdx, int xdy)
599 {
600 int coords[14];
601 int ydy = -xdx, ydx = xdy;
602
603 #define POINT(n, xx, yy) ( \
604 coords[2*(n)+0] = x + (xx)*xdx + (yy)*ydx, \
605 coords[2*(n)+1] = y + (xx)*xdy + (yy)*ydy)
606
607 POINT(0, TILE_SIZE / 2, 3 * TILE_SIZE / 4); /* top of arrow */
608 POINT(1, 3 * TILE_SIZE / 4, TILE_SIZE / 2); /* right corner */
609 POINT(2, 5 * TILE_SIZE / 8, TILE_SIZE / 2); /* right concave */
610 POINT(3, 5 * TILE_SIZE / 8, TILE_SIZE / 4); /* bottom right */
611 POINT(4, 3 * TILE_SIZE / 8, TILE_SIZE / 4); /* bottom left */
612 POINT(5, 3 * TILE_SIZE / 8, TILE_SIZE / 2); /* left concave */
613 POINT(6, TILE_SIZE / 4, TILE_SIZE / 2); /* left corner */
614
615 draw_polygon(fe, coords, 7, TRUE, COL_LOWLIGHT);
616 draw_polygon(fe, coords, 7, FALSE, COL_TEXT);
617 }
618
619 static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
620 game_state *state, int dir, game_ui *ui,
621 float animtime, float flashtime)
622 {
623 int i, bgcolour;
624
625 if (flashtime > 0) {
626 int frame = (int)(flashtime / FLASH_FRAME);
627 bgcolour = (frame % 2 ? COL_LOWLIGHT : COL_HIGHLIGHT);
628 } else
629 bgcolour = COL_BACKGROUND;
630
631 if (!ds->started) {
632 int coords[6];
633
634 draw_rect(fe, 0, 0,
635 TILE_SIZE * state->w + 2 * BORDER,
636 TILE_SIZE * state->h + 2 * BORDER, COL_BACKGROUND);
637 draw_update(fe, 0, 0,
638 TILE_SIZE * state->w + 2 * BORDER,
639 TILE_SIZE * state->h + 2 * BORDER);
640
641 /*
642 * Recessed area containing the whole puzzle.
643 */
644 coords[0] = COORD(state->w) + HIGHLIGHT_WIDTH - 1;
645 coords[1] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
646 coords[2] = COORD(state->w) + HIGHLIGHT_WIDTH - 1;
647 coords[3] = COORD(0) - HIGHLIGHT_WIDTH;
648 coords[4] = COORD(0) - HIGHLIGHT_WIDTH;
649 coords[5] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
650 draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
651 draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT);
652
653 coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
654 coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
655 draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT);
656 draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT);
657
658 /*
659 * Arrows for making moves.
660 */
661 for (i = 0; i < state->w; i++) {
662 draw_arrow(fe, COORD(i), COORD(0), +1, 0);
663 draw_arrow(fe, COORD(i+1), COORD(state->h), -1, 0);
664 }
665 for (i = 0; i < state->h; i++) {
666 draw_arrow(fe, COORD(state->w), COORD(i), 0, +1);
667 draw_arrow(fe, COORD(0), COORD(i+1), 0, -1);
668 }
669
670 ds->started = TRUE;
671 }
672
673 /*
674 * Now draw each tile.
675 */
676
677 clip(fe, COORD(0), COORD(0), TILE_SIZE*state->w, TILE_SIZE*state->h);
678
679 for (i = 0; i < state->n; i++) {
680 int t, t0;
681 /*
682 * Figure out what should be displayed at this
683 * location. It's either a simple tile, or it's a
684 * transition between two tiles (in which case we say
685 * -1 because it must always be drawn).
686 */
687
688 if (oldstate && oldstate->tiles[i] != state->tiles[i])
689 t = -1;
690 else
691 t = state->tiles[i];
692
693 t0 = t;
694
695 if (ds->bgcolour != bgcolour || /* always redraw when flashing */
696 ds->tiles[i] != t || ds->tiles[i] == -1 || t == -1) {
697 int x, y, x2, y2;
698
699 /*
700 * Figure out what to _actually_ draw, and where to
701 * draw it.
702 */
703 if (t == -1) {
704 int x0, y0, x1, y1, dx, dy;
705 int j;
706 float c;
707 int sense;
708
709 if (dir < 0) {
710 assert(oldstate);
711 sense = -oldstate->last_movement_sense;
712 } else {
713 sense = state->last_movement_sense;
714 }
715
716 t = state->tiles[i];
717
718 /*
719 * FIXME: must be prepared to draw a double
720 * tile in some situations.
721 */
722
723 /*
724 * Find the coordinates of this tile in the old and
725 * new states.
726 */
727 x1 = COORD(X(state, i));
728 y1 = COORD(Y(state, i));
729 for (j = 0; j < oldstate->n; j++)
730 if (oldstate->tiles[j] == state->tiles[i])
731 break;
732 assert(j < oldstate->n);
733 x0 = COORD(X(state, j));
734 y0 = COORD(Y(state, j));
735
736 dx = (x1 - x0);
737 if (dx != 0 &&
738 dx != TILE_SIZE * sense) {
739 dx = (dx < 0 ? dx + TILE_SIZE * state->w :
740 dx - TILE_SIZE * state->w);
741 assert(abs(dx) == TILE_SIZE);
742 }
743 dy = (y1 - y0);
744 if (dy != 0 &&
745 dy != TILE_SIZE * sense) {
746 dy = (dy < 0 ? dy + TILE_SIZE * state->h :
747 dy - TILE_SIZE * state->h);
748 assert(abs(dy) == TILE_SIZE);
749 }
750
751 c = (animtime / ANIM_TIME);
752 if (c < 0.0F) c = 0.0F;
753 if (c > 1.0F) c = 1.0F;
754
755 x = x0 + (int)(c * dx);
756 y = y0 + (int)(c * dy);
757 x2 = x1 - dx + (int)(c * dx);
758 y2 = y1 - dy + (int)(c * dy);
759 } else {
760 x = COORD(X(state, i));
761 y = COORD(Y(state, i));
762 x2 = y2 = -1;
763 }
764
765 draw_tile(fe, state, x, y, t, bgcolour);
766 if (x2 != -1 || y2 != -1)
767 draw_tile(fe, state, x2, y2, t, bgcolour);
768 }
769 ds->tiles[i] = t0;
770 }
771
772 unclip(fe);
773
774 ds->bgcolour = bgcolour;
775
776 /*
777 * Update the status bar.
778 */
779 {
780 char statusbuf[256];
781
782 /*
783 * Don't show the new status until we're also showing the
784 * new _state_ - after the game animation is complete.
785 */
786 if (oldstate)
787 state = oldstate;
788
789 sprintf(statusbuf, "%sMoves: %d",
790 (state->completed ? "COMPLETED! " : ""),
791 (state->completed ? state->completed : state->movecount));
792
793 status_bar(fe, statusbuf);
794 }
795 }
796
797 static float game_anim_length(game_state *oldstate,
798 game_state *newstate, int dir)
799 {
800 return ANIM_TIME;
801 }
802
803 static float game_flash_length(game_state *oldstate,
804 game_state *newstate, int dir)
805 {
806 if (!oldstate->completed && newstate->completed)
807 return 2 * FLASH_FRAME;
808 else
809 return 0.0F;
810 }
811
812 static int game_wants_statusbar(void)
813 {
814 return TRUE;
815 }
816
817 #ifdef COMBINED
818 #define thegame sixteen
819 #endif
820
821 const struct game thegame = {
822 "Sixteen", "games.sixteen",
823 default_params,
824 game_fetch_preset,
825 decode_params,
826 encode_params,
827 free_params,
828 dup_params,
829 TRUE, game_configure, custom_params,
830 validate_params,
831 new_game_seed,
832 game_free_aux_info,
833 validate_seed,
834 new_game,
835 dup_game,
836 free_game,
837 TRUE, game_text_format,
838 new_ui,
839 free_ui,
840 make_move,
841 game_size,
842 game_colours,
843 game_new_drawstate,
844 game_free_drawstate,
845 game_redraw,
846 game_anim_length,
847 game_flash_length,
848 game_wants_statusbar,
849 };