Maze generation: Difference between revisions

Content added Content deleted
m (→‎{{header|Chapel}}: Use if-expressions rather than statements when displaying maze.)
m (→‎{{header|Chapel}}: Allow parameters for maze size in Chapel)
Line 2,154: Line 2,154:
<syntaxhighlight lang="chapel">
<syntaxhighlight lang="chapel">
use Random;
use Random;

config const rows: int = 9;
config const cols: int = 16;
if rows < 1 || cols < 1 {
writeln("Maze must be at least 1x1 in size.");
exit(1);
}


enum direction {N = 1, E = 2, S = 3, W = 4};
enum direction {N = 1, E = 2, S = 3, W = 4};
Line 2,169: Line 2,176:
];
];


var maze: [1..9, 1..16] Cell;
var maze: [1..rows, 1..cols] Cell;
var startingCell = (choose(maze.dim(0)), choose(maze.dim(1)));
var startingCell = (choose(maze.dim(0)), choose(maze.dim(1)));