Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15165
| From | Sarah Brent <sbrent.physics@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | maze generation |
| Date | 2013-07-12 06:29 +0000 |
| Message-ID | <kro7nk$f17$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
Hello All,
I am trying to get out an array of all the deleted walls from this maze generation code. Can't seem to make it work, when I ask it to print it will only give me the entire maze grid, and not the specific walls I'm asking for.
MazeGen2[m_, n_] :=
Block[{$RecursionLimit = Infinity,
unvisited = Tuples[Range /@ {m, n}], maze, mazearray = {},
mazeA},
(*unvisited=Delete[unvisited,{{1},{2},{Length[
unvisited]-1},{Length[unvisited]}}];*)
(*Print[unvisited];*)
maze = {{{{#, # - {0, 1}}, {#, # - {1, 0}}}} & /@
unvisited, {{{0, n - 1}, {0, 0}, {m - 1,
0}}}};(*This generates the grid*)
Print[maze];
{unvisited = DeleteCases[unvisited, #];
(*Print[unvisited];*)
Do[
If[MemberQ[unvisited, neighbor],
maze = DeleteCases[
maze, {#, neighbor - {1, 1}} | {neighbor, # - {1, 1}}, {5}]
(*mazeA=Flatten[AppendTo[mazearray,
maze]];*)
; #0@neighbor],
{neighbor,
RandomSample@{# + {0, 1}, # - {0, 1}, # + {1, 0}, # - {1,
0}}}
]
} &@RandomChoice@unvisited;
Flatten[maze]
];
Thanks!
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
maze generation Sarah Brent <sbrent.physics@gmail.com> - 2013-07-12 06:29 +0000
csiph-web