; Maze for Mswlogo ; I think its educational ; It tought me a little more backtracking :) ; I think is very eye-catching. ; --------------------------- to ini :tam ;maze size make "maxt power :tam 2 make "m mdarray list :tam :tam make "l 10 for (list "i 1 :tam) [ for (list "j 1 :tam) [ mdsetitem list :i :j :m "false ]] show :m make "t 0 ht setfloodcolor [0 0 0] fill st setpencolor [255 255 255] setpensize [8 8] maze 1 1 [[1 0][-1 0][0 1]] [0 -1] mdsetitem [1 1] :m "true end to less :a :b if emptyp :b [op []] op ifelse :a=first :b [butfirst :b] [fput first :b less :a butfirst :b] end to maze :rx :ry :c :lst if :t=:maxt [stop] repeat 3 [ make "k pick :c move :rx :ry :k make "c less :k :c ] move :rx :ry :lst end to move :rx :ry :d make "px :rx + first :d make "py :ry + last :d if or :px>:tam :py>:tam [stop] if or :px<1 :py<1 [stop] if (mditem list :px :py :m) = "false [ mdsetitem list :px :py :m "true pu setpos list :l*:rx :l*:ry pd setpos list :l*:px :l*:py make "t :t+1 maze :px :py (less :d [[1 0][-1 0][0 1][0 -1]]) :d ] end --------------------------------------------------------------- Please post messages to the Logo forum to logo-l@gsn.org. Mail questions about the list administration to logofdn@gsn.org. To unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home