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