Move most of face_text_pos() into grid.c, leaving in loopy.c only the
[sgt/puzzles] / twiddle.c
CommitLineData
9038fd11 1/*
2 * twiddle.c: Puzzle involving rearranging a grid of squares by
3 * rotating subsquares. Adapted and generalised from a
4 * door-unlocking puzzle in Metroid Prime 2 (the one in the Main
5 * Gyro Chamber).
6 */
7
9038fd11 8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <assert.h>
12#include <ctype.h>
13#include <math.h>
14
15#include "puzzles.h"
16
1e3e152d 17#define PREFERRED_TILE_SIZE 48
18#define TILE_SIZE (ds->tilesize)
9038fd11 19#define BORDER (TILE_SIZE / 2)
20#define HIGHLIGHT_WIDTH (TILE_SIZE / 20)
21#define COORD(x) ( (x) * TILE_SIZE + BORDER )
22#define FROMCOORD(x) ( ((x) - BORDER + TILE_SIZE) / TILE_SIZE - 1 )
23
47a46323 24#define ANIM_PER_BLKSIZE_UNIT 0.13F
9038fd11 25#define FLASH_FRAME 0.13F
26
27enum {
28 COL_BACKGROUND,
29 COL_TEXT,
30 COL_HIGHLIGHT,
31 COL_HIGHLIGHT_GENTLE,
32 COL_LOWLIGHT,
33 COL_LOWLIGHT_GENTLE,
5c6659fd 34 COL_HIGHCURSOR, COL_LOWCURSOR,
9038fd11 35 NCOLOURS
36};
37
38struct game_params {
39 int w, h, n;
40 int rowsonly;
a3631c72 41 int orientable;
81875211 42 int movetarget;
9038fd11 43};
44
45struct game_state {
46 int w, h, n;
a3631c72 47 int orientable;
9038fd11 48 int *grid;
49 int completed;
2ac6d24e 50 int used_solve; /* used to suppress completion flash */
81875211 51 int movecount, movetarget;
9038fd11 52 int lastx, lasty, lastr; /* coordinates of last rotation */
53};
54
55static game_params *default_params(void)
56{
57 game_params *ret = snew(game_params);
58
59 ret->w = ret->h = 3;
60 ret->n = 2;
a3631c72 61 ret->rowsonly = ret->orientable = FALSE;
81875211 62 ret->movetarget = 0;
9038fd11 63
64 return ret;
65}
66
67
68static void free_params(game_params *params)
69{
70 sfree(params);
71}
72
73static game_params *dup_params(game_params *params)
74{
75 game_params *ret = snew(game_params);
76 *ret = *params; /* structure copy */
77 return ret;
78}
79
80static int game_fetch_preset(int i, char **name, game_params **params)
81{
82 static struct {
83 char *title;
84 game_params params;
85 } presets[] = {
a3631c72 86 { "3x3 rows only", { 3, 3, 2, TRUE, FALSE } },
87 { "3x3 normal", { 3, 3, 2, FALSE, FALSE } },
88 { "3x3 orientable", { 3, 3, 2, FALSE, TRUE } },
9038fd11 89 { "4x4 normal", { 4, 4, 2, FALSE } },
a3631c72 90 { "4x4 orientable", { 4, 4, 2, FALSE, TRUE } },
47a46323 91 { "4x4, rotating 3x3 blocks", { 4, 4, 3, FALSE } },
92 { "5x5, rotating 3x3 blocks", { 5, 5, 3, FALSE } },
93 { "6x6, rotating 4x4 blocks", { 6, 6, 4, FALSE } },
9038fd11 94 };
95
96 if (i < 0 || i >= lenof(presets))
97 return FALSE;
98
99 *name = dupstr(presets[i].title);
100 *params = dup_params(&presets[i].params);
101
102 return TRUE;
103}
104
1185e3c5 105static void decode_params(game_params *ret, char const *string)
9038fd11 106{
9038fd11 107 ret->w = ret->h = atoi(string);
108 ret->n = 2;
a3631c72 109 ret->rowsonly = ret->orientable = FALSE;
81875211 110 ret->movetarget = 0;
89167dad 111 while (*string && isdigit((unsigned char)*string)) string++;
9038fd11 112 if (*string == 'x') {
113 string++;
114 ret->h = atoi(string);
89167dad 115 while (*string && isdigit((unsigned char)*string)) string++;
9038fd11 116 }
117 if (*string == 'n') {
118 string++;
119 ret->n = atoi(string);
89167dad 120 while (*string && isdigit((unsigned char)*string)) string++;
9038fd11 121 }
a3631c72 122 while (*string) {
123 if (*string == 'r') {
124 ret->rowsonly = TRUE;
125 } else if (*string == 'o') {
126 ret->orientable = TRUE;
81875211 127 } else if (*string == 'm') {
128 string++;
129 ret->movetarget = atoi(string);
89167dad 130 while (string[1] && isdigit((unsigned char)string[1])) string++;
a3631c72 131 }
9038fd11 132 string++;
9038fd11 133 }
9038fd11 134}
135
1185e3c5 136static char *encode_params(game_params *params, int full)
9038fd11 137{
138 char buf[256];
a3631c72 139 sprintf(buf, "%dx%dn%d%s%s", params->w, params->h, params->n,
140 params->rowsonly ? "r" : "",
141 params->orientable ? "o" : "");
1185e3c5 142 /* Shuffle limit is part of the limited parameters, because we have to
143 * supply the target move count. */
144 if (params->movetarget)
145 sprintf(buf + strlen(buf), "m%d", params->movetarget);
9038fd11 146 return dupstr(buf);
147}
148
149static config_item *game_configure(game_params *params)
150{
151 config_item *ret;
152 char buf[80];
153
81875211 154 ret = snewn(7, config_item);
9038fd11 155
156 ret[0].name = "Width";
157 ret[0].type = C_STRING;
158 sprintf(buf, "%d", params->w);
159 ret[0].sval = dupstr(buf);
160 ret[0].ival = 0;
161
162 ret[1].name = "Height";
163 ret[1].type = C_STRING;
164 sprintf(buf, "%d", params->h);
165 ret[1].sval = dupstr(buf);
166 ret[1].ival = 0;
167
47a46323 168 ret[2].name = "Rotating block size";
9038fd11 169 ret[2].type = C_STRING;
170 sprintf(buf, "%d", params->n);
171 ret[2].sval = dupstr(buf);
172 ret[2].ival = 0;
173
174 ret[3].name = "One number per row";
175 ret[3].type = C_BOOLEAN;
176 ret[3].sval = NULL;
177 ret[3].ival = params->rowsonly;
178
a3631c72 179 ret[4].name = "Orientation matters";
180 ret[4].type = C_BOOLEAN;
9038fd11 181 ret[4].sval = NULL;
a3631c72 182 ret[4].ival = params->orientable;
183
81875211 184 ret[5].name = "Number of shuffling moves";
185 ret[5].type = C_STRING;
186 sprintf(buf, "%d", params->movetarget);
187 ret[5].sval = dupstr(buf);
a3631c72 188 ret[5].ival = 0;
9038fd11 189
81875211 190 ret[6].name = NULL;
191 ret[6].type = C_END;
192 ret[6].sval = NULL;
193 ret[6].ival = 0;
194
9038fd11 195 return ret;
196}
197
198static game_params *custom_params(config_item *cfg)
199{
200 game_params *ret = snew(game_params);
201
202 ret->w = atoi(cfg[0].sval);
203 ret->h = atoi(cfg[1].sval);
204 ret->n = atoi(cfg[2].sval);
205 ret->rowsonly = cfg[3].ival;
a3631c72 206 ret->orientable = cfg[4].ival;
81875211 207 ret->movetarget = atoi(cfg[5].sval);
9038fd11 208
209 return ret;
210}
211
3ff276f2 212static char *validate_params(game_params *params, int full)
9038fd11 213{
214 if (params->n < 2)
47a46323 215 return "Rotating block size must be at least two";
9038fd11 216 if (params->w < params->n)
47a46323 217 return "Width must be at least the rotating block size";
9038fd11 218 if (params->h < params->n)
47a46323 219 return "Height must be at least the rotating block size";
9038fd11 220 return NULL;
221}
222
223/*
224 * This function actually performs a rotation on a grid. The `x'
225 * and `y' coordinates passed in are the coordinates of the _top
226 * left corner_ of the rotated region. (Using the centre would have
227 * involved half-integers and been annoyingly fiddly. Clicking in
228 * the centre is good for a user interface, but too inconvenient to
229 * use internally.)
230 */
a3631c72 231static void do_rotate(int *grid, int w, int h, int n, int orientable,
232 int x, int y, int dir)
9038fd11 233{
234 int i, j;
235
236 assert(x >= 0 && x+n <= w);
237 assert(y >= 0 && y+n <= h);
238 dir &= 3;
239 if (dir == 0)
240 return; /* nothing to do */
241
242 grid += y*w+x; /* translate region to top corner */
243
244 /*
245 * If we were leaving the result of the rotation in a separate
246 * grid, the simple thing to do would be to loop over each
247 * square within the rotated region and assign it from its
248 * source square. However, to do it in place without taking
249 * O(n^2) memory, we need to be marginally more clever. What
250 * I'm going to do is loop over about one _quarter_ of the
251 * rotated region and permute each element within that quarter
252 * with its rotational coset.
253 *
254 * The size of the region I need to loop over is (n+1)/2 by
255 * n/2, which is an obvious exact quarter for even n and is a
256 * rectangle for odd n. (For odd n, this technique leaves out
257 * one element of the square, which is of course the central
258 * one that never moves anyway.)
259 */
260 for (i = 0; i < (n+1)/2; i++) {
261 for (j = 0; j < n/2; j++) {
262 int k;
263 int g[4];
23e8c9fd 264 int p[4];
265
266 p[0] = j*w+i;
267 p[1] = i*w+(n-j-1);
268 p[2] = (n-j-1)*w+(n-i-1);
269 p[3] = (n-i-1)*w+j;
9038fd11 270
271 for (k = 0; k < 4; k++)
272 g[k] = grid[p[k]];
273
a3631c72 274 for (k = 0; k < 4; k++) {
275 int v = g[(k+dir) & 3];
276 if (orientable)
277 v ^= ((v+dir) ^ v) & 3; /* alter orientation */
278 grid[p[k]] = v;
279 }
9038fd11 280 }
281 }
a3631c72 282
283 /*
284 * Don't forget the orientation on the centre square, if n is
285 * odd.
286 */
287 if (orientable && (n & 1)) {
288 int v = grid[n/2*(w+1)];
289 v ^= ((v+dir) ^ v) & 3; /* alter orientation */
290 grid[n/2*(w+1)] = v;
291 }
9038fd11 292}
293
a3631c72 294static int grid_complete(int *grid, int wh, int orientable)
9038fd11 295{
296 int ok = TRUE;
297 int i;
298 for (i = 1; i < wh; i++)
299 if (grid[i] < grid[i-1])
300 ok = FALSE;
a3631c72 301 if (orientable) {
302 for (i = 0; i < wh; i++)
303 if (grid[i] & 3)
304 ok = FALSE;
305 }
9038fd11 306 return ok;
307}
308
1185e3c5 309static char *new_game_desc(game_params *params, random_state *rs,
c566778e 310 char **aux, int interactive)
9038fd11 311{
312 int *grid;
313 int w = params->w, h = params->h, n = params->n, wh = w*h;
314 int i;
315 char *ret;
316 int retlen;
317 int total_moves;
318
319 /*
320 * Set up a solved grid.
321 */
322 grid = snewn(wh, int);
323 for (i = 0; i < wh; i++)
a3631c72 324 grid[i] = ((params->rowsonly ? i/w : i) + 1) * 4;
9038fd11 325
326 /*
327 * Shuffle it. This game is complex enough that I don't feel up
328 * to analysing its full symmetry properties (particularly at
329 * n=4 and above!), so I'm going to do it the pedestrian way
330 * and simply shuffle the grid by making a long sequence of
331 * randomly chosen moves.
332 */
81875211 333 total_moves = params->movetarget;
334 if (!total_moves)
060ba134 335 /* Add a random move to avoid parity issues. */
81875211 336 total_moves = w*h*n*n*2 + random_upto(rs, 2);
337
338 do {
060ba134 339 int *prevmoves;
340 int rw, rh; /* w/h of rotation centre space */
341
342 rw = w - n + 1;
343 rh = h - n + 1;
344 prevmoves = snewn(rw * rh, int);
345 for (i = 0; i < rw * rh; i++)
346 prevmoves[i] = 0;
81875211 347
348 for (i = 0; i < total_moves; i++) {
060ba134 349 int x, y, r, oldtotal, newtotal, dx, dy;
81875211 350
351 do {
352 x = random_upto(rs, w - n + 1);
353 y = random_upto(rs, h - n + 1);
060ba134 354 r = 2 * random_upto(rs, 2) - 1;
355
356 /*
357 * See if any previous rotations has happened at
358 * this point which nothing has overlapped since.
359 * If so, ensure we haven't either undone a
360 * previous move or repeated one so many times that
361 * it turns into fewer moves in the inverse
362 * direction (i.e. three identical rotations).
363 */
364 oldtotal = prevmoves[y*rw+x];
365 newtotal = oldtotal + r;
291edf3e 366
367 /*
368 * Special case here for w==h==n, in which case
369 * there is actually no way to _avoid_ all moves
370 * repeating or undoing previous ones.
371 */
372 } while ((w != n || h != n) &&
373 (abs(newtotal) < abs(oldtotal) || abs(newtotal) > 2));
060ba134 374
375 do_rotate(grid, w, h, n, params->orientable, x, y, r);
81875211 376
377 /*
060ba134 378 * Log the rotation we've just performed at this point,
379 * for inversion detection in the next move.
380 *
381 * Also zero a section of the prevmoves array, because
382 * any rotation area which _overlaps_ this one is now
383 * entirely safe to perform further moves in.
384 *
385 * Two rotation areas overlap if their top left
386 * coordinates differ by strictly less than n in both
387 * directions
81875211 388 */
060ba134 389 prevmoves[y*rw+x] += r;
390 for (dy = -n+1; dy <= n-1; dy++) {
391 if (y + dy < 0 || y + dy >= rh)
392 continue;
393 for (dx = -n+1; dx <= n-1; dx++) {
394 if (x + dx < 0 || x + dx >= rw)
395 continue;
396 if (dx == 0 && dy == 0)
397 continue;
398 prevmoves[(y+dy)*rw+(x+dx)] = 0;
399 }
81875211 400 }
401 }
060ba134 402
403 sfree(prevmoves);
404
81875211 405 } while (grid_complete(grid, wh, params->orientable));
9038fd11 406
407 /*
1185e3c5 408 * Now construct the game description, by describing the grid
409 * as a simple sequence of integers. They're comma-separated,
410 * unless the puzzle is orientable in which case they're
411 * separated by orientation letters `u', `d', `l' and `r'.
9038fd11 412 */
413 ret = NULL;
414 retlen = 0;
415 for (i = 0; i < wh; i++) {
416 char buf[80];
417 int k;
418
30861651 419 k = sprintf(buf, "%d%c", grid[i] / 4,
ab53eb64 420 (char)(params->orientable ? "uldr"[grid[i] & 3] : ','));
9038fd11 421
422 ret = sresize(ret, retlen + k + 1, char);
423 strcpy(ret + retlen, buf);
424 retlen += k;
425 }
30861651 426 if (!params->orientable)
427 ret[retlen-1] = '\0'; /* delete last comma */
9038fd11 428
429 sfree(grid);
430 return ret;
431}
432
1185e3c5 433static char *validate_desc(game_params *params, char *desc)
9038fd11 434{
435 char *p, *err;
436 int w = params->w, h = params->h, wh = w*h;
437 int i;
438
1185e3c5 439 p = desc;
9038fd11 440 err = NULL;
441
442 for (i = 0; i < wh; i++) {
30861651 443 if (*p < '0' || *p > '9')
9038fd11 444 return "Not enough numbers in string";
9038fd11 445 while (*p >= '0' && *p <= '9')
446 p++;
30861651 447 if (!params->orientable && i < wh-1) {
448 if (*p != ',')
449 return "Expected comma after number";
450 } else if (params->orientable && i < wh) {
451 if (*p != 'l' && *p != 'r' && *p != 'u' && *p != 'd')
452 return "Expected orientation letter after number";
453 } else if (i == wh-1 && *p) {
9038fd11 454 return "Excess junk at end of string";
455 }
456
457 if (*p) p++; /* eat comma */
458 }
459
460 return NULL;
461}
462
dafd6cf6 463static game_state *new_game(midend *me, game_params *params, char *desc)
9038fd11 464{
465 game_state *state = snew(game_state);
466 int w = params->w, h = params->h, n = params->n, wh = w*h;
467 int i;
468 char *p;
469
470 state->w = w;
471 state->h = h;
472 state->n = n;
a3631c72 473 state->orientable = params->orientable;
9038fd11 474 state->completed = 0;
a440f184 475 state->used_solve = FALSE;
9038fd11 476 state->movecount = 0;
81875211 477 state->movetarget = params->movetarget;
9038fd11 478 state->lastx = state->lasty = state->lastr = -1;
479
480 state->grid = snewn(wh, int);
481
1185e3c5 482 p = desc;
9038fd11 483
484 for (i = 0; i < wh; i++) {
30861651 485 state->grid[i] = 4 * atoi(p);
9038fd11 486 while (*p >= '0' && *p <= '9')
487 p++;
30861651 488 if (*p) {
489 if (params->orientable) {
490 switch (*p) {
491 case 'l': state->grid[i] |= 1; break;
492 case 'd': state->grid[i] |= 2; break;
493 case 'r': state->grid[i] |= 3; break;
494 }
495 }
496 p++;
497 }
9038fd11 498 }
499
500 return state;
501}
502
503static game_state *dup_game(game_state *state)
504{
505 game_state *ret = snew(game_state);
506
507 ret->w = state->w;
508 ret->h = state->h;
509 ret->n = state->n;
a3631c72 510 ret->orientable = state->orientable;
9038fd11 511 ret->completed = state->completed;
512 ret->movecount = state->movecount;
81875211 513 ret->movetarget = state->movetarget;
9038fd11 514 ret->lastx = state->lastx;
515 ret->lasty = state->lasty;
516 ret->lastr = state->lastr;
2ac6d24e 517 ret->used_solve = state->used_solve;
9038fd11 518
519 ret->grid = snewn(ret->w * ret->h, int);
520 memcpy(ret->grid, state->grid, ret->w * ret->h * sizeof(int));
521
522 return ret;
523}
524
525static void free_game(game_state *state)
526{
527 sfree(state->grid);
528 sfree(state);
529}
530
2ac6d24e 531static int compare_int(const void *av, const void *bv)
532{
533 const int *a = (const int *)av;
534 const int *b = (const int *)bv;
535 if (*a < *b)
536 return -1;
537 else if (*a > *b)
538 return +1;
539 else
540 return 0;
541}
542
df11cd4e 543static char *solve_game(game_state *state, game_state *currstate,
c566778e 544 char *aux, char **error)
2ac6d24e 545{
df11cd4e 546 return dupstr("S");
2ac6d24e 547}
548
fa3abef5 549static int game_can_format_as_text_now(game_params *params)
550{
551 return TRUE;
552}
553
9b4b03d3 554static char *game_text_format(game_state *state)
555{
af52394e 556 char *ret, *p, buf[80];
557 int i, x, y, col, o, maxlen;
558
559 /*
560 * First work out how many characters we need to display each
561 * number. We're pretty flexible on grid contents here, so we
562 * have to scan the entire grid.
563 */
564 col = 0;
565 for (i = 0; i < state->w * state->h; i++) {
566 x = sprintf(buf, "%d", state->grid[i] / 4);
567 if (col < x) col = x;
568 }
569 o = (state->orientable ? 1 : 0);
570
571 /*
572 * Now we know the exact total size of the grid we're going to
573 * produce: it's got h rows, each containing w lots of col+o,
574 * w-1 spaces and a trailing newline.
575 */
576 maxlen = state->h * state->w * (col+o+1);
577
48a10826 578 ret = snewn(maxlen+1, char);
af52394e 579 p = ret;
580
581 for (y = 0; y < state->h; y++) {
582 for (x = 0; x < state->w; x++) {
583 int v = state->grid[state->w*y+x];
584 sprintf(buf, "%*d", col, v/4);
585 memcpy(p, buf, col);
586 p += col;
587 if (o)
588 *p++ = "^<v>"[v & 3];
589 if (x+1 == state->w)
590 *p++ = '\n';
591 else
592 *p++ = ' ';
593 }
594 }
595
596 assert(p - ret == maxlen);
597 *p = '\0';
598 return ret;
9b4b03d3 599}
600
5c6659fd 601struct game_ui {
602 int cur_x, cur_y;
603 int cur_visible;
604};
605
9038fd11 606static game_ui *new_ui(game_state *state)
607{
5c6659fd 608 game_ui *ui = snew(game_ui);
609
610 ui->cur_x = 0;
611 ui->cur_y = 0;
612 ui->cur_visible = FALSE;
613
614 return ui;
9038fd11 615}
616
617static void free_ui(game_ui *ui)
618{
5c6659fd 619 sfree(ui);
9038fd11 620}
621
844f605f 622static char *encode_ui(game_ui *ui)
ae8290c6 623{
624 return NULL;
625}
626
844f605f 627static void decode_ui(game_ui *ui, char *encoding)
ae8290c6 628{
629}
630
07dfb697 631static void game_changed_state(game_ui *ui, game_state *oldstate,
632 game_state *newstate)
633{
634}
635
1e3e152d 636struct game_drawstate {
637 int started;
638 int w, h, bgcolour;
639 int *grid;
640 int tilesize;
5c6659fd 641 int cur_x, cur_y;
1e3e152d 642};
643
df11cd4e 644static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
645 int x, int y, int button)
9038fd11 646{
df11cd4e 647 int w = state->w, h = state->h, n = state->n /* , wh = w*h */;
648 char buf[80];
9038fd11 649 int dir;
650
f0ee053c 651 button = button & (~MOD_MASK | MOD_NUM_KEYPAD);
652
5c6659fd 653 if (IS_CURSOR_MOVE(button)) {
654 if (button == CURSOR_LEFT && ui->cur_x > 0)
655 ui->cur_x--;
656 if (button == CURSOR_RIGHT && (ui->cur_x+n) < (w))
657 ui->cur_x++;
658 if (button == CURSOR_UP && ui->cur_y > 0)
659 ui->cur_y--;
660 if (button == CURSOR_DOWN && (ui->cur_y+n) < (h))
661 ui->cur_y++;
662 ui->cur_visible = 1;
663 return "";
664 }
665
9038fd11 666 if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
667 /*
668 * Determine the coordinates of the click. We offset by n-1
669 * half-blocks so that the user must click at the centre of
670 * a rotation region rather than at the corner.
671 */
672 x -= (n-1) * TILE_SIZE / 2;
673 y -= (n-1) * TILE_SIZE / 2;
674 x = FROMCOORD(x);
675 y = FROMCOORD(y);
a96666e4 676 dir = (button == LEFT_BUTTON ? 1 : -1);
677 if (x < 0 || x > w-n || y < 0 || y > h-n)
9038fd11 678 return NULL;
5c6659fd 679 ui->cur_visible = 0;
680 } else if (IS_CURSOR_SELECT(button)) {
681 if (ui->cur_visible) {
682 x = ui->cur_x;
683 y = ui->cur_y;
684 dir = (button == CURSOR_SELECT2) ? -1 : +1;
685 } else {
686 ui->cur_visible = 1;
687 return "";
688 }
a96666e4 689 } else if (button == 'a' || button == 'A' || button==MOD_NUM_KEYPAD+'7') {
690 x = y = 0;
691 dir = (button == 'A' ? -1 : +1);
692 } else if (button == 'b' || button == 'B' || button==MOD_NUM_KEYPAD+'9') {
693 x = w-n;
694 y = 0;
695 dir = (button == 'B' ? -1 : +1);
696 } else if (button == 'c' || button == 'C' || button==MOD_NUM_KEYPAD+'1') {
697 x = 0;
698 y = h-n;
699 dir = (button == 'C' ? -1 : +1);
700 } else if (button == 'd' || button == 'D' || button==MOD_NUM_KEYPAD+'3') {
701 x = w-n;
702 y = h-n;
703 dir = (button == 'D' ? -1 : +1);
704 } else if (button==MOD_NUM_KEYPAD+'8' && (w-n) % 2 == 0) {
705 x = (w-n) / 2;
706 y = 0;
707 dir = +1;
708 } else if (button==MOD_NUM_KEYPAD+'2' && (w-n) % 2 == 0) {
709 x = (w-n) / 2;
710 y = h-n;
711 dir = +1;
712 } else if (button==MOD_NUM_KEYPAD+'4' && (h-n) % 2 == 0) {
713 x = 0;
714 y = (h-n) / 2;
715 dir = +1;
716 } else if (button==MOD_NUM_KEYPAD+'6' && (h-n) % 2 == 0) {
717 x = w-n;
718 y = (h-n) / 2;
719 dir = +1;
720 } else if (button==MOD_NUM_KEYPAD+'5' && (w-n) % 2 == 0 && (h-n) % 2 == 0){
721 x = (w-n) / 2;
722 y = (h-n) / 2;
723 dir = +1;
724 } else {
725 return NULL; /* no move to be made */
726 }
9038fd11 727
a96666e4 728 /*
df11cd4e 729 * If we reach here, we have a valid move.
a96666e4 730 */
df11cd4e 731 sprintf(buf, "M%d,%d,%d", x, y, dir);
732 return dupstr(buf);
733}
734
735static game_state *execute_move(game_state *from, char *move)
736{
737 game_state *ret;
738 int w = from->w, h = from->h, n = from->n, wh = w*h;
739 int x, y, dir;
740
741 if (!strcmp(move, "S")) {
742 int i;
743 ret = dup_game(from);
744
745 /*
746 * Simply replace the grid with a solved one. For this game,
747 * this isn't a useful operation for actually telling the user
748 * what they should have done, but it is useful for
749 * conveniently being able to get hold of a clean state from
750 * which to practise manoeuvres.
751 */
752 qsort(ret->grid, ret->w*ret->h, sizeof(int), compare_int);
753 for (i = 0; i < ret->w*ret->h; i++)
754 ret->grid[i] &= ~3;
a440f184 755 ret->used_solve = TRUE;
df11cd4e 756 ret->completed = ret->movecount = 1;
757
758 return ret;
759 }
760
761 if (move[0] != 'M' ||
762 sscanf(move+1, "%d,%d,%d", &x, &y, &dir) != 3 ||
763 x < 0 || y < 0 || x > from->w - n || y > from->h - n)
764 return NULL; /* can't parse this move string */
765
a96666e4 766 ret = dup_game(from);
a96666e4 767 ret->movecount++;
768 do_rotate(ret->grid, w, h, n, ret->orientable, x, y, dir);
769 ret->lastx = x;
770 ret->lasty = y;
771 ret->lastr = dir;
9038fd11 772
a96666e4 773 /*
774 * See if the game has been completed. To do this we simply
775 * test that the grid contents are in increasing order.
776 */
777 if (!ret->completed && grid_complete(ret->grid, wh, ret->orientable))
778 ret->completed = ret->movecount;
779 return ret;
9038fd11 780}
781
782/* ----------------------------------------------------------------------
783 * Drawing routines.
784 */
785
1f3ee4ee 786static void game_compute_size(game_params *params, int tilesize,
787 int *x, int *y)
9038fd11 788{
1f3ee4ee 789 /* Ick: fake up `ds->tilesize' for macro expansion purposes */
790 struct { int tilesize; } ads, *ds = &ads;
791 ads.tilesize = tilesize;
1e3e152d 792
9038fd11 793 *x = TILE_SIZE * params->w + 2 * BORDER;
794 *y = TILE_SIZE * params->h + 2 * BORDER;
795}
796
dafd6cf6 797static void game_set_size(drawing *dr, game_drawstate *ds,
798 game_params *params, int tilesize)
1f3ee4ee 799{
800 ds->tilesize = tilesize;
801}
802
8266f3fc 803static float *game_colours(frontend *fe, int *ncolours)
9038fd11 804{
805 float *ret = snewn(3 * NCOLOURS, float);
806 int i;
9038fd11 807
937a9eff 808 game_mkhighlight(fe, ret, COL_BACKGROUND, COL_HIGHLIGHT, COL_LOWLIGHT);
9038fd11 809
5c6659fd 810 /* cursor is light-background with a red tinge. */
811 ret[COL_HIGHCURSOR * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 1.0F;
812 ret[COL_HIGHCURSOR * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 0.5F;
813 ret[COL_HIGHCURSOR * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 0.5F;
814
9038fd11 815 for (i = 0; i < 3; i++) {
9038fd11 816 ret[COL_HIGHLIGHT_GENTLE * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 1.1F;
9038fd11 817 ret[COL_LOWLIGHT_GENTLE * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 0.9F;
818 ret[COL_TEXT * 3 + i] = 0.0;
5c6659fd 819 ret[COL_LOWCURSOR * 3 + i] = ret[COL_HIGHCURSOR * 3 + i] * 0.6F;
9038fd11 820 }
821
822 *ncolours = NCOLOURS;
823 return ret;
824}
825
dafd6cf6 826static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
9038fd11 827{
828 struct game_drawstate *ds = snew(struct game_drawstate);
829 int i;
830
831 ds->started = FALSE;
832 ds->w = state->w;
833 ds->h = state->h;
834 ds->bgcolour = COL_BACKGROUND;
835 ds->grid = snewn(ds->w*ds->h, int);
1e3e152d 836 ds->tilesize = 0; /* haven't decided yet */
9038fd11 837 for (i = 0; i < ds->w*ds->h; i++)
838 ds->grid[i] = -1;
5c6659fd 839 ds->cur_x = ds->cur_y = -state->n;
9038fd11 840
841 return ds;
842}
843
dafd6cf6 844static void game_free_drawstate(drawing *dr, game_drawstate *ds)
9038fd11 845{
ab53eb64 846 sfree(ds->grid);
9038fd11 847 sfree(ds);
848}
849
850struct rotation {
851 int cx, cy, cw, ch; /* clip region */
852 int ox, oy; /* rotation origin */
853 float c, s; /* cos and sin of rotation angle */
854 int lc, rc, tc, bc; /* colours of tile edges */
855};
856
857static void rotate(int *xy, struct rotation *rot)
858{
859 if (rot) {
5c6659fd 860 float xf = (float)xy[0] - rot->ox, yf = (float)xy[1] - rot->oy;
9038fd11 861 float xf2, yf2;
862
863 xf2 = rot->c * xf + rot->s * yf;
864 yf2 = - rot->s * xf + rot->c * yf;
865
5c6659fd 866 xy[0] = (int)(xf2 + rot->ox + 0.5); /* round to nearest */
867 xy[1] = (int)(yf2 + rot->oy + 0.5); /* round to nearest */
9038fd11 868 }
869}
870
5c6659fd 871#define CUR_TOP 1
872#define CUR_RIGHT 2
873#define CUR_BOTTOM 4
874#define CUR_LEFT 8
875
dafd6cf6 876static void draw_tile(drawing *dr, game_drawstate *ds, game_state *state,
1e3e152d 877 int x, int y, int tile, int flash_colour,
5c6659fd 878 struct rotation *rot, unsigned cedges)
9038fd11 879{
880 int coords[8];
881 char str[40];
882
0551ee6b 883 /*
884 * If we've been passed a rotation region but we're drawing a
885 * tile which is outside it, we must draw it normally. This can
886 * occur if we're cleaning up after a completion flash while a
887 * new move is also being made.
888 */
889 if (rot && (x < rot->cx || y < rot->cy ||
daaccee8 890 x >= rot->cx+rot->cw || y >= rot->cy+rot->ch))
0551ee6b 891 rot = NULL;
892
9038fd11 893 if (rot)
dafd6cf6 894 clip(dr, rot->cx, rot->cy, rot->cw, rot->ch);
9038fd11 895
896 /*
897 * We must draw each side of the tile's highlight separately,
898 * because in some cases (during rotation) they will all need
899 * to be different colours.
900 */
901
902 /* The centre point is common to all sides. */
903 coords[4] = x + TILE_SIZE / 2;
904 coords[5] = y + TILE_SIZE / 2;
905 rotate(coords+4, rot);
906
907 /* Right side. */
908 coords[0] = x + TILE_SIZE - 1;
909 coords[1] = y + TILE_SIZE - 1;
910 rotate(coords+0, rot);
911 coords[2] = x + TILE_SIZE - 1;
912 coords[3] = y;
913 rotate(coords+2, rot);
dafd6cf6 914 draw_polygon(dr, coords, 3, rot ? rot->rc : COL_LOWLIGHT,
5c6659fd 915 rot ? rot->rc : (cedges & CUR_RIGHT) ? COL_LOWCURSOR : COL_LOWLIGHT);
9038fd11 916
917 /* Bottom side. */
918 coords[2] = x;
919 coords[3] = y + TILE_SIZE - 1;
920 rotate(coords+2, rot);
dafd6cf6 921 draw_polygon(dr, coords, 3, rot ? rot->bc : COL_LOWLIGHT,
5c6659fd 922 rot ? rot->bc : (cedges & CUR_BOTTOM) ? COL_LOWCURSOR : COL_LOWLIGHT);
9038fd11 923
924 /* Left side. */
925 coords[0] = x;
926 coords[1] = y;
927 rotate(coords+0, rot);
dafd6cf6 928 draw_polygon(dr, coords, 3, rot ? rot->lc : COL_HIGHLIGHT,
5c6659fd 929 rot ? rot->lc : (cedges & CUR_LEFT) ? COL_HIGHCURSOR : COL_HIGHLIGHT);
9038fd11 930
931 /* Top side. */
932 coords[2] = x + TILE_SIZE - 1;
933 coords[3] = y;
934 rotate(coords+2, rot);
dafd6cf6 935 draw_polygon(dr, coords, 3, rot ? rot->tc : COL_HIGHLIGHT,
5c6659fd 936 rot ? rot->tc : (cedges & CUR_TOP) ? COL_HIGHCURSOR : COL_HIGHLIGHT);
9038fd11 937
a3631c72 938 /*
939 * Now the main blank area in the centre of the tile.
940 */
9038fd11 941 if (rot) {
942 coords[0] = x + HIGHLIGHT_WIDTH;
943 coords[1] = y + HIGHLIGHT_WIDTH;
944 rotate(coords+0, rot);
945 coords[2] = x + HIGHLIGHT_WIDTH;
946 coords[3] = y + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
947 rotate(coords+2, rot);
948 coords[4] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
949 coords[5] = y + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
950 rotate(coords+4, rot);
951 coords[6] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
952 coords[7] = y + HIGHLIGHT_WIDTH;
953 rotate(coords+6, rot);
dafd6cf6 954 draw_polygon(dr, coords, 4, flash_colour, flash_colour);
9038fd11 955 } else {
dafd6cf6 956 draw_rect(dr, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
9038fd11 957 TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
958 flash_colour);
959 }
960
a3631c72 961 /*
4b24f582 962 * Next, the triangles for orientation.
a3631c72 963 */
964 if (state->orientable) {
d50832a3 965 int xdx, xdy, ydx, ydy;
966 int cx, cy, displ, displ2;
a3631c72 967 switch (tile & 3) {
968 case 0:
d50832a3 969 xdx = 1, xdy = 0;
970 ydx = 0, ydy = 1;
a3631c72 971 break;
972 case 1:
d50832a3 973 xdx = 0, xdy = -1;
974 ydx = 1, ydy = 0;
a3631c72 975 break;
976 case 2:
d50832a3 977 xdx = -1, xdy = 0;
978 ydx = 0, ydy = -1;
a3631c72 979 break;
980 default /* case 3 */:
d50832a3 981 xdx = 0, xdy = 1;
982 ydx = -1, ydy = 0;
a3631c72 983 break;
984 }
985
d50832a3 986 cx = x + TILE_SIZE / 2;
987 cy = y + TILE_SIZE / 2;
988 displ = TILE_SIZE / 2 - HIGHLIGHT_WIDTH - 2;
989 displ2 = TILE_SIZE / 3 - HIGHLIGHT_WIDTH;
a3631c72 990
30861651 991 coords[0] = cx - displ * xdx + displ2 * ydx;
992 coords[1] = cy - displ * xdy + displ2 * ydy;
a3631c72 993 rotate(coords+0, rot);
30861651 994 coords[2] = cx + displ * xdx + displ2 * ydx;
995 coords[3] = cy + displ * xdy + displ2 * ydy;
a3631c72 996 rotate(coords+2, rot);
30861651 997 coords[4] = cx - displ * ydx;
998 coords[5] = cy - displ * ydy;
a3631c72 999 rotate(coords+4, rot);
dafd6cf6 1000 draw_polygon(dr, coords, 3, COL_LOWLIGHT_GENTLE, COL_LOWLIGHT_GENTLE);
a3631c72 1001 }
1002
9038fd11 1003 coords[0] = x + TILE_SIZE/2;
1004 coords[1] = y + TILE_SIZE/2;
1005 rotate(coords+0, rot);
a3631c72 1006 sprintf(str, "%d", tile / 4);
dafd6cf6 1007 draw_text(dr, coords[0], coords[1],
9038fd11 1008 FONT_VARIABLE, TILE_SIZE/3, ALIGN_VCENTRE | ALIGN_HCENTRE,
1009 COL_TEXT, str);
1010
1011 if (rot)
dafd6cf6 1012 unclip(dr);
9038fd11 1013
dafd6cf6 1014 draw_update(dr, x, y, TILE_SIZE, TILE_SIZE);
9038fd11 1015}
1016
1017static int highlight_colour(float angle)
1018{
1019 int colours[32] = {
1020 COL_LOWLIGHT,
1021 COL_LOWLIGHT_GENTLE,
1022 COL_LOWLIGHT_GENTLE,
1023 COL_LOWLIGHT_GENTLE,
1024 COL_HIGHLIGHT_GENTLE,
1025 COL_HIGHLIGHT_GENTLE,
1026 COL_HIGHLIGHT_GENTLE,
1027 COL_HIGHLIGHT,
1028 COL_HIGHLIGHT,
1029 COL_HIGHLIGHT,
1030 COL_HIGHLIGHT,
1031 COL_HIGHLIGHT,
1032 COL_HIGHLIGHT,
1033 COL_HIGHLIGHT,
1034 COL_HIGHLIGHT,
1035 COL_HIGHLIGHT,
1036 COL_HIGHLIGHT,
1037 COL_HIGHLIGHT_GENTLE,
1038 COL_HIGHLIGHT_GENTLE,
1039 COL_HIGHLIGHT_GENTLE,
1040 COL_LOWLIGHT_GENTLE,
1041 COL_LOWLIGHT_GENTLE,
1042 COL_LOWLIGHT_GENTLE,
1043 COL_LOWLIGHT,
1044 COL_LOWLIGHT,
1045 COL_LOWLIGHT,
1046 COL_LOWLIGHT,
1047 COL_LOWLIGHT,
1048 COL_LOWLIGHT,
1049 COL_LOWLIGHT,
1050 COL_LOWLIGHT,
1051 COL_LOWLIGHT,
1052 };
1053
1054 return colours[(int)((angle + 2*PI) / (PI/16)) & 31];
1055}
1056
1057static float game_anim_length(game_state *oldstate, game_state *newstate,
e3f21163 1058 int dir, game_ui *ui)
9038fd11 1059{
47a46323 1060 return (float)(ANIM_PER_BLKSIZE_UNIT * sqrt(newstate->n-1));
9038fd11 1061}
1062
1063static float game_flash_length(game_state *oldstate, game_state *newstate,
e3f21163 1064 int dir, game_ui *ui)
9038fd11 1065{
2ac6d24e 1066 if (!oldstate->completed && newstate->completed &&
1067 !oldstate->used_solve && !newstate->used_solve)
9038fd11 1068 return 2 * FLASH_FRAME;
1069 else
1070 return 0.0F;
1071}
1072
4496362f 1073static int game_is_solved(game_state *state)
1074{
1075 return state->completed;
1076}
1077
dafd6cf6 1078static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
9038fd11 1079 game_state *state, int dir, game_ui *ui,
1080 float animtime, float flashtime)
1081{
1082 int i, bgcolour;
1083 struct rotation srot, *rot;
1084 int lastx = -1, lasty = -1, lastr = -1;
5c6659fd 1085 int cx, cy, cmoved = 0, n = state->n;
1086
1087 cx = ui->cur_visible ? ui->cur_x : -state->n;
1088 cy = ui->cur_visible ? ui->cur_y : -state->n;
1089 if (cx != ds->cur_x || cy != ds->cur_y)
1090 cmoved = 1;
9038fd11 1091
1092 if (flashtime > 0) {
1093 int frame = (int)(flashtime / FLASH_FRAME);
1094 bgcolour = (frame % 2 ? COL_LOWLIGHT : COL_HIGHLIGHT);
1095 } else
1096 bgcolour = COL_BACKGROUND;
1097
1098 if (!ds->started) {
19f24306 1099 int coords[10];
9038fd11 1100
dafd6cf6 1101 draw_rect(dr, 0, 0,
9038fd11 1102 TILE_SIZE * state->w + 2 * BORDER,
1103 TILE_SIZE * state->h + 2 * BORDER, COL_BACKGROUND);
dafd6cf6 1104 draw_update(dr, 0, 0,
9038fd11 1105 TILE_SIZE * state->w + 2 * BORDER,
1106 TILE_SIZE * state->h + 2 * BORDER);
1107
1108 /*
1109 * Recessed area containing the whole puzzle.
1110 */
1111 coords[0] = COORD(state->w) + HIGHLIGHT_WIDTH - 1;
1112 coords[1] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
1113 coords[2] = COORD(state->w) + HIGHLIGHT_WIDTH - 1;
1114 coords[3] = COORD(0) - HIGHLIGHT_WIDTH;
19f24306 1115 coords[4] = coords[2] - TILE_SIZE;
1116 coords[5] = coords[3] + TILE_SIZE;
1117 coords[8] = COORD(0) - HIGHLIGHT_WIDTH;
1118 coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
1119 coords[6] = coords[8] + TILE_SIZE;
1120 coords[7] = coords[9] - TILE_SIZE;
dafd6cf6 1121 draw_polygon(dr, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
9038fd11 1122
1123 coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
1124 coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
dafd6cf6 1125 draw_polygon(dr, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
9038fd11 1126
1127 ds->started = TRUE;
1128 }
1129
1130 /*
1131 * If we're drawing any rotated tiles, sort out the rotation
1132 * parameters, and also zap the rotation region to the
1133 * background colour before doing anything else.
1134 */
1135 if (oldstate) {
1136 float angle;
e3f21163 1137 float anim_max = game_anim_length(oldstate, state, dir, ui);
9038fd11 1138
1139 if (dir > 0) {
1140 lastx = state->lastx;
1141 lasty = state->lasty;
1142 lastr = state->lastr;
1143 } else {
1144 lastx = oldstate->lastx;
1145 lasty = oldstate->lasty;
1146 lastr = -oldstate->lastr;
1147 }
1148
1149 rot = &srot;
1150 rot->cx = COORD(lastx);
1151 rot->cy = COORD(lasty);
1152 rot->cw = rot->ch = TILE_SIZE * state->n;
1153 rot->ox = rot->cx + rot->cw/2;
1154 rot->oy = rot->cy + rot->ch/2;
5c6659fd 1155 angle = (float)((-PI/2 * lastr) * (1.0 - animtime / anim_max));
1156 rot->c = (float)cos(angle);
1157 rot->s = (float)sin(angle);
9038fd11 1158
1159 /*
1160 * Sort out the colours of the various sides of the tile.
1161 */
5c6659fd 1162 rot->lc = highlight_colour((float)PI + angle);
9038fd11 1163 rot->rc = highlight_colour(angle);
5c6659fd 1164 rot->tc = highlight_colour((float)(PI/2.0) + angle);
1165 rot->bc = highlight_colour((float)(-PI/2.0) + angle);
9038fd11 1166
dafd6cf6 1167 draw_rect(dr, rot->cx, rot->cy, rot->cw, rot->ch, bgcolour);
9038fd11 1168 } else
1169 rot = NULL;
1170
1171 /*
1172 * Now draw each tile.
1173 */
1174 for (i = 0; i < state->w * state->h; i++) {
5c6659fd 1175 int t, cc = 0;
9038fd11 1176 int tx = i % state->w, ty = i / state->w;
1177
1178 /*
1179 * Figure out what should be displayed at this location.
1180 * Usually it will be state->grid[i], unless we're in the
1181 * middle of animating an actual rotation and this cell is
1182 * within the rotation region, in which case we set -1
1183 * (always display).
1184 */
1185 if (oldstate && lastx >= 0 && lasty >= 0 &&
1186 tx >= lastx && tx < lastx + state->n &&
1187 ty >= lasty && ty < lasty + state->n)
1188 t = -1;
1189 else
1190 t = state->grid[i];
1191
5c6659fd 1192 if (cmoved) {
1193 /* cursor has moved (or changed visibility)... */
1194 if (tx == cx || tx == cx+n-1 || ty == cy || ty == cy+n-1)
1195 cc = 1; /* ...we're on new cursor, redraw */
1196 if (tx == ds->cur_x || tx == ds->cur_x+n-1 ||
1197 ty == ds->cur_y || ty == ds->cur_y+n-1)
1198 cc = 1; /* ...we were on old cursor, redraw */
1199 }
1200
9038fd11 1201 if (ds->bgcolour != bgcolour || /* always redraw when flashing */
5c6659fd 1202 ds->grid[i] != t || ds->grid[i] == -1 || t == -1 || cc) {
9038fd11 1203 int x = COORD(tx), y = COORD(ty);
5c6659fd 1204 unsigned cedges = 0;
1205
1206 if (tx == cx && ty >= cy && ty <= cy+n-1) cedges |= CUR_LEFT;
1207 if (ty == cy && tx >= cx && tx <= cx+n-1) cedges |= CUR_TOP;
1208 if (tx == cx+n-1 && ty >= cy && ty <= cy+n-1) cedges |= CUR_RIGHT;
1209 if (ty == cy+n-1 && tx >= cx && tx <= cx+n-1) cedges |= CUR_BOTTOM;
9038fd11 1210
5c6659fd 1211 draw_tile(dr, ds, state, x, y, state->grid[i], bgcolour, rot, cedges);
9038fd11 1212 ds->grid[i] = t;
1213 }
1214 }
1215 ds->bgcolour = bgcolour;
5c6659fd 1216 ds->cur_x = cx; ds->cur_y = cy;
9038fd11 1217
1218 /*
1219 * Update the status bar.
1220 */
1221 {
1222 char statusbuf[256];
1223
1224 /*
1225 * Don't show the new status until we're also showing the
1226 * new _state_ - after the game animation is complete.
1227 */
1228 if (oldstate)
1229 state = oldstate;
1230
2ac6d24e 1231 if (state->used_solve)
1232 sprintf(statusbuf, "Moves since auto-solve: %d",
1233 state->movecount - state->completed);
81875211 1234 else {
2ac6d24e 1235 sprintf(statusbuf, "%sMoves: %d",
1236 (state->completed ? "COMPLETED! " : ""),
1237 (state->completed ? state->completed : state->movecount));
81875211 1238 if (state->movetarget)
1239 sprintf(statusbuf+strlen(statusbuf), " (target %d)",
1240 state->movetarget);
1241 }
9038fd11 1242
dafd6cf6 1243 status_bar(dr, statusbuf);
9038fd11 1244 }
1245}
1246
4d08de49 1247static int game_timing_state(game_state *state, game_ui *ui)
48dcdd62 1248{
1249 return TRUE;
1250}
1251
dafd6cf6 1252static void game_print_size(game_params *params, float *x, float *y)
1253{
1254}
1255
1256static void game_print(drawing *dr, game_state *state, int tilesize)
1257{
1258}
1259
9038fd11 1260#ifdef COMBINED
1261#define thegame twiddle
1262#endif
1263
1264const struct game thegame = {
750037d7 1265 "Twiddle", "games.twiddle", "twiddle",
9038fd11 1266 default_params,
1267 game_fetch_preset,
1268 decode_params,
1269 encode_params,
1270 free_params,
1271 dup_params,
1d228b10 1272 TRUE, game_configure, custom_params,
9038fd11 1273 validate_params,
1185e3c5 1274 new_game_desc,
1185e3c5 1275 validate_desc,
9038fd11 1276 new_game,
1277 dup_game,
1278 free_game,
2ac6d24e 1279 TRUE, solve_game,
fa3abef5 1280 TRUE, game_can_format_as_text_now, game_text_format,
9038fd11 1281 new_ui,
1282 free_ui,
ae8290c6 1283 encode_ui,
1284 decode_ui,
07dfb697 1285 game_changed_state,
df11cd4e 1286 interpret_move,
1287 execute_move,
1f3ee4ee 1288 PREFERRED_TILE_SIZE, game_compute_size, game_set_size,
9038fd11 1289 game_colours,
1290 game_new_drawstate,
1291 game_free_drawstate,
1292 game_redraw,
1293 game_anim_length,
1294 game_flash_length,
4496362f 1295 game_is_solved,
dafd6cf6 1296 FALSE, FALSE, game_print_size, game_print,
ac9f41c4 1297 TRUE, /* wants_statusbar */
48dcdd62 1298 FALSE, game_timing_state,
2705d374 1299 0, /* flags */
9038fd11 1300};
5c6659fd 1301
1302/* vim: set shiftwidth=4 tabstop=8: */