]> git.cworth.org Git - wordgame/blob - grid.h
Increase the window size a bit
[wordgame] / grid.h
1 /*
2  * Copyright © 2006 Carl Worth
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
17  */
18
19 #ifndef _GRID_H_
20 #define _GRID_H_
21
22 #include "dict.h"
23
24 #define GRID_SIZE_MAX 5
25 /* (  3 chars per cell
26  *  x GRID_SIZE_MAX cells per row
27  *  + 1 newline per row
28  * ) x GRID_SIZE_MAX rows per grid
29  *   + 1 terminator character
30  */
31 #define GRID_STRING_MAX (((3 * GRID_SIZE_MAX + 1) * GRID_SIZE_MAX) + 1)
32
33 typedef struct _grid {
34     int size;
35     char letters[GRID_SIZE_MAX][GRID_SIZE_MAX];
36     char string[GRID_STRING_MAX];
37
38     /* Private, transient state used by enumerate */
39     dict_t *results;
40 } grid_t;
41
42 /* size must be 4 or 5 */
43 void
44 grid_init (grid_t *grid, int size);
45
46 void
47 grid_set_letters (grid_t        *grid,
48                   const char    *letters);
49
50 char *
51 grid_string (grid_t *grid);
52
53 void
54 grid_solve (grid_t *grid, dict_t *dict, dict_t *solution);
55
56 #endif /* _GRID_H_ */