31 #define RANDOM_OPTIONS 0 32 #define REGULAR_SPIRAL 1 35 #define MAX_SPIRAL_OPT 8 41 #define MIN(x, y) (((x) < (y)) ? (x) : (y)) 44 #define MAX(x, y) (((x) < (y)) ? (y) : (x)) 47 #define MAX_FINE .454545 49 extern int surround_check(
char **maze,
int i,
int j,
int xsize,
int ysize);
74 char **maze = (
char **)calloc(
sizeof(
char *), xsize);
76 for (i = 0; i < xsize; i++) {
77 maze[i] = (
char *)calloc(
sizeof(
char), ysize);
81 for (i = 0; i < xsize; i++)
82 for (j = 0; j < ysize; j++) {
102 if (
RANDOM()%2 && (option®ULAR_SPIRAL)) {
113 float pitch = (
RANDOM()%5)/10.+10./22.;
115 xscale = yscale = pitch;
118 if ((option&FIT_SPIRAL) && (xsize != ysize)) {
120 xscale *= (float)xsize/(
float)ysize;
122 yscale *= (float)ysize/(
float)xsize;
126 if (option®ULAR_SPIRAL) {
127 float scale =
MIN(xscale, yscale);
129 xscale = yscale = scale;
133 while ((fabsf(x) < SizeX) && (fabsf(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] =
'>';
161 int i, j, ic = xsize/2, jc = ysize/2;
166 for (i = ic-1, j = jc; i > 0 && layout[i][j] ==
'#'; i--) {
170 for (i = ic+1, j = jc; i < xsize-1 && layout[i][j] ==
'#'; i++) {
178 for (i = ic, j = jc-1; j > 0 && layout[i][j] ==
'#'; j--) {
182 for (i = ic, j = jc+1; j < ysize-1 && layout[i][j] ==
'#'; j++) {
189 layout[ic][jc/2] = 0;
190 layout[ic/2][jc] = 0;
191 layout[ic][jc/2+jc] = 0;
192 layout[ic/2+ic][jc] = 0;
193 for (i = ic-1, j = jc/2; i > 0 && layout[i][j] ==
'#'; i--) {
198 for (i = ic+1, j = jc/2; i < xsize-1 && layout[i][j] ==
'#'; i++) {
203 for (i = ic/2, j = jc-1; j > 0 && layout[i][j] ==
'#'; j--) {
208 for (i = ic/2, j = jc+1; j < ysize-1 && layout[i][j] ==
'#'; j++) {
215 for (i = 0; i < xsize; i++)
216 for (j = 0; j < ysize; j++) {
217 if (layout[i][j] ==
'D') {
219 if (si != 3 && si != 12) {
#define MAX_SPIRAL_OPT
this should be 2x the last real option
Random map related variables.
char ** map_gen_spiral(int xsize, int ysize, int option, int _unused_layers)
Generates a spiral layout.
Global type definitions and header inclusions.
#define FINE_SPIRAL
uses the min.
void connect_spirals(int xsize, int ysize, int sym, char **layout)
Connects disjoint spirals which may result from the symmetrization process.
#define FIT_SPIRAL
scale to a rectangular region, not square
#define REGULAR_SPIRAL
Regular spiral–distance increases constantly.
int surround_check(char **maze, int i, int j, int xsize, int ysize)
Checks free spots around a spot.
#define Y_SYM
Horizontal symmetry.
#define X_SYM
Vertical symmetry.
#define XY_SYM
Reflection.