Project Folders
Teacher Resources
Student Resources
How Do I?
Site Map
Our Team

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

[Thread Prev] [Thread Next]

Subject: Help with Conditionals
From: mwforum@xxxxxxxxxxxxxxxxxx (Mike Sandy)
Date: Fri, 21 May 2004 19:43:16 +0100

> I am in a real bind.  I have introduced the conditional "if" to my 8th
> grade class.  We have a BIG integration product due by Thursday for a
> Science/Tech Fair. The students are simulating their experience of
> testing the velocity of water using oranges in a river. The orange
> should stop either when it hits the rope or the girl shape.
> Okay, here is the problem.
> We wrote a procedure that that says 
> If touching? "orange1 "t2 [stop announce [.486 m/s]]

Others have offered various solutions, but though too late
for the deadline, the following may be of future use.

A alternative approach to this project
instead of writing a CHECK procedure for each turtle
write one which will deal with all cases.
This also saves writing an instruction for
each turtle.
The initial program involved FOREVER for which
the requires STOPALL or CANCEL[...] to stop it.
A more controllable method is to define
an equivalent FOREVER:
For turtle "t1

to move.oranges
 if touching? "t1 "t11
 fd speed
 move.oranges ;REPEATS AT THIS STAGE

How can this be made to apply generally?
The currently active turtle is given by the
value of the variable WHO (In the commander try: show who)
So the number of the turtle is given by BF WHO
The number of the target turtle is 10 larger,
so the target turtle is: word "t 10 + bf who
to move.oranges
 if touching? who word "t 10 + bf who
 fd speed

How to get the turtles moving independently?

ask[t1 t2 t3 t4 t5][move.turtles]
would move t1 then t2  &c.


ask[t1 t2 t3 t4 t5][launch[move.turtles]]

starts them all together(well almost).
MW HELP states that LAUNCH needs STOPALL &c.
for stopping, but NOT IN THIS CASE. 
Check the processes tab.

The so-called independent processes are not independent.
If you watch the speed of the slowest turtle, when the others
have stopped, the slowest turtle speeds up!


Attachment: River_project2_m.mw2
Description: Binary data

  • Previous by thread: Help with Conditionals
  • Next by thread: Book Recommendation

  • 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