53 static int find_free_point(
char **maze,
int *x,
int *y,
int xc,
int yc,
int xsize,
int ysize);
68 char **
maze_gen(
int xsize,
int ysize,
int option) {
73 char **maze = (
char **)calloc(
sizeof(
char *), xsize);
74 for (i = 0; i < xsize; i++) {
75 maze[i] = (
char *)calloc(
sizeof(
char), ysize);
79 for (i = 0; i < xsize; i++)
80 maze[i][0] = maze[i][ysize-1] =
'#';
81 for (j = 0; j < ysize; j++)
82 maze[0][j] = maze[xsize-1][j] =
'#';
135 for (i = 2; i < xsize-2; i++) {
145 for (j = 2; j < ysize-2; j++) {
191 static int find_free_point(
char **maze,
int *x,
int *y,
int xc,
int yc,
int xsize,
int ysize) {
197 if (yc < ysize-2 && xc > 2 && xc < xsize-2) {
198 int cleartest = (int)maze[xc][yc+1]+(
int)maze[xc-1][yc+1]+(int)maze[xc+1][yc+1];
200 cleartest += (int)maze[xc][yc+2]+(
int)maze[xc-1][yc+2]+(int)maze[xc+1][yc+2];
201 if (cleartest == 0) {
208 if (yc > 2 && xc > 2 && xc < xsize-2) {
209 int cleartest = (int)maze[xc][yc-1]+(
int)maze[xc-1][yc-1]+(int)maze[xc+1][yc-1];
211 cleartest += (int)maze[xc][yc-2]+(
int)maze[xc-1][yc-2]+(int)maze[xc+1][yc-2];
212 if (cleartest == 0) {
220 if (xc < xsize-2 && yc > 2 && yc < ysize-2) {
221 int cleartest = (int)maze[xc+1][yc]+(
int)maze[xc+1][yc-1]+(int)maze[xc+1][yc+1];
223 cleartest += (int)maze[xc+2][yc]+(
int)maze[xc+2][yc-1]+(int)maze[xc+2][yc+1];
224 if (cleartest == 0) {
232 if (xc > 2 && yc > 2 && yc < ysize-2) {
233 int cleartest = (int)maze[xc-1][yc]+(
int)maze[xc-1][yc-1]+(int)maze[xc-1][yc+1];
235 cleartest += (int)maze[xc-2][yc]+(
int)maze[xc-2][yc-1]+(int)maze[xc-2][yc+1];
236 if (cleartest == 0) {
247 count = RANDOM()%count;
250 switch (dirlist[count]) {
static void fill_maze_full(char **maze, int x, int y, int xsize, int ysize, free_walls_struct *)
static void make_wall_free_list(int xsize, int ysize, free_walls_struct *)
static void fill_maze_sparse(char **maze, int x, int y, int xsize, int ysize, free_walls_struct *)
static int find_free_point(char **maze, int *x, int *y, int xc, int yc, int xsize, int ysize)
struct free_walls_struct free_walls_struct
static void pop_wall_point(int *x, int *y, free_walls_struct *)
char ** maze_gen(int xsize, int ysize, int option)