[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> multi-turtle simulationn



;hello Jim Muller
;Of course when you try to draw many shapes simultaneously this is
;generally speaking implies some sort of multiple-turtle simulation.
;however there is two approches :-
; 1- to use a general purpose program to simulate multi-turtles like 
; the one that was posted on the list some time ago,which you also
; can find with "lady bug" for drawing the simultaneous shapes.
; 2- to proceed directly and draw the shapes, taking care of the 
; turtle position yourself befor jumping from one shape to the 
; other. as was shown by my last message.
;
;So although the general multi-turtle simulation program is more
;elegant, students can't catch the logic behind it.
;While if they try to do the job directly they will never forget the
;idea behind it. the code for doing this is straight forward and 
;simple. Simply this was the idea which I tried to phrase.
;
;
;here is the code written using the general multi-turtle simulation program
;to do the same job.    
;Best Regards.
;Mhelhefny
;---------------------------------------------------
TO ASK :TNUM :COMMAND.LIST
IF :TNUM = 0 [ZERO :COMMAND.LIST]
IF :TNUM = 1 [ONE :COMMAND.LIST]
IF :TNUM = 2 [TWO :COMMAND.LIST]
IF :TNUM = 3 [THREE :COMMAND.LIST]
END


to go
cs ht set.zero set.one set.two set.three
ask 0 [pu setxy 230 120 pd ]
ask 1 [pu setxy -230 120 pd]
ask 2 [pu setxy -230 -110 pd]
ask 3 [pu setxy 230 -110 pd]
turtles.four 100 8
end

TO ONE  :COMMAND.LIST
SETXY :OLDX1 :OLDY1 SETH :OLDH1
PD RUN :COMMAND.LIST PU
MAKE "OLDX1 XCOR
MAKE "OLDY1 YCOR
MAKE "OLDH1 HEADING
END

TO SET.ONE  
MAKE "OLDX1 XCOR
MAKE "OLDY1 YCOR
MAKE "OLDH1 HEADING
END

TO SET.THREE  
MAKE "OLDX3 XCOR
MAKE "OLDY3 YCOR
MAKE "OLDH3 HEADING
END

TO SET.TWO  
MAKE "OLDX2 XCOR
MAKE "OLDY2 YCOR
MAKE "OLDH2 HEADING
END

TO SET.ZERO  
MAKE "OLDX0 XCOR
MAKE "OLDY0 YCOR
MAKE "OLDH0 HEADING
END

TO THREE  :COMMAND.LIST
SETXY :OLDX3 :OLDY3 SETH :OLDH3
PD RUN :COMMAND.LIST PU
MAKE "OLDX3 XCOR
MAKE "OLDY3 YCOR
MAKE "OLDH3 HEADING
END

TO TURTLES.FOUR :N :SIZE
if :size > :n [stop]
ask 0 [setpc 3 rt 71 fd :size]
ask 1 [setpc 4 rt 122 fd :size*1.8]
ask 2 [setpc 5 rt 89 fd :size*1.2]
ask 3 [setpc 6 rt 52.9 fd :size*.8]
TURTLES.FOUR :N :SIZE + 1
END

TO TWO  :COMMAND.LIST
SETXY :OLDX2 :OLDY2 SETH :OLDH2
PD RUN :COMMAND.LIST PU
MAKE "OLDX2 XCOR
MAKE "OLDY2 YCOR
MAKE "OLDH2 HEADING
END

TO ZERO  :COMMAND.LIST
SETXY :OLDX0 :OLDY0 SETH :OLDH0
PD RUN :COMMAND.LIST PU
MAKE "OLDX0 XCOR
MAKE "OLDY0 YCOR
MAKE "OLDH0 HEADING
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