Random Pseudo-maze

Add a 2D node to the graph (I used Square).
Edit the parameters as:

  1. span float
  2. gridcels int

Replace the node’s logic with the following turtle script:

let cel span/gridcels

loop gridcels Xcel
loop gridcels Ycel

if round(rnd(1)) EQ 1
mov cel*Xcel cel*Ycel 0
fwd cel
endif

if round(rnd(1)) EQ 1
mov cel*Xcel celY*cel 90
fwd cel
endif

endloop
endloop

Create a local variable: cel = span divided by gridcels

open a nested loop with 2 counters: Xcel and Ycel
(the counters +1 each time through the loop)

50% random chance:
– move the turtle using the loop’s Xcel and Ycel count
– draw a horizontal line, 1 cel length

50% random chance:
– move the turtle using the loop’s Xcel and Ycel count
– draw a vertical line, 1 cel length

repeat the nested loops until done

Output Shape must be OPEN

Comments are closed.