[MWForum]Re: Random maze

Mike Sandy mwforum@lists.mathcats.com
Mon, 2 Dec 2002 15:22:20 -0000


Daniel's maze reminded me that one can be
generated using truchet tiles.

to block :d :n ;d is tile length, n is the number of tiles per side
 cg ht pu
 let[xc  :d * :n / -2
     yc  :d * :n / -2]
 setpos list :xc :yc
 dotimes 
   [i :n]
   [dotimes 
     [j :n]
     [tile :d random 2
      setpos list :xc + (:j + 1) * :d ycor
     ]
    setpos list :xc :yc + (:i + 1) * :d
   ] 
end

to tile :d :k
 let[xc xcor yc ycor
     d  :d / 2
     k 1 - :k * 2]
 setpos list  :xc + :k * :d :yc - :d
 pd setpos list  :xc - :k * :d :yc + :d
 pu setpos list :xc :yc
end


Try block 10 35

You can add sliders for :d and :n values

I've generated the tiles in the program but they could
be  present as shapes.

Truchet tiles can be used for producinging a great many
patterns. 
Visit:
http://www.counton.org/explorer/morphing/04truchet.shtml

There are lots of other ideas at the site.
Mike