Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: Re: problem with code FollowpathMany
From: "Daniel Ajoy" <da.ajoy@xxxxxxxxx>
Date: Sat, 12 May 2007 19:46:59 -0500
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed;

On 12 May 2007 at 13:32, zehava wizman wrote:

> Hello Forum
> I got from you a code describing how some turtles can follow      . 
> I first turtle, using recursion, and turtlesown instruction don´t . 
> I understand some of the meaning and use of them                  . 
>
> 1. what is the connection between slider tic and  :n - 1 ( if tic <
> (:n - *6

Hi,

to do.and.pass :n
if tic < (:n - 1) * 6 [stop]


when you run the startup button you notice that not all of the
turtles start moving at the same time. 

:n is the number of the turtle, so when we are talking to

t1

n - 1 * 6 = (1 - 1) * 6 = 0 * 6 = 0

so for t1, do.and.pass does not stop immediately.

For t2

n - 1 * 6 = (2 - 1) * 6 = 1 * 6 = 6

do.and.pass waits until tics = 6 before starting doing something

For t3

n - 1 * 6 = (3 - 1) * 6 = 2 * 6 = 12

do.and.pass waits until tics = 12 before starting doing something




> 2. queue is getting the names of turtles? 

No.

> If so Why I see the queue
> filled with fd 10?


the queue is filled in two places, and in both places with this
instruction:

setqueue fput :code queue



what we put in the queue is the value of "code"

we point things in "code" with these commands:

let [code [fd 10]]

let [code last queue]


if :key = 37 [ let [code [seth 270]] ]
if :key = 38 [ let [code [seth   0]] ]
if :key = 39 [ let [code [seth  90]] ]
if :key = 40 [ let [code [seth 180]] ]


we never put turtle names in the queue.


> 3 At line "let [code [fd 10]]" -   Why variable Code gets the
> command       fd 10?

Because the queue is a queue of commands, the turtles have to
run the commands in their queues. Each turtle has its own queue
of commands.


> 4. What is the meaning of the line ask "t1 [setqueue fput :code
> queue]?

ask "t1 [setqueue fput :code queue]

it means,

turtle1 put the value of the variable code as the first element
of your list "queue".

if that turtle's queue was:

[fd 10] [fd 10] [fd 10]

and the code was:

[seth 0]

then the new value of that turtle's queue is:

[seth 0] [fd 10] [fd 10] [fd 10]

then, the next command that that turtle is going to carry out
is 

[fd 10]

and after carrying it out. its queue is going to be just:

[seth 0] [fd 10] [fd 10]



Daniel
OpenWorld Learning




  • Previous by thread: problem with code FollowpathMany
  • Next by thread: stopping track time & More pages or separate projects

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008