"Hold" function in Guess was completely broken.
[sgt/puzzles] / guess.c
1 /*
2 * guess.c: Mastermind clone.
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 FLASH_FRAME 0.5F
15
16 enum {
17 COL_BACKGROUND,
18 COL_FRAME, COL_CURSOR, COL_FLASH, COL_HOLD,
19 COL_EMPTY, /* must be COL_1 - 1 */
20 COL_1, COL_2, COL_3, COL_4, COL_5, COL_6, COL_7, COL_8, COL_9, COL_10,
21 COL_CORRECTPLACE, COL_CORRECTCOLOUR,
22 NCOLOURS
23 };
24
25 struct game_params {
26 int ncolours, npegs, nguesses;
27 int allow_blank, allow_multiple;
28 };
29
30 #define FEEDBACK_CORRECTPLACE 1
31 #define FEEDBACK_CORRECTCOLOUR 2
32
33 typedef struct pegrow {
34 int npegs;
35 int *pegs; /* 0 is 'empty' */
36 int *feedback; /* may well be unused */
37 } *pegrow;
38
39 struct game_state {
40 game_params params;
41 pegrow *guesses; /* length params->nguesses */
42 int *holds;
43 pegrow solution;
44 int next_go; /* from 0 to nguesses-1;
45 if next_go == nguesses then they've lost. */
46 int solved;
47 };
48
49 static game_params *default_params(void)
50 {
51 game_params *ret = snew(game_params);
52
53 /* AFAIK this is the canonical Mastermind ruleset. */
54 ret->ncolours = 6;
55 ret->npegs = 4;
56 ret->nguesses = 10;
57
58 ret->allow_blank = 0;
59 ret->allow_multiple = 1;
60
61 return ret;
62 }
63
64 static void free_params(game_params *params)
65 {
66 sfree(params);
67 }
68
69 static game_params *dup_params(game_params *params)
70 {
71 game_params *ret = snew(game_params);
72 *ret = *params; /* structure copy */
73 return ret;
74 }
75
76 static const struct {
77 char *name;
78 game_params params;
79 } guess_presets[] = {
80 {"Standard", {6, 4, 10, FALSE, TRUE}},
81 {"Super", {8, 5, 12, FALSE, TRUE}},
82 };
83
84
85 static int game_fetch_preset(int i, char **name, game_params **params)
86 {
87 if (i < 0 || i >= lenof(guess_presets))
88 return FALSE;
89
90 *name = dupstr(guess_presets[i].name);
91 /*
92 * get round annoying const issues
93 */
94 {
95 game_params tmp = guess_presets[i].params;
96 *params = dup_params(&tmp);
97 }
98
99 return TRUE;
100 }
101
102 static void decode_params(game_params *params, char const *string)
103 {
104 char const *p = string;
105 game_params *defs = default_params();
106
107 *params = *defs; free_params(defs);
108
109 while (*p) {
110 switch (*p++) {
111 case 'c':
112 params->ncolours = atoi(p);
113 while (*p && isdigit((unsigned char)*p)) p++;
114 break;
115
116 case 'p':
117 params->npegs = atoi(p);
118 while (*p && isdigit((unsigned char)*p)) p++;
119 break;
120
121 case 'g':
122 params->nguesses = atoi(p);
123 while (*p && isdigit((unsigned char)*p)) p++;
124 break;
125
126 case 'b':
127 params->allow_blank = 1;
128 break;
129
130 case 'B':
131 params->allow_blank = 0;
132 break;
133
134 case 'm':
135 params->allow_multiple = 1;
136 break;
137
138 case 'M':
139 params->allow_multiple = 0;
140 break;
141
142 default:
143 ;
144 }
145 }
146 }
147
148 static char *encode_params(game_params *params, int full)
149 {
150 char data[256];
151
152 sprintf(data, "c%dp%dg%d%s%s",
153 params->ncolours, params->npegs, params->nguesses,
154 params->allow_blank ? "b" : "B", params->allow_multiple ? "m" : "M");
155
156 return dupstr(data);
157 }
158
159 static config_item *game_configure(game_params *params)
160 {
161 config_item *ret;
162 char buf[80];
163
164 ret = snewn(6, config_item);
165
166 ret[0].name = "Colours";
167 ret[0].type = C_STRING;
168 sprintf(buf, "%d", params->ncolours);
169 ret[0].sval = dupstr(buf);
170 ret[0].ival = 0;
171
172 ret[1].name = "Pegs per guess";
173 ret[1].type = C_STRING;
174 sprintf(buf, "%d", params->npegs);
175 ret[1].sval = dupstr(buf);
176 ret[1].ival = 0;
177
178 ret[2].name = "Guesses";
179 ret[2].type = C_STRING;
180 sprintf(buf, "%d", params->nguesses);
181 ret[2].sval = dupstr(buf);
182 ret[2].ival = 0;
183
184 ret[3].name = "Allow blanks";
185 ret[3].type = C_BOOLEAN;
186 ret[3].sval = NULL;
187 ret[3].ival = params->allow_blank;
188
189 ret[4].name = "Allow duplicates";
190 ret[4].type = C_BOOLEAN;
191 ret[4].sval = NULL;
192 ret[4].ival = params->allow_multiple;
193
194 ret[5].name = NULL;
195 ret[5].type = C_END;
196 ret[5].sval = NULL;
197 ret[5].ival = 0;
198
199 return ret;
200 }
201
202 static game_params *custom_params(config_item *cfg)
203 {
204 game_params *ret = snew(game_params);
205
206 ret->ncolours = atoi(cfg[0].sval);
207 ret->npegs = atoi(cfg[1].sval);
208 ret->nguesses = atoi(cfg[2].sval);
209
210 ret->allow_blank = cfg[3].ival;
211 ret->allow_multiple = cfg[4].ival;
212
213 return ret;
214 }
215
216 static char *validate_params(game_params *params, int full)
217 {
218 if (params->ncolours < 2 || params->npegs < 2)
219 return "Trivial solutions are uninteresting";
220 /* NB as well as the no. of colours we define, max(ncolours) must
221 * also fit in an unsigned char; see new_game_desc. */
222 if (params->ncolours > 10)
223 return "Too many colours";
224 if (params->nguesses < 1)
225 return "Must have at least one guess";
226 if (!params->allow_multiple && params->ncolours < params->npegs)
227 return "Disallowing multiple colours requires at least as many colours as pegs";
228 return NULL;
229 }
230
231 static pegrow new_pegrow(int npegs)
232 {
233 pegrow pegs = snew(struct pegrow);
234
235 pegs->npegs = npegs;
236 pegs->pegs = snewn(pegs->npegs, int);
237 memset(pegs->pegs, 0, pegs->npegs * sizeof(int));
238 pegs->feedback = snewn(pegs->npegs, int);
239 memset(pegs->feedback, 0, pegs->npegs * sizeof(int));
240
241 return pegs;
242 }
243
244 static pegrow dup_pegrow(pegrow pegs)
245 {
246 pegrow newpegs = new_pegrow(pegs->npegs);
247
248 memcpy(newpegs->pegs, pegs->pegs, newpegs->npegs * sizeof(int));
249 memcpy(newpegs->feedback, pegs->feedback, newpegs->npegs * sizeof(int));
250
251 return newpegs;
252 }
253
254 static void invalidate_pegrow(pegrow pegs)
255 {
256 memset(pegs->pegs, -1, pegs->npegs * sizeof(int));
257 memset(pegs->feedback, -1, pegs->npegs * sizeof(int));
258 }
259
260 static void free_pegrow(pegrow pegs)
261 {
262 sfree(pegs->pegs);
263 sfree(pegs->feedback);
264 sfree(pegs);
265 }
266
267 static char *new_game_desc(game_params *params, random_state *rs,
268 char **aux, int interactive)
269 {
270 unsigned char *bmp = snewn(params->npegs, unsigned char);
271 char *ret;
272 int i, c;
273 pegrow colcount = new_pegrow(params->ncolours);
274
275 for (i = 0; i < params->npegs; i++) {
276 newcol:
277 c = random_upto(rs, params->ncolours);
278 if (!params->allow_multiple && colcount->pegs[c]) goto newcol;
279 colcount->pegs[c]++;
280 bmp[i] = (unsigned char)(c+1);
281 }
282 obfuscate_bitmap(bmp, params->npegs*8, FALSE);
283
284 ret = bin2hex(bmp, params->npegs);
285 sfree(bmp);
286 free_pegrow(colcount);
287 return ret;
288 }
289
290 static char *validate_desc(game_params *params, char *desc)
291 {
292 unsigned char *bmp;
293 int i;
294
295 /* desc is just an (obfuscated) bitmap of the solution; check that
296 * it's the correct length and (when unobfuscated) contains only
297 * sensible colours. */
298 if (strlen(desc) != params->npegs * 2)
299 return "Game description is wrong length";
300 bmp = hex2bin(desc, params->npegs);
301 obfuscate_bitmap(bmp, params->npegs*8, TRUE);
302 for (i = 0; i < params->npegs; i++) {
303 if (bmp[i] < 1 || bmp[i] > params->ncolours) {
304 sfree(bmp);
305 return "Game description is corrupted";
306 }
307 }
308 sfree(bmp);
309
310 return NULL;
311 }
312
313 static game_state *new_game(midend *me, game_params *params, char *desc)
314 {
315 game_state *state = snew(game_state);
316 unsigned char *bmp;
317 int i;
318
319 state->params = *params;
320 state->guesses = snewn(params->nguesses, pegrow);
321 for (i = 0; i < params->nguesses; i++)
322 state->guesses[i] = new_pegrow(params->npegs);
323 state->holds = snewn(params->npegs, int);
324 state->solution = new_pegrow(params->npegs);
325
326 bmp = hex2bin(desc, params->npegs);
327 obfuscate_bitmap(bmp, params->npegs*8, TRUE);
328 for (i = 0; i < params->npegs; i++)
329 state->solution->pegs[i] = (int)bmp[i];
330 sfree(bmp);
331
332 memset(state->holds, 0, sizeof(int) * params->npegs);
333 state->next_go = state->solved = 0;
334
335 return state;
336 }
337
338 static game_state *dup_game(game_state *state)
339 {
340 game_state *ret = snew(game_state);
341 int i;
342
343 *ret = *state;
344
345 ret->guesses = snewn(state->params.nguesses, pegrow);
346 for (i = 0; i < state->params.nguesses; i++)
347 ret->guesses[i] = dup_pegrow(state->guesses[i]);
348 ret->holds = snewn(state->params.npegs, int);
349 memcpy(ret->holds, state->holds, sizeof(int) * state->params.npegs);
350 ret->solution = dup_pegrow(state->solution);
351
352 return ret;
353 }
354
355 static void free_game(game_state *state)
356 {
357 int i;
358
359 free_pegrow(state->solution);
360 for (i = 0; i < state->params.nguesses; i++)
361 free_pegrow(state->guesses[i]);
362 sfree(state->holds);
363 sfree(state->guesses);
364
365 sfree(state);
366 }
367
368 static char *solve_game(game_state *state, game_state *currstate,
369 char *aux, char **error)
370 {
371 return dupstr("S");
372 }
373
374 static char *game_text_format(game_state *state)
375 {
376 return NULL;
377 }
378
379 static int is_markable(game_params *params, pegrow pegs)
380 {
381 int i, nset = 0, nrequired, ret = 0;
382 pegrow colcount = new_pegrow(params->ncolours);
383
384 nrequired = params->allow_blank ? 1 : params->npegs;
385
386 for (i = 0; i < params->npegs; i++) {
387 int c = pegs->pegs[i];
388 if (c > 0) {
389 colcount->pegs[c-1]++;
390 nset++;
391 }
392 }
393 if (nset < nrequired) goto done;
394
395 if (!params->allow_multiple) {
396 for (i = 0; i < params->ncolours; i++) {
397 if (colcount->pegs[i] > 1) goto done;
398 }
399 }
400 ret = 1;
401 done:
402 free_pegrow(colcount);
403 return ret;
404 }
405
406 struct game_ui {
407 game_params params;
408 pegrow curr_pegs; /* half-finished current move */
409 int *holds;
410 int colour_cur; /* position of up-down colour picker cursor */
411 int peg_cur; /* position of left-right peg picker cursor */
412 int display_cur, markable;
413
414 int drag_col, drag_x, drag_y; /* x and y are *center* of peg! */
415 int drag_opeg; /* peg index, if dragged from a peg (from current guess), otherwise -1 */
416 };
417
418 static game_ui *new_ui(game_state *state)
419 {
420 game_ui *ui = snew(game_ui);
421 memset(ui, 0, sizeof(game_ui));
422 ui->params = state->params; /* structure copy */
423 ui->curr_pegs = new_pegrow(state->params.npegs);
424 ui->holds = snewn(state->params.npegs, int);
425 memset(ui->holds, 0, sizeof(int)*state->params.npegs);
426 ui->drag_opeg = -1;
427 return ui;
428 }
429
430 static void free_ui(game_ui *ui)
431 {
432 free_pegrow(ui->curr_pegs);
433 sfree(ui->holds);
434 sfree(ui);
435 }
436
437 static char *encode_ui(game_ui *ui)
438 {
439 char *ret, *p, *sep;
440 int i;
441
442 /*
443 * For this game it's worth storing the contents of the current
444 * guess, and the current set of holds.
445 */
446 ret = snewn(40 * ui->curr_pegs->npegs, char);
447 p = ret;
448 sep = "";
449 for (i = 0; i < ui->curr_pegs->npegs; i++) {
450 p += sprintf(p, "%s%d%s", sep, ui->curr_pegs->pegs[i],
451 ui->holds[i] ? "_" : "");
452 sep = ",";
453 }
454 *p++ = '\0';
455 assert(p - ret < 40 * ui->curr_pegs->npegs);
456 return sresize(ret, p - ret, char);
457 }
458
459 static void decode_ui(game_ui *ui, char *encoding)
460 {
461 int i;
462 char *p = encoding;
463 for (i = 0; i < ui->curr_pegs->npegs; i++) {
464 ui->curr_pegs->pegs[i] = atoi(p);
465 while (*p && isdigit((unsigned char)*p)) p++;
466 if (*p == '_') {
467 /* NB: old versions didn't store holds */
468 ui->holds[i] = 1;
469 p++;
470 } else
471 ui->holds[i] = 0;
472 if (*p == ',') p++;
473 }
474 ui->markable = is_markable(&ui->params, ui->curr_pegs);
475 }
476
477 static void game_changed_state(game_ui *ui, game_state *oldstate,
478 game_state *newstate)
479 {
480 int i;
481
482 /* Implement holds, clear other pegs.
483 * This does something that is arguably the Right Thing even
484 * for undo. */
485 for (i = 0; i < newstate->solution->npegs; i++) {
486 if (newstate->solved)
487 ui->holds[i] = 0;
488 else
489 ui->holds[i] = newstate->holds[i];
490 if (newstate->solved || (newstate->next_go == 0) || !ui->holds[i]) {
491 ui->curr_pegs->pegs[i] = 0;
492 } else
493 ui->curr_pegs->pegs[i] =
494 newstate->guesses[newstate->next_go-1]->pegs[i];
495 }
496 ui->markable = is_markable(&newstate->params, ui->curr_pegs);
497 /* Clean up cursor position */
498 if (!ui->markable && ui->peg_cur == newstate->solution->npegs)
499 ui->peg_cur--;
500 }
501
502 #define PEGSZ (ds->pegsz)
503 #define PEGOFF (ds->pegsz + ds->gapsz)
504 #define HINTSZ (ds->hintsz)
505 #define HINTOFF (ds->hintsz + ds->gapsz)
506
507 #define GAP (ds->gapsz)
508 #define CGAP (ds->gapsz / 2)
509
510 #define PEGRAD (ds->pegrad)
511 #define HINTRAD (ds->hintrad)
512
513 #define COL_OX (ds->colx)
514 #define COL_OY (ds->coly)
515 #define COL_X(c) (COL_OX)
516 #define COL_Y(c) (COL_OY + (c)*PEGOFF)
517 #define COL_W PEGOFF
518 #define COL_H (ds->colours->npegs*PEGOFF)
519
520 #define GUESS_OX (ds->guessx)
521 #define GUESS_OY (ds->guessy)
522 #define GUESS_X(g,p) (GUESS_OX + (p)*PEGOFF)
523 #define GUESS_Y(g,p) (GUESS_OY + (g)*PEGOFF)
524 #define GUESS_W (ds->solution->npegs*PEGOFF)
525 #define GUESS_H (ds->nguesses*PEGOFF)
526
527 #define HINT_OX (GUESS_OX + GUESS_W + ds->gapsz)
528 #define HINT_OY (GUESS_OY + (PEGSZ - HINTOFF - HINTSZ) / 2)
529 #define HINT_X(g) HINT_OX
530 #define HINT_Y(g) (HINT_OY + (g)*PEGOFF)
531 #define HINT_W ((ds->hintw*HINTOFF) - GAP)
532 #define HINT_H GUESS_H
533
534 #define SOLN_OX GUESS_OX
535 #define SOLN_OY (GUESS_OY + GUESS_H + ds->gapsz + 2)
536 #define SOLN_W GUESS_W
537 #define SOLN_H PEGOFF
538
539 struct game_drawstate {
540 int nguesses;
541 pegrow *guesses; /* same size as state->guesses */
542 pegrow solution; /* only displayed if state->solved */
543 pegrow colours; /* length ncolours, not npegs */
544
545 int pegsz, hintsz, gapsz; /* peg size (diameter), etc. */
546 int pegrad, hintrad; /* radius of peg, hint */
547 int border;
548 int colx, coly; /* origin of colours vertical bar */
549 int guessx, guessy; /* origin of guesses */
550 int solnx, solny; /* origin of solution */
551 int hintw; /* no. of hint tiles we're wide per row */
552 int w, h, started, solved;
553
554 int next_go;
555
556 blitter *blit_peg;
557 int drag_col, blit_ox, blit_oy;
558 };
559
560 static void set_peg(game_params *params, game_ui *ui, int peg, int col)
561 {
562 ui->curr_pegs->pegs[peg] = col;
563 ui->markable = is_markable(params, ui->curr_pegs);
564 }
565
566 static int mark_pegs(pegrow guess, pegrow solution, int ncols)
567 {
568 int nc_place = 0, nc_colour = 0, i, j;
569
570 assert(guess && solution && (guess->npegs == solution->npegs));
571
572 for (i = 0; i < guess->npegs; i++) {
573 if (guess->pegs[i] == solution->pegs[i]) nc_place++;
574 }
575
576 /* slight bit of cleverness: we have the following formula, from
577 * http://mathworld.wolfram.com/Mastermind.html that gives:
578 *
579 * nc_colour = sum(colours, min(#solution, #guess)) - nc_place
580 *
581 * I think this is due to Knuth.
582 */
583 for (i = 1; i <= ncols; i++) {
584 int n_guess = 0, n_solution = 0;
585 for (j = 0; j < guess->npegs; j++) {
586 if (guess->pegs[j] == i) n_guess++;
587 if (solution->pegs[j] == i) n_solution++;
588 }
589 nc_colour += min(n_guess, n_solution);
590 }
591 nc_colour -= nc_place;
592
593 debug(("mark_pegs, %d pegs, %d right place, %d right colour",
594 guess->npegs, nc_place, nc_colour));
595 assert((nc_colour + nc_place) <= guess->npegs);
596
597 memset(guess->feedback, 0, guess->npegs*sizeof(int));
598 for (i = 0, j = 0; i < nc_place; i++)
599 guess->feedback[j++] = FEEDBACK_CORRECTPLACE;
600 for (i = 0; i < nc_colour; i++)
601 guess->feedback[j++] = FEEDBACK_CORRECTCOLOUR;
602
603 return nc_place;
604 }
605
606 static char *encode_move(game_state *from, game_ui *ui)
607 {
608 char *buf, *p, *sep;
609 int len, i;
610
611 len = ui->curr_pegs->npegs * 20 + 2;
612 buf = snewn(len, char);
613 p = buf;
614 *p++ = 'G';
615 sep = "";
616 for (i = 0; i < ui->curr_pegs->npegs; i++) {
617 p += sprintf(p, "%s%d%s", sep, ui->curr_pegs->pegs[i],
618 ui->holds[i] ? "_" : "");
619 sep = ",";
620 }
621 *p++ = '\0';
622 assert(p - buf <= len);
623 buf = sresize(buf, len, char);
624
625 return buf;
626 }
627
628 static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
629 int x, int y, int button)
630 {
631 int over_col = 0; /* one-indexed */
632 int over_guess = -1; /* zero-indexed */
633 int over_past_guess_y = -1; /* zero-indexed */
634 int over_past_guess_x = -1; /* zero-indexed */
635 int over_hint = 0; /* zero or one */
636 char *ret = NULL;
637
638 int guess_ox = GUESS_X(from->next_go, 0);
639 int guess_oy = GUESS_Y(from->next_go, 0);
640
641 if (from->solved) return NULL;
642
643 if (x >= COL_OX && x <= (COL_OX + COL_W) &&
644 y >= COL_OY && y <= (COL_OY + COL_H)) {
645 over_col = ((y - COL_OY) / PEGOFF) + 1;
646 } else if (x >= guess_ox &&
647 y >= guess_oy && y <= (guess_oy + GUESS_H)) {
648 if (x <= (guess_ox + GUESS_W)) {
649 over_guess = (x - guess_ox) / PEGOFF;
650 } else {
651 over_hint = 1;
652 }
653 } else if (x >= guess_ox && x <= (guess_ox + GUESS_W) &&
654 y >= GUESS_OY && y < guess_oy) {
655 over_past_guess_y = (y - GUESS_OY) / PEGOFF;
656 over_past_guess_x = (x - guess_ox) / PEGOFF;
657 }
658 debug(("make_move: over_col %d, over_guess %d, over_hint %d,"
659 " over_past_guess (%d,%d)", over_col, over_guess, over_hint,
660 over_past_guess_x, over_past_guess_y));
661
662 assert(ds->blit_peg);
663
664 /* mouse input */
665 if (button == LEFT_BUTTON) {
666 if (over_col > 0) {
667 ui->drag_col = over_col;
668 ui->drag_opeg = -1;
669 debug(("Start dragging from colours"));
670 } else if (over_guess > -1) {
671 int col = ui->curr_pegs->pegs[over_guess];
672 if (col) {
673 ui->drag_col = col;
674 ui->drag_opeg = over_guess;
675 debug(("Start dragging from a guess"));
676 }
677 } else if (over_past_guess_y > -1) {
678 int col =
679 from->guesses[over_past_guess_y]->pegs[over_past_guess_x];
680 if (col) {
681 ui->drag_col = col;
682 ui->drag_opeg = -1;
683 debug(("Start dragging from a past guess"));
684 }
685 }
686 if (ui->drag_col) {
687 ui->drag_x = x;
688 ui->drag_y = y;
689 debug(("Start dragging, col = %d, (%d,%d)",
690 ui->drag_col, ui->drag_x, ui->drag_y));
691 ret = "";
692 }
693 } else if (button == LEFT_DRAG && ui->drag_col) {
694 ui->drag_x = x;
695 ui->drag_y = y;
696 debug(("Keep dragging, (%d,%d)", ui->drag_x, ui->drag_y));
697 ret = "";
698 } else if (button == LEFT_RELEASE && ui->drag_col) {
699 if (over_guess > -1) {
700 debug(("Dropping colour %d onto guess peg %d",
701 ui->drag_col, over_guess));
702 set_peg(&from->params, ui, over_guess, ui->drag_col);
703 } else {
704 if (ui->drag_opeg > -1) {
705 debug(("Removing colour %d from peg %d",
706 ui->drag_col, ui->drag_opeg));
707 set_peg(&from->params, ui, ui->drag_opeg, 0);
708 }
709 }
710 ui->drag_col = 0;
711 ui->drag_opeg = -1;
712 ui->display_cur = 0;
713 debug(("Stop dragging."));
714 ret = "";
715 } else if (button == RIGHT_BUTTON) {
716 if (over_guess > -1) {
717 /* we use ths feedback in the game_ui to signify
718 * 'carry this peg to the next guess as well'. */
719 ui->holds[over_guess] = 1 - ui->holds[over_guess];
720 ret = "";
721 }
722 } else if (button == LEFT_RELEASE && over_hint && ui->markable) {
723 /* NB this won't trigger if on the end of a drag; that's on
724 * purpose, in case you drop by mistake... */
725 ret = encode_move(from, ui);
726 }
727
728 /* keyboard input */
729 if (button == CURSOR_UP || button == CURSOR_DOWN) {
730 ui->display_cur = 1;
731 if (button == CURSOR_DOWN && (ui->colour_cur+1) < from->params.ncolours)
732 ui->colour_cur++;
733 if (button == CURSOR_UP && ui->colour_cur > 0)
734 ui->colour_cur--;
735 ret = "";
736 } else if (button == CURSOR_LEFT || button == CURSOR_RIGHT) {
737 int maxcur = from->params.npegs;
738 if (ui->markable) maxcur++;
739
740 ui->display_cur = 1;
741 if (button == CURSOR_RIGHT && (ui->peg_cur+1) < maxcur)
742 ui->peg_cur++;
743 if (button == CURSOR_LEFT && ui->peg_cur > 0)
744 ui->peg_cur--;
745 ret = "";
746 } else if (button == CURSOR_SELECT || button == ' ' || button == '\r' ||
747 button == '\n') {
748 ui->display_cur = 1;
749 if (ui->peg_cur == from->params.npegs) {
750 ret = encode_move(from, ui);
751 } else {
752 set_peg(&from->params, ui, ui->peg_cur, ui->colour_cur+1);
753 ret = "";
754 }
755 } else if (button == 'D' || button == 'd' || button == '\b') {
756 ui->display_cur = 1;
757 set_peg(&from->params, ui, ui->peg_cur, 0);
758 ret = "";
759 } else if (button == 'H' || button == 'h') {
760 ui->display_cur = 1;
761 ui->holds[ui->peg_cur] = 1 - ui->holds[ui->peg_cur];
762 ret = "";
763 }
764 return ret;
765 }
766
767 static game_state *execute_move(game_state *from, char *move)
768 {
769 int i, nc_place;
770 game_state *ret;
771 char *p;
772
773 if (!strcmp(move, "S")) {
774 ret = dup_game(from);
775 ret->solved = 1;
776 return ret;
777 } else if (move[0] == 'G') {
778 p = move+1;
779
780 ret = dup_game(from);
781
782 for (i = 0; i < from->solution->npegs; i++) {
783 int val = atoi(p);
784 int min_colour = from->params.allow_blank? 0 : 1;
785 if (val < min_colour || val > from->params.ncolours) {
786 free_game(ret);
787 return NULL;
788 }
789 ret->guesses[from->next_go]->pegs[i] = atoi(p);
790 while (*p && isdigit((unsigned char)*p)) p++;
791 if (*p == '_') {
792 ret->holds[i] = 1;
793 p++;
794 } else
795 ret->holds[i] = 0;
796 if (*p == ',') p++;
797 }
798
799 nc_place = mark_pegs(ret->guesses[from->next_go], ret->solution, ret->params.ncolours);
800
801 if (nc_place == ret->solution->npegs) {
802 ret->solved = 1; /* win! */
803 } else {
804 ret->next_go = from->next_go + 1;
805 if (ret->next_go >= ret->params.nguesses)
806 ret->solved = 1; /* 'lose' so we show the pegs. */
807 }
808
809 return ret;
810 } else
811 return NULL;
812 }
813
814 /* ----------------------------------------------------------------------
815 * Drawing routines.
816 */
817
818 #define PEG_PREFER_SZ 32
819
820 /* next three are multipliers for pegsz. It will look much nicer if
821 * (2*PEG_HINT) + PEG_GAP = 1.0 as the hints are formatted like that. */
822 #define PEG_GAP 0.10
823 #define PEG_HINT 0.35
824
825 #define BORDER 0.5
826
827 static void game_compute_size(game_params *params, int tilesize,
828 int *x, int *y)
829 {
830 double hmul, vmul_c, vmul_g, vmul;
831 int hintw = (params->npegs+1)/2;
832
833 hmul = BORDER * 2.0 + /* border */
834 1.0 * 2.0 + /* vertical colour bar */
835 1.0 * params->npegs + /* guess pegs */
836 PEG_GAP * params->npegs + /* guess gaps */
837 PEG_HINT * hintw + /* hint pegs */
838 PEG_GAP * (hintw - 1); /* hint gaps */
839
840 vmul_c = BORDER * 2.0 + /* border */
841 1.0 * params->ncolours + /* colour pegs */
842 PEG_GAP * (params->ncolours - 1); /* colour gaps */
843
844 vmul_g = BORDER * 2.0 + /* border */
845 1.0 * (params->nguesses + 1) + /* guesses plus solution */
846 PEG_GAP * (params->nguesses + 1); /* gaps plus gap above soln */
847
848 vmul = max(vmul_c, vmul_g);
849
850 *x = (int)ceil((double)tilesize * hmul);
851 *y = (int)ceil((double)tilesize * vmul);
852 }
853
854 static void game_set_size(drawing *dr, game_drawstate *ds,
855 game_params *params, int tilesize)
856 {
857 int colh, guessh;
858
859 ds->pegsz = tilesize;
860
861 ds->hintsz = (int)((double)ds->pegsz * PEG_HINT);
862 ds->gapsz = (int)((double)ds->pegsz * PEG_GAP);
863 ds->border = (int)((double)ds->pegsz * BORDER);
864
865 ds->pegrad = (ds->pegsz -1)/2; /* radius of peg to fit in pegsz (which is 2r+1) */
866 ds->hintrad = (ds->hintsz-1)/2;
867
868 colh = ((ds->pegsz + ds->gapsz) * params->ncolours) - ds->gapsz;
869 guessh = ((ds->pegsz + ds->gapsz) * params->nguesses); /* guesses */
870 guessh += ds->gapsz + ds->pegsz; /* solution */
871
872 game_compute_size(params, tilesize, &ds->w, &ds->h);
873 ds->colx = ds->border;
874 ds->coly = (ds->h - colh) / 2;
875
876 ds->guessx = ds->solnx = ds->border + ds->pegsz * 2; /* border + colours */
877 ds->guessy = (ds->h - guessh) / 2;
878 ds->solny = ds->guessy + ((ds->pegsz + ds->gapsz) * params->nguesses) + ds->gapsz;
879
880 assert(ds->pegsz > 0);
881 assert(!ds->blit_peg); /* set_size is never called twice */
882 ds->blit_peg = blitter_new(dr, ds->pegsz, ds->pegsz);
883 }
884
885 static float *game_colours(frontend *fe, int *ncolours)
886 {
887 float *ret = snewn(3 * NCOLOURS, float), max;
888 int i;
889
890 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
891
892 /* red */
893 ret[COL_1 * 3 + 0] = 1.0F;
894 ret[COL_1 * 3 + 1] = 0.0F;
895 ret[COL_1 * 3 + 2] = 0.0F;
896
897 /* yellow */
898 ret[COL_2 * 3 + 0] = 1.0F;
899 ret[COL_2 * 3 + 1] = 1.0F;
900 ret[COL_2 * 3 + 2] = 0.0F;
901
902 /* green */
903 ret[COL_3 * 3 + 0] = 0.0F;
904 ret[COL_3 * 3 + 1] = 1.0F;
905 ret[COL_3 * 3 + 2] = 0.0F;
906
907 /* blue */
908 ret[COL_4 * 3 + 0] = 0.0F;
909 ret[COL_4 * 3 + 1] = 0.0F;
910 ret[COL_4 * 3 + 2] = 1.0F;
911
912 /* orange */
913 ret[COL_5 * 3 + 0] = 1.0F;
914 ret[COL_5 * 3 + 1] = 0.5F;
915 ret[COL_5 * 3 + 2] = 0.0F;
916
917 /* purple */
918 ret[COL_6 * 3 + 0] = 0.5F;
919 ret[COL_6 * 3 + 1] = 0.0F;
920 ret[COL_6 * 3 + 2] = 0.7F;
921
922 /* brown */
923 ret[COL_7 * 3 + 0] = 0.4F;
924 ret[COL_7 * 3 + 1] = 0.2F;
925 ret[COL_7 * 3 + 2] = 0.2F;
926
927 /* light blue */
928 ret[COL_8 * 3 + 0] = 0.4F;
929 ret[COL_8 * 3 + 1] = 0.7F;
930 ret[COL_8 * 3 + 2] = 1.0F;
931
932 /* light green */
933 ret[COL_9 * 3 + 0] = 0.7F;
934 ret[COL_9 * 3 + 1] = 1.0F;
935 ret[COL_9 * 3 + 2] = 0.7F;
936
937 /* pink */
938 ret[COL_10 * 3 + 0] = 1.0F;
939 ret[COL_10 * 3 + 1] = 0.6F;
940 ret[COL_10 * 3 + 2] = 1.0F;
941
942 ret[COL_FRAME * 3 + 0] = 0.0F;
943 ret[COL_FRAME * 3 + 1] = 0.0F;
944 ret[COL_FRAME * 3 + 2] = 0.0F;
945
946 ret[COL_CURSOR * 3 + 0] = 0.0F;
947 ret[COL_CURSOR * 3 + 1] = 0.0F;
948 ret[COL_CURSOR * 3 + 2] = 0.0F;
949
950 ret[COL_FLASH * 3 + 0] = 0.5F;
951 ret[COL_FLASH * 3 + 1] = 1.0F;
952 ret[COL_FLASH * 3 + 2] = 1.0F;
953
954 ret[COL_HOLD * 3 + 0] = 1.0F;
955 ret[COL_HOLD * 3 + 1] = 0.5F;
956 ret[COL_HOLD * 3 + 2] = 0.5F;
957
958 ret[COL_CORRECTPLACE*3 + 0] = 0.0F;
959 ret[COL_CORRECTPLACE*3 + 1] = 0.0F;
960 ret[COL_CORRECTPLACE*3 + 2] = 0.0F;
961
962 ret[COL_CORRECTCOLOUR*3 + 0] = 1.0F;
963 ret[COL_CORRECTCOLOUR*3 + 1] = 1.0F;
964 ret[COL_CORRECTCOLOUR*3 + 2] = 1.0F;
965
966 /* We want to make sure we can distinguish COL_CORRECTCOLOUR
967 * (which we hard-code as white) from COL_BACKGROUND (which
968 * could default to white on some platforms).
969 * Code borrowed from fifteen.c. */
970 max = ret[COL_BACKGROUND*3];
971 for (i = 1; i < 3; i++)
972 if (ret[COL_BACKGROUND*3+i] > max)
973 max = ret[COL_BACKGROUND*3+i];
974 if (max * 1.2F > 1.0F) {
975 for (i = 0; i < 3; i++)
976 ret[COL_BACKGROUND*3+i] /= (max * 1.2F);
977 }
978
979 /* We also want to be able to tell the difference between BACKGROUND
980 * and EMPTY, for similar distinguishing-hint reasons. */
981 ret[COL_EMPTY * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 2.0 / 3.0;
982 ret[COL_EMPTY * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 2.0 / 3.0;
983 ret[COL_EMPTY * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 2.0 / 3.0;
984
985 *ncolours = NCOLOURS;
986 return ret;
987 }
988
989 static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
990 {
991 struct game_drawstate *ds = snew(struct game_drawstate);
992 int i;
993
994 memset(ds, 0, sizeof(struct game_drawstate));
995
996 ds->guesses = snewn(state->params.nguesses, pegrow);
997 ds->nguesses = state->params.nguesses;
998 for (i = 0; i < state->params.nguesses; i++) {
999 ds->guesses[i] = new_pegrow(state->params.npegs);
1000 invalidate_pegrow(ds->guesses[i]);
1001 }
1002 ds->solution = new_pegrow(state->params.npegs);
1003 invalidate_pegrow(ds->solution);
1004 ds->colours = new_pegrow(state->params.ncolours);
1005 invalidate_pegrow(ds->colours);
1006
1007 ds->hintw = (state->params.npegs+1)/2; /* must round up */
1008
1009 ds->blit_peg = NULL;
1010
1011 return ds;
1012 }
1013
1014 static void game_free_drawstate(drawing *dr, game_drawstate *ds)
1015 {
1016 int i;
1017
1018 if (ds->blit_peg) blitter_free(dr, ds->blit_peg);
1019 free_pegrow(ds->colours);
1020 free_pegrow(ds->solution);
1021 for (i = 0; i < ds->nguesses; i++)
1022 free_pegrow(ds->guesses[i]);
1023 sfree(ds->guesses);
1024 sfree(ds);
1025 }
1026
1027 static void draw_peg(drawing *dr, game_drawstate *ds, int cx, int cy,
1028 int moving, int col)
1029 {
1030 /*
1031 * Some platforms antialias circles, which means we shouldn't
1032 * overwrite a circle of one colour with a circle of another
1033 * colour without erasing the background first. However, if the
1034 * peg is the one being dragged, we don't erase the background
1035 * because we _want_ it to alpha-blend nicely into whatever's
1036 * behind it.
1037 */
1038 if (!moving)
1039 draw_rect(dr, cx-CGAP, cy-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2,
1040 COL_BACKGROUND);
1041 if (PEGRAD > 0) {
1042 draw_circle(dr, cx+PEGRAD, cy+PEGRAD, PEGRAD,
1043 COL_EMPTY + col, (col ? COL_FRAME : COL_EMPTY));
1044 } else
1045 draw_rect(dr, cx, cy, PEGSZ, PEGSZ, COL_EMPTY + col);
1046 draw_update(dr, cx-CGAP, cy-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2);
1047 }
1048
1049 static void draw_cursor(drawing *dr, game_drawstate *ds, int x, int y)
1050 {
1051 draw_circle(dr, x+PEGRAD, y+PEGRAD, PEGRAD+CGAP, -1, COL_CURSOR);
1052
1053 draw_update(dr, x-CGAP, y-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2);
1054 }
1055
1056 static void guess_redraw(drawing *dr, game_drawstate *ds, int guess,
1057 pegrow src, int *holds, int cur_col, int force)
1058 {
1059 pegrow dest;
1060 int rowx, rowy, i, scol;
1061
1062 if (guess == -1) {
1063 dest = ds->solution;
1064 rowx = SOLN_OX;
1065 rowy = SOLN_OY;
1066 } else {
1067 dest = ds->guesses[guess];
1068 rowx = GUESS_X(guess,0);
1069 rowy = GUESS_Y(guess,0);
1070 }
1071 if (src) assert(src->npegs == dest->npegs);
1072
1073 for (i = 0; i < dest->npegs; i++) {
1074 scol = src ? src->pegs[i] : 0;
1075 if (i == cur_col)
1076 scol |= 0x1000;
1077 if (holds && holds[i])
1078 scol |= 0x2000;
1079 if ((dest->pegs[i] != scol) || force) {
1080 draw_peg(dr, ds, rowx + PEGOFF * i, rowy, FALSE, scol &~ 0x3000);
1081 /*
1082 * Hold marker.
1083 */
1084 draw_rect(dr, rowx + PEGOFF * i, rowy + PEGSZ + ds->gapsz/2,
1085 PEGSZ, 2, (scol & 0x2000 ? COL_HOLD : COL_BACKGROUND));
1086 draw_update(dr, rowx + PEGOFF * i, rowy + PEGSZ + ds->gapsz/2,
1087 PEGSZ, 2);
1088 if (scol & 0x1000)
1089 draw_cursor(dr, ds, rowx + PEGOFF * i, rowy);
1090 }
1091 dest->pegs[i] = scol;
1092 }
1093 }
1094
1095 static void hint_redraw(drawing *dr, game_drawstate *ds, int guess,
1096 pegrow src, int force, int cursor, int markable)
1097 {
1098 pegrow dest = ds->guesses[guess];
1099 int rowx, rowy, i, scol, col, hintlen;
1100 int need_redraw;
1101 int emptycol = (markable ? COL_FLASH : COL_EMPTY);
1102
1103 if (src) assert(src->npegs == dest->npegs);
1104
1105 hintlen = (dest->npegs + 1)/2;
1106
1107 /*
1108 * Because of the possible presence of the cursor around this
1109 * entire section, we redraw all or none of it but never part.
1110 */
1111 need_redraw = FALSE;
1112
1113 for (i = 0; i < dest->npegs; i++) {
1114 scol = src ? src->feedback[i] : 0;
1115 if (i == 0 && cursor)
1116 scol |= 0x1000;
1117 if (i == 0 && markable)
1118 scol |= 0x2000;
1119 if ((scol != dest->feedback[i]) || force) {
1120 need_redraw = TRUE;
1121 }
1122 dest->feedback[i] = scol;
1123 }
1124
1125 if (need_redraw) {
1126 int hinth = HINTSZ + GAP + HINTSZ;
1127 int hx,hy,hw,hh;
1128
1129 hx = HINT_X(guess)-GAP; hy = HINT_Y(guess)-GAP;
1130 hw = HINT_W+GAP*2; hh = hinth+GAP*2;
1131
1132 /* erase a large background rectangle */
1133 draw_rect(dr, hx, hy, hw, hh, COL_BACKGROUND);
1134
1135 for (i = 0; i < dest->npegs; i++) {
1136 scol = src ? src->feedback[i] : 0;
1137 col = ((scol == FEEDBACK_CORRECTPLACE) ? COL_CORRECTPLACE :
1138 (scol == FEEDBACK_CORRECTCOLOUR) ? COL_CORRECTCOLOUR :
1139 emptycol);
1140
1141 rowx = HINT_X(guess);
1142 rowy = HINT_Y(guess);
1143 if (i < hintlen) {
1144 rowx += HINTOFF * i;
1145 } else {
1146 rowx += HINTOFF * (i - hintlen);
1147 rowy += HINTOFF;
1148 }
1149 if (HINTRAD > 0) {
1150 draw_circle(dr, rowx+HINTRAD, rowy+HINTRAD, HINTRAD, col,
1151 (col == emptycol ? emptycol : COL_FRAME));
1152 } else {
1153 draw_rect(dr, rowx, rowy, HINTSZ, HINTSZ, col);
1154 }
1155 }
1156 if (cursor) {
1157 int x1,y1,x2,y2;
1158 x1 = hx + CGAP; y1 = hy + CGAP;
1159 x2 = hx + hw - CGAP; y2 = hy + hh - CGAP;
1160 draw_line(dr, x1, y1, x2, y1, COL_CURSOR);
1161 draw_line(dr, x2, y1, x2, y2, COL_CURSOR);
1162 draw_line(dr, x2, y2, x1, y2, COL_CURSOR);
1163 draw_line(dr, x1, y2, x1, y1, COL_CURSOR);
1164 }
1165
1166 draw_update(dr, hx, hy, hw, hh);
1167 }
1168 }
1169
1170 static void currmove_redraw(drawing *dr, game_drawstate *ds, int guess, int col)
1171 {
1172 int ox = GUESS_X(guess, 0), oy = GUESS_Y(guess, 0), off = PEGSZ/4;
1173
1174 draw_rect(dr, ox-off-1, oy, 2, PEGSZ, col);
1175 draw_update(dr, ox-off-1, oy, 2, PEGSZ);
1176 }
1177
1178 static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
1179 game_state *state, int dir, game_ui *ui,
1180 float animtime, float flashtime)
1181 {
1182 int i, new_move, last_go;
1183
1184 new_move = (state->next_go != ds->next_go) || !ds->started;
1185 last_go = (state->next_go == state->params.nguesses-1);
1186
1187 if (!ds->started) {
1188 draw_rect(dr, 0, 0, ds->w, ds->h, COL_BACKGROUND);
1189 draw_rect(dr, SOLN_OX, SOLN_OY - ds->gapsz - 1, SOLN_W, 2, COL_FRAME);
1190 draw_update(dr, 0, 0, ds->w, ds->h);
1191 }
1192
1193 if (ds->drag_col != 0) {
1194 debug(("Loading from blitter."));
1195 blitter_load(dr, ds->blit_peg, ds->blit_ox, ds->blit_oy);
1196 draw_update(dr, ds->blit_ox, ds->blit_oy, PEGSZ, PEGSZ);
1197 }
1198
1199 /* draw the colours */
1200 for (i = 0; i < state->params.ncolours; i++) {
1201 int val = i+1;
1202 if (ui->display_cur && ui->colour_cur == i)
1203 val |= 0x1000;
1204 if (ds->colours->pegs[i] != val) {
1205 draw_peg(dr, ds, COL_X(i), COL_Y(i), FALSE, i+1);
1206 if (val & 0x1000)
1207 draw_cursor(dr, ds, COL_X(i), COL_Y(i));
1208 ds->colours->pegs[i] = val;
1209 }
1210 }
1211
1212 /* draw the guesses (so far) and the hints
1213 * (in reverse order to avoid trampling holds) */
1214 for (i = state->params.nguesses - 1; i >= 0; i--) {
1215 if (state->next_go > i || state->solved) {
1216 /* this info is stored in the game_state already */
1217 guess_redraw(dr, ds, i, state->guesses[i], NULL, -1, 0);
1218 hint_redraw(dr, ds, i, state->guesses[i],
1219 i == (state->next_go-1) ? 1 : 0, FALSE, FALSE);
1220 } else if (state->next_go == i) {
1221 /* this is the one we're on; the (incomplete) guess is
1222 * stored in the game_ui. */
1223 guess_redraw(dr, ds, i, ui->curr_pegs,
1224 ui->holds, ui->display_cur ? ui->peg_cur : -1, 0);
1225 hint_redraw(dr, ds, i, NULL, 1,
1226 ui->display_cur && ui->peg_cur == state->params.npegs,
1227 ui->markable);
1228 } else {
1229 /* we've not got here yet; it's blank. */
1230 guess_redraw(dr, ds, i, NULL, NULL, -1, 0);
1231 hint_redraw(dr, ds, i, NULL, 0, FALSE, FALSE);
1232 }
1233 }
1234
1235 /* draw the 'current move' and 'able to mark' sign. */
1236 if (new_move)
1237 currmove_redraw(dr, ds, ds->next_go, COL_BACKGROUND);
1238 if (!state->solved)
1239 currmove_redraw(dr, ds, state->next_go, COL_HOLD);
1240
1241 /* draw the solution (or the big rectangle) */
1242 if ((state->solved != ds->solved) || !ds->started) {
1243 draw_rect(dr, SOLN_OX, SOLN_OY, SOLN_W, SOLN_H,
1244 state->solved ? COL_BACKGROUND : COL_EMPTY);
1245 draw_update(dr, SOLN_OX, SOLN_OY, SOLN_W, SOLN_H);
1246 }
1247 if (state->solved)
1248 guess_redraw(dr, ds, -1, state->solution, NULL, -1, !ds->solved);
1249 ds->solved = state->solved;
1250
1251 ds->next_go = state->next_go;
1252
1253 /* if ui->drag_col != 0, save the screen to the blitter,
1254 * draw the peg where we saved, and set ds->drag_* == ui->drag_*. */
1255 if (ui->drag_col != 0) {
1256 int ox = ui->drag_x - (PEGSZ/2);
1257 int oy = ui->drag_y - (PEGSZ/2);
1258 debug(("Saving to blitter at (%d,%d)", ox, oy));
1259 blitter_save(dr, ds->blit_peg, ox, oy);
1260 draw_peg(dr, ds, ox, oy, TRUE, ui->drag_col);
1261
1262 ds->blit_ox = ox; ds->blit_oy = oy;
1263 }
1264 ds->drag_col = ui->drag_col;
1265
1266 ds->started = 1;
1267 }
1268
1269 static float game_anim_length(game_state *oldstate, game_state *newstate,
1270 int dir, game_ui *ui)
1271 {
1272 return 0.0F;
1273 }
1274
1275 static float game_flash_length(game_state *oldstate, game_state *newstate,
1276 int dir, game_ui *ui)
1277 {
1278 return 0.0F;
1279 }
1280
1281 static int game_timing_state(game_state *state, game_ui *ui)
1282 {
1283 return TRUE;
1284 }
1285
1286 static void game_print_size(game_params *params, float *x, float *y)
1287 {
1288 }
1289
1290 static void game_print(drawing *dr, game_state *state, int tilesize)
1291 {
1292 }
1293
1294 #ifdef COMBINED
1295 #define thegame guess
1296 #endif
1297
1298 const struct game thegame = {
1299 "Guess", "games.guess",
1300 default_params,
1301 game_fetch_preset,
1302 decode_params,
1303 encode_params,
1304 free_params,
1305 dup_params,
1306 TRUE, game_configure, custom_params,
1307 validate_params,
1308 new_game_desc,
1309 validate_desc,
1310 new_game,
1311 dup_game,
1312 free_game,
1313 TRUE, solve_game,
1314 FALSE, game_text_format,
1315 new_ui,
1316 free_ui,
1317 encode_ui,
1318 decode_ui,
1319 game_changed_state,
1320 interpret_move,
1321 execute_move,
1322 PEG_PREFER_SZ, game_compute_size, game_set_size,
1323 game_colours,
1324 game_new_drawstate,
1325 game_free_drawstate,
1326 game_redraw,
1327 game_anim_length,
1328 game_flash_length,
1329 FALSE, FALSE, game_print_size, game_print,
1330 FALSE, /* wants_statusbar */
1331 FALSE, game_timing_state,
1332 0, /* flags */
1333 };
1334
1335 /* vim: set shiftwidth=4 tabstop=8: */