Hi Turtlers,
Here a "maze" program, which I wrote to test MSWLogo's PIXEL function.
PIXEL reports the color under the turtle.
The turtle begins in the center a randomly-generated maze, and tries to
find its way out. The maze is surrounded by a red "fence", which is no
problem for the turtle to cross to freedom.
After several trials and errors, the turtle eventually finds a way out.
Just to prove that patience pays...
=========================================
to main
cs ht
setpc[255 0 0] square
setpc[0 0 0] maze
pu setxy -5 -5 st
setpc[255 0 0] move
end
to square ; red fence
pu setxy -105 -105 pd
repeat 4[fd 210 rt 90]
end
to maze
for[x -90 90 15][
for[y -90 90 15][
pu setxy :x :y pd
seth 90*random 4
fd 15]] ; maze walls
end
to move ; in PENUP mode
if or (abs xcor)>115 (abs ycor)>115[stop]
if pixel=[0 0 0][bk 8 rt -180+random 360]
fd 1 wait 1 ; move step-by-step
move ; iterate
end
=========================================
Berkeley Logos have no equivalent for PIXEL, so my program will not run
in UCBLogo.
Enjoy,
[[Yehuda]]
---------------------------------------------------------------
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