This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ruben654's profile picture

Maze digger program

Started by ruben654, 16 November 2012 - 04:16 AM
ruben654 #1
Posted 16 November 2012 - 05:16 AM
I created a program that builds mazes. The mazes can be any size and are completely pseudo-random.

The program is very easy to use:
You place the turtle in the ground and run the program like this:

programname <width> <length>
You can get the code here: http://pastebin.com/a4Bxy9cQ
Please note I didn't prevent the turtle from messing up when it gets blocked by any mob or player, so keep those away from the turtle.
jag #2
Posted 16 November 2012 - 05:27 AM
So what happens if I do
maze 1 100
And shouldn't it be
maze <width> <lenght>
Instead of
maze <width> <height>
ruben654 #3
Posted 16 November 2012 - 05:40 AM
If you do maze 1 100 it'll make one straight line, and you're right about the <length> thing thanks
Sebra #4
Posted 20 November 2012 - 03:56 AM
Nice!
It seems you can easily add height 1-3 as third argument and blocking protection (attack once a second if unable to move).
BigSHinyToys #5
Posted 20 November 2012 - 05:36 AM
This is cool but it seams to make a maze twice the size I ask for.
I can't fault the results thought this looks very nice next to my house.
Hoovkid #6
Posted 30 November 2012 - 12:00 PM
when i ran this program, this was the resulting 'maze'. any help?
it was running well but then received this error,


0bios:40: vm error: java.lang.ArrayIndexOutOfBoundsExeption: 256
ChunLing #7
Posted 30 November 2012 - 12:10 PM
I'm thinking that means that there was a problem with the lua implementation in the version of ComputerCraft you're running. Or maybe just the instance.
Norrellite #8
Posted 01 December 2012 - 06:38 AM
The reason that it gives mazes that are twice the dimensions asked for is because it moves two blocks for each "turn". This gives a nice 1 block wall around each passageway, but it also doubles the size. I had the same problem in a maze program that I wrote. I consider the dimensions to be in "nodes" instead of block but you could probably make the values <width> and <height> equal to half the value of tonumber(tArgs[1]) and [2] if it really bothers you.

Ugh, thinking about this, it would probably be somewhat complicated to keep to integers. Something like width = math.floor(0.5 * tonumber(tArgs[1]) should work. You want to do math.floor to round down so it fits within the parameters asked for. This should give something like a 6 x 6 "node" maze if you give it a <width> and <height> of 13. I hope that syntax works, I'll try it out later.