[MWForum]How to slow down a turtle/car travelling around a road network
Mike Sandy
mwforum@lists.mathcats.com
Thu, 2 Oct 2003 14:18:57 +0100
The final turtle position with GLIDE# as below is slightly out from
that expected, due to rounding errors, but I doubt for most uses it would
be noticeable.
The accurate version is:
to glide# :dist :speed
let[f int 100 / :speed]
repeat :dist * :f
[fd 1 / :f ]
end
> Do you know how Graham would get to stop the turtle (or car) when
>it hits one of the hidden turtles. Would you use 'when' and 'touching'
>and some sort of stop command?
First thoughts:
Touching? won't work with a "hidden" (in the sense of HIDETURTLE) turtle,
so the turtle shape would have to be showing and thus part of the
"background".
If I understand you, the moving turtle will have to detect collision with
any of the stationary
turtles so you could use:
to touching-any? :who :tlist
if empty? :tlist[op "false]
if touching? :who first :tlist [op "true]
op touching-any? :who bf :tlist
end
:who - the moving turtle
:tlist - list of stationary turtles
if :who = "t1 and :tlist = [t2 t3 t4]
GLIDE# would become
to glide# :dist :speed
let[f int 100 / :speed]
repeat :dist * :f
[fd 1 / :f
if touching-any? "t1 [t2 t3 t4]
[stop]]
end
For t1 to move on, the touched turtle would first have to be hidden (ht).
Alternatively, the moving turtle could go from hidden turtle to hidden
turtle using DISTANCE and TOWARDS.
Hope this helps.
Mike
----- Original Message -----
From: "Tony Wilson" <twilson@hestalbs.melb.catholic.edu.au>
To: <mwforum@lists.mathcats.com>
Sent: Thursday, October 02, 2003 12:44 PM
Subject: Re: [MWForum]How to slow down a turtle/car travelling around a road
network
> That is a nice formulae you have there, Mike. I will start using it.
> Do you know how Graham would get to stop the turtle (or car) when it hits
one of the hidden turtles. Would you use 'when' and 'touching' and some sort
of stop command?
> Tony
> "Mike Sandy" <mjsandy@btopenworld.com> on Thu, 2 Oct 2003 11:43:10 +0100
wrote:
> > Try:
> >
> > to glide# :dist :speed
> > repeat :dist / :speed * 100
> > [fd .01 * :speed]
> > end
> >
> > :speed 1 to 10
> >
> > Mike