Maze generation: Difference between revisions

Content added Content deleted
m (→‎{{header|D}}: added start and end)
Line 110: Line 110:
void print() {
void print() {
maze[0][0].m &= ~north;
maze[0][0].m &= ~north;
maze[h-1][w-1].m &= ~east;
maze[w-1][h-1].m &= ~east;


for (int r = 0; r < h; r++) {
for (int r = 0; r < h; r++) {
Line 116: Line 116:
auto vert = appender("");
auto vert = appender("");
for (int c; c < w; c++) {
for (int c; c < w; c++) {
if (maze[r][c].m & north) {
if (maze[c][r].m & north) {
if (c == w - 1) hori.put("+---+"); else hori.put("+---");
if (c == w - 1) hori.put("+---+"); else hori.put("+---");
} else {
} else {
if (c == w - 1) hori.put("+ +"); else hori.put("+ ");
if (c == w - 1) hori.put("+ +"); else hori.put("+ ");
}
}
if (maze[r][c].m & east) {
if (maze[c][r].m & east) {
if (c == 0) vert.put("| |"); else vert.put(" |");
if (c == 0) vert.put("| |"); else vert.put(" |");
} else {
} else {