Maze generation: Difference between revisions
Content added Content deleted
(→{{header|Julia}}: updated to julia v0.6) |
|||
Line 3,684: | Line 3,684: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
The following code is for julia version >= 0.6. |
|||
String API has changed in julia versions > 0.4. One must import the library LegacyStrings for the following code to work. |
|||
<lang julia>function walk(maze, cell, visited = Any[]) |
<lang julia>function walk(maze, cell, visited = Any[]) |
||
Line 3,690: | Line 3,690: | ||
for neigh in shuffle(neighbors(cell, size(maze))) |
for neigh in shuffle(neighbors(cell, size(maze))) |
||
if !(neigh in visited) |
if !(neigh in visited) |
||
maze[round(Int,(cell+neigh)/2)...] = 0 |
maze[round.(Int,(cell+neigh)/2)...] = 0 |
||
walk(maze, neigh, visited) |
walk(maze, neigh, visited) |
||
end |
end |
||
Line 3,705: | Line 3,705: | ||
pprint(matrix) = for i = 1:size(matrix,1) println(join(matrix[i,:])) end |
pprint(matrix) = for i = 1:size(matrix,1) println(join(matrix[i,:])) end |
||
function printmaze(maze, wall = |
function printmaze(maze, wall = split("╹ ╸ ┛ ╺ ┗ ━ ┻ ╻ ┃ ┓ ┫ ┏ ┣ ┳ ╋")) |
||
h,w = size(maze) |
h,w = size(maze) |
||
pprint([ maze[i,j] == 0 ? ' ' : |
pprint([ maze[i,j] == 0 ? ' ' : |