82 if (zx > xsize-1 || ax < 1) {
85 if (zy > ysize-1 || ay < 1) {
90 if (sx < 3 || sy < 3) {
95 for (walk = Rooms; walk->
x != 0; walk++) {
96 int dx = abs(tx-walk->
x);
97 int dy = abs(ty-walk->
y);
99 if ((dx < (walk->
sx+sx)/2+xlim) && (dy < (walk->
sy+sy)/2+ylim)) {
107 for (walk = Rooms; walk->
x != 0; walk++)
128 int making_circle =
RANDOM() % 2;
133 for (walk = Rooms; walk->
x != 0; walk++) {
134 if (walk->
sx < walk->
sy) {
141 for (i = walk->
ax; i < walk->zx; i++)
142 for (j = walk->
ay; j < walk->zy; j++) {
143 if (!making_circle || ((
int)(0.5+hypot(walk->
x-i, walk->
y-j))) <= R) {
162 if (Rooms[1].
x == 0) {
166 for (walk = Rooms+1; walk->
x != 0; walk++) {
169 int x2 = (walk-1)->
x;
170 int y2 = (walk-1)->
y;
178 int tx = x2, ty = y2;
186 for (i = x1; i < x2; i++) {
187 if (in_wall == 0 && maze[i][j] ==
'#') {
190 }
else if (in_wall && maze[i][j] ==
'.') {
193 }
else if (maze[i][j] !=
'D' && maze[i][j] !=
'.') {
198 if (maze[i][j] ==
'.') {
201 if (maze[i][j] == 0 || maze[i][j] ==
'#') {
204 for (; j <
MAX(y1, y2); j++) {
205 if (in_wall == 0 && maze[i][j] ==
'#') {
208 }
else if (in_wall && maze[i][j] ==
'.') {
211 }
else if (maze[i][j] !=
'D' && maze[i][j] !=
'.') {
219 int tx = x2, ty = y2;
227 for (j = y1; j < y2; j++) {
228 if (in_wall == 0 && maze[i][j] ==
'#') {
231 }
else if (in_wall && maze[i][j] ==
'.') {
234 }
else if (maze[i][j] !=
'D' && maze[i][j] !=
'.') {
240 if (maze[i][j] ==
'.') {
243 if (maze[i][j] == 0 || maze[i][j] ==
'#') {
246 for (; i <
MAX(x1, x2); i++) {
247 if (in_wall == 0 && maze[i][j] ==
'#') {
250 }
else if (in_wall && maze[i][j] ==
'.') {
253 }
else if (maze[i][j] !=
'D' && maze[i][j] !=
'.') {
281 int surround_index = 0;
283 if ((i > 0) && (
layout[i-1][j] != 0 &&
layout[i-1][j] !=
'.')) {
286 if ((i < Xsize-1) && (
layout[i+1][j] != 0 &&
layout[i+1][j] !=
'.')) {
289 if ((j > 0) && (
layout[i][j-1] != 0 &&
layout[i][j-1] !=
'.')) {
292 if ((j < Ysize-1) && (
layout[i][j+1] != 0 &&
layout[i][j+1] !=
'.')) {
295 return surround_index;
316 (
void)_unused_options;
317 (
void)_unused_layers;
320 char **maze = (
char **)malloc(
sizeof(
char *)*xsize);
321 for (i = 0; i < xsize; i++) {
322 maze[i] = (
char *)malloc(
sizeof(
char)*ysize);
323 for (j = 0; j < ysize; j++) {
332 if (xsize < 11 || ysize < 11) {
333 for (i = 1; i < xsize-1; i++)
334 for (j = 1; j < ysize-1; j++) {
337 maze[(xsize-1)/2][(ysize-1)/2] =
'>';
338 maze[(xsize-1)/2][(ysize-1)/2+1] =
'<';
344 Rooms = (
Room *)calloc(nrooms+1,
sizeof(
Room));
348 while (tries < 450 && i < nrooms) {
358 for (i = 1; i < xsize-1; i++)
359 for (j = 1; j < ysize-1; j++) {
362 maze[(xsize-1)/2][(ysize-1)/2] =
'>';
363 maze[(xsize-1)/2][(ysize-1)/2+1] =
'<';
375 maze[Rooms->
x][Rooms->
y] =
'<';
377 for (walk = Rooms; walk->
x != 0; walk++)
387 if (maze[walk->
x][walk->
y+1] ==
'.') {
388 maze[walk->
x][walk->
y+1] =
'>';
390 maze[walk->
x][walk->
y-1] =
'>';
393 maze[walk->
x][walk->
y] =
'>';
397 for (i = 0; i < xsize; i++)
398 for (j = 0; j < ysize; j++) {
399 if (maze[i][j] ==
'.') {
402 if (maze[i][j] ==
'D') {
405 if (si != 3 && si != 12) {