38 #define RANDOM_OPTIONS 0
39 #define REGULAR_SPIRAL 1
42 #define MAX_SPIRAL_OPT 8
48 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
51 #define MAX(x, y) (((x) < (y)) ? (y) : (x))
54 #define MAX_FINE .454545
56 extern int surround_check(
char **maze,
int i,
int j,
int xsize,
int ysize);
77 char **maze = (
char **)calloc(
sizeof(
char *), xsize);
79 for (i = 0; i < xsize; i++) {
80 maze[i] = (
char *)calloc(
sizeof(
char), ysize);
84 for (i = 0; i < xsize; i++)
85 for (j = 0; j < ysize; j++)
104 if (RANDOM()%2 && (option®ULAR_SPIRAL))
114 float pitch = (RANDOM()%5)/10.+10./22.;
116 xscale = yscale = pitch;
119 if ((option&FIT_SPIRAL) && (xsize != ysize)) {
121 xscale *= (float)xsize/(
float)ysize;
123 yscale *= (float)ysize/(
float)xsize;
126 if (option®ULAR_SPIRAL) {
127 float scale =
MIN(xscale, yscale);
129 xscale = yscale = scale;
133 while ((abs(x) < SizeX) && (abs(y) < SizeY)) {
134 x = parm*cos(parm)*xscale;
135 y = parm*sin(parm)*yscale;
136 maze[(int)(ic+x)][(int)(jc+y)] =
'\0';
140 maze[(int)(ic+x+0.5)][(int)(jc+y+0.5)] =
'<';
143 maze[ic][jc+1] =
'>';
160 int i, j, ic = xsize/2, jc = ysize/2;
165 for (i = ic-1, j = jc; i > 0 && layout[i][j] ==
'#'; i--)
168 for (i = ic+1, j = jc; i < xsize-1 && layout[i][j] ==
'#'; i++)
175 for (i = ic, j = jc-1; j > 0 && layout[i][j] ==
'#'; j--)
178 for (i = ic, j = jc+1; j < ysize-1 && layout[i][j] ==
'#'; j++)
184 layout[ic][jc/2] = 0;
185 layout[ic/2][jc] = 0;
186 layout[ic][jc/2+jc] = 0;
187 layout[ic/2+ic][jc] = 0;
188 for (i = ic-1, j = jc/2; i > 0 && layout[i][j] ==
'#'; i--) {
193 for (i = ic+1, j = jc/2; i < xsize-1 && layout[i][j] ==
'#'; i++) {
198 for (i = ic/2, j = jc-1; j > 0 && layout[i][j] ==
'#'; j--) {
203 for (i = ic/2, j = jc+1; j < ysize-1 && layout[i][j] ==
'#'; j++) {
210 for (i = 0; i < xsize; i++)
211 for (j = 0; j < ysize; j++) {
212 if (layout[i][j] ==
'D') {
214 if (si != 3 && si != 12) {
char ** map_gen_spiral(int xsize, int ysize, int option)
void connect_spirals(int xsize, int ysize, int sym, char **layout)
int surround_check(char **maze, int i, int j, int xsize, int ysize)