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]

To: <MWcybercourse@xxxxxxxxxxxxxxx>
Subject: RE: Mosquito or no-see-em?
From: "mike sandy" <mjsandy@xxxx>
Date: Wed, 12 Sep 2001 18:08:40 +0100

In my program, mosquito_hunter.mw2, the following piece of code controlled
the fluctuations - a simple switch of direction, decreasing with the proximity
of the prey.

make "d distance "t2
if :d > :dmax[make "dmax :d]
lt :d / :dmax * 80 * (-1 + 2 * random 2) ; ;:k
fd random 10 towards "t2

But as Gary McCallister said, a large number of factors could affect the 
flight path.
These might lead to movement, at times, away from the prey.
One way of allowing for this is the following code:

make "d distance "t2
if :d > :dmax[make "dmax :d]
make "f :d / :dmax
lt (power :f :n) * (-1*:angle + random 2 * :angle) 
fd random 10

If :n, in (power :f :n), is greater than 1 then the rate of decrease in 
increases with :n; the reverse is true for 1 / :n.

:angle < or = to 180. 

The distance travelled by "fd random 10" can be changed, but if much larger 
values are used
the mosquito can go right through the barrier before TOUCHING? is called.


Attachment: mosquito_hunter1.mw2
Description: Binary data

  • Previous by thread: Re: RE: Mosquito or no-see-em?
  • Next by thread: Re: RE: Mosquito or no-see-em?

  • 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