Tmw2.0 Englishprojectsize[744 426]turtles-have[]globals[]globals-list[globals-vars]shapesw[12 ||]_ 1F[p{{ZZ5B5{{{V=BV1c9g1s!!ssNBBsNJ)9g9gJ){o{oRJRJ)%{o{o)%9g119gBZZB!![13 ||]  &5DU^hy1c9g{B1{{!{BRJBk-9g{Zcck-{o!{o1=s!=sJ[14 ||] 2#<O`jtzc9!5Z=J)Zk B!Z{sB{o{os=9BRJs5sNJ)Zk{{k-ZkZsRJRJcJ){o!sk-sN =!Z{Zk1)%{{1)%sR11R{[28 check_off]  "-8CNYdoBB!YkB!YkB!YkB!YkB!YkB!YkB!YkB!YkB!YkB!YkBYk[29 check_on]  &6J`pBB!YkB!YkB!YkB!YkB!YkB!YkB!YkB!YkB!YkB!YkBYkprocedurestext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\fmodern\fprq1 Courier New;}{\f5\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red0\green0\blue128;\red0\green128\blue128;} \deflang1033\pard\plain\f4\fs20\cf2 ; Purpose: To play with drawing triangles. \par ; Copyright \plain\lang3081\f4\fs20\cf2 \'a9\plain\f4\fs20\cf2 2004 by Rupert Russell \par ; e-mail: r.russell@ballarat.edu.au \par ; URL: http://velorum.ballarat.edu.au/~rrussell/microworlds/ \par ; Created: September 4, 2004\plain\f4\fs20\cf1 \par \plain\f4\fs20\cf2 ; \par ; This program is free software; you can redistribute it and/or modify \par ; it under the terms of the GNU General Public License as published by \par ; the Free Software Foundation; either version 2 of the License, or \par ; (at your option) any later version. \par ; \par ; This program is distributed in the hope that it will be useful, \par ; but WITHOUT ANY WARRANTY; without even the implied warranty of \par ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \par ; GNU General Public License for more details. \par ; \par ; You should have received a copy of the GNU General Public License \par ; along with this program; if not, write to the Free Software \par ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. \par ; ---------------------------------------------------------------------\plain\f4\fs20\cf0 \par \plain\f4\fs20\b \par to startup \par \plain\f4\fs20\cf2 ; startup is a special procedure that is called \par ; each time you load the project. \par ; this procedure sets up the global variables used by this project\plain\f4\fs20\b \par \par \plain\f4\fs20 make "false 0\tab \plain\f4\fs20\cf2 \tab \tab ; define "false for later use\plain\f4\fs20 \par make "true 1\tab \tab \tab \plain\f4\fs20\cf2 ; define "true for later use\plain\f4\fs20\b \par \plain\f4\fs20 make "black 9\tab \tab \tab \plain\f4\fs20\cf2 ; define "black as the colour 9\plain\f4\fs20 \par \par \plain\f4\fs20\cf2 ; set the checkbox turtles to their default states\plain\f4\fs20 \par talkto "turtle_colour_check_box \par make "draw_in_colour :false \par setsh "check_off \par \par talkto "turtle_manual_check_box \par make "manual :false \par setsh "check_off \par \par everyone [st] \par \par \plain\f4\fs20\b end \par \par to go \par \plain\f4\fs20 \plain\f4\fs20\cf2 ; call the move_turtles procedure to randomly set \par ; the position of each turtle\plain\f4\fs20 \plain\f4\fs20\cf2 only if manual is not checked \par \plain\f4\fs20 if :manual = :false [move_turtles] \par \par \plain\f4\fs20\cf2 ; if the colour check box is ticked then pick a random colour \par ; otherwise set the colour to black. \par \plain\f4\fs20 ifelse :draw_in_colour = :true \par [ \par \plain\f4\fs20\cf2 ; chose a different random colour for each side of the triangle\plain\f4\fs20 \par make "colour_to_draw_a (random 100) \par make "colour_to_draw_b (random 100) \par make "colour_to_draw_c (random 100) \par ] \par [ \par \plain\f4\fs20\cf2 ; set each side of the triangle to black\plain\f4\fs20 \par make "colour_to_draw_a :black \par make "colour_to_draw_b :black \par make "colour_to_draw_c :black \par ] \par \par repeat 1000 [\plain\f4\fs20\cf2 \par \tab ; if "turtle_A "touches turtle_B stop drawing otherwise \par ; move each turtle and draw another triangle between them \par ; repeat up to 1000 times \par \plain\f4\fs20 \par ifelse touching? "turtle_A "turtle_B \par [ \par stop \plain\f4\fs20\cf2 \tab \tab ; stops drawing if "turtle_A & B touch\plain\f4\fs20 \par ]\tab \par [ \par talkto "turtle_A \par setc :colour_to_draw_a \par pu \par rt 2 \par fd 2 \par \par talkto "turtle_B \par setc :colour_to_draw_b \par pu \par rt 2 \par fd 2 \par \par talkto "turtle_C \par setc :colour_to_draw_c \par pu \par rt 2 \par fd 2 \par \par draw_triangle \par ] \tab \tab \tab \plain\f4\fs20\cf2 \tab ; end of ifelse\plain\f4\fs20 \par ]\tab \tab \tab \tab \tab \plain\f4\fs20\cf2 ; end of repeat 1000 \plain\f4\fs20 \par \plain\f4\fs20\b end \par \par to move_turtles \par \plain\f4\fs20\cf2 ; move each turtle to a random position on the screen\plain\f4\fs20 \par \par \plain\f4\fs20\cf2 ; find out how large the project is\plain\f4\fs20 \par make "max_x first projectsize \par make "max_y last projectsize \par \par \plain\f4\fs20\cf2 ; move "turtle_A to a random position \plain\f4\fs20 \par make "new_x random :max_x\tab \plain\f4\fs20\cf2 \tab ; get the new random x position\plain\f4\fs20 \par make "new_y random :max_y\tab \plain\f4\fs20\cf2 \tab ; get the new random y position\plain\f4\fs20 \par talkto "turtle_A \par setx :new_x \par sety :new_y \par \par \plain\f4\fs20\cf2 ; move "turtle_B to a random position\plain\f4\fs20 \par make "new_x random :max_x\tab \plain\f4\fs20\cf2 \tab ; get the new random x position \par \plain\f4\fs20 make "new_y random :max_y\tab \plain\f4\fs20\cf2 \tab ; get the new random y position\plain\f4\fs20 \par talkto "turtle_B \par setx :new_x \par sety :new_y \par \par \plain\f4\fs20\cf2 ; move "turtle_C to a random position\plain\f4\fs20 \par make "new_x random :max_x\tab \plain\f4\fs20\cf2 \tab ; get the new random x position\plain\f4\fs20 \par make "new_y random :max_y\tab \plain\f4\fs20\cf2 \tab ; get the new random y position\plain\f4\fs20 \par talkto "turtle_C \par setx :new_x \par sety :new_y \par \plain\f4\fs20\b end \par \par to check_box_colour_clicked \par \plain\f4\fs20 talkto "turtle_colour_check_box \par \par \plain\f4\fs20\cf2 ; toggle the state of the checkbox\plain\f4\fs20 \par \plain\f4\fs20\b \plain\f4\fs20 ifelse :draw_in_colour = :false\plain\f4\fs20\b \par \plain\f4\fs20 [ \par \plain\f4\fs20\cf2 ; check the box\plain\f4\fs20 \par make "draw_in_colour :true \par setsh "check_on \par ] \par [ \par \plain\f4\fs20\cf2 ; uncheck the box\plain\f4\fs20 \par make "draw_in_colour :false \par setsh "check_off \par ] \par \plain\f4\fs20\b end \par \par \par to check_box_manual_clicked \par \plain\f4\fs20 \par talkto "turtle_manual_check_box \par \plain\f4\fs20\b \plain\f4\fs20 ifelse :manual = :false\plain\f4\fs20\b \par \plain\f4\fs20 [ \par \plain\f4\fs20\cf2 ;check the box\plain\f4\fs20 \par make "manual :true \par setsh "check_on \par show [move turtles by hand] \par ] \par [ \par \plain\f4\fs20\cf2 ; uncheck the check box\plain\f4\fs20 \par make "manual :false \par setsh "check_off \par cc \par ] \par \plain\f4\fs20\b end \par \par to draw_triangle\plain\f4\fs20 \par \par \plain\f4\fs20\cf2 ; draws a triangle between the 3 turtles\plain\f4\fs20 \par \par talkto "turtle_A \par towards "turtle_B\tab \plain\f4\fs20\cf2 \tab ; turn "turtle_A towards "turtle_B\plain\f4\fs20 \par pd \par make "dist distance "turtle_B \par fd :dist \par bk :dist \par pu \par \par talkto "turtle_B \par towards "turtle_C \par pd \par make "dist distance "turtle_C \par fd :dist \par bk :dist \par pu \par \par talkto "turtle_C \par towards "turtle_A \par pd \par make "dist distance "turtle_A \par fd :dist \par bk :dist \par pu \par \par \plain\f4\fs20\b end\plain\f4\fs20 \par } @/pagenamepage1%curturtleturtle_manual_check_boxcurtexttext2transition0Dturtle-deamons[[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []]Cmouse-deamons[[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []]bg0$buffer$$6HZl~ 2DVhz .@Rdv*<N`r&8J\n"4FXj| 0BTfx,>Pbt(:L^p  $ 6 H Z l ~  2 D V h z  . @ R d v   * < N ` r   & 8 J \ n "4FXj| 0BTfx,>Pbt(:L^p$6HZl~ 2DVhz .@Rdv*<N`r&8J\n"4FXj| 0BTfx,>Pbt(:L^p$6HZl~ 2DVhz .@Rdvobject typetnameturtle_Alocked?false xpos264 ypos171 shape13penstate0 size40pencolor0heading92 pensize1shown?true fcn[go] kind1shapein13have-list[has] colorin9object typetnameturtle_Blocked?false xpos375 ypos144 shape14penstate0 size40pencolor0heading273 pensize1shown?true fcn[go] kind1shapein14have-list[has] colorin9object typetnameturtle_Clocked?false xpos361 ypos232 shape15penstate0 size40pencolor0heading271 pensize1shown?true fcn[go] kind1shapein15have-list[has] colorin9objecttypebuttonnamebutton2rect[71 397 60 25]show-name?falselocked?falsefcn[clean] kind1object typetextnametext1rect[196 393 139 25]show-name?falselocked?falsevisible?truesnaped?falseNtext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\fmodern\fprq1 Courier New;}{\f5\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red0\green0\blue128;\red0\green128\blue128;} \deflang1033\pard\plain\f5\fs20 Draw in colour \par } object typet nameturtle_colour_check_boxlocked?false xpos188 ypos410 shape29penstate0 size40pencolor0 heading0 pensize1shown?true"fcn[check_box_colour_clicked] kind1shapeincheck_offhave-list[has] colorin9object typet nameturtle_manual_check_boxlocked?false xpos356 ypos409 shape29penstate0 size40pencolor0 heading0 pensize1shown?true"fcn[check_box_manual_clicked] kind1shapeincheck_offhave-list[has] colorin9object typetextnametext2rect[369 392 92 28]show-name?falselocked?falsevisible?truesnaped?falseFtext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\fmodern\fprq1 Courier New;}{\f5\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red0\green0\blue128;\red0\green128\blue128;} \deflang1033\pard\plain\f5\fs20 Manual \par } {objecttypebuttonnamebutton1rect[4 398 60 25]show-name?falselocked?false fcn[go] kind1