[Thread Prev] <
On 20 Nov 2007 at 3:35, askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx wrote:
> from: David Burke <burkd1@xxxxxxxxx>
> date: Tue Nov 20 03:35:08 2007
> platform: Mac OS10
> version: MicroWorlds Ex
>
> I have a game where my students have to navigate a polygon
> maze to win. I want to check if there turtle is within a
> specified distance of the target. I want their xcor, ycor
> and heading to be within 0.25, or any other chosen
> precision. I was trying to get the ABS command to work for
> this with no luck. Here is what I was trying:
>
> ifelse abs 150 - xcor < 0.25 [pr [yes]] [pr [no]]
>
this is understood by MW as follows:
ifelse (abs ((150 - xcor) < 0.25)) [pr [yes]] [pr [no]]
you want:
ifelse 0.25 > abs 150 - xcor [pr [yes]] [pr [no]]
because MW understands this as follows:
ifelse (0.25 > (abs (150 - xcor))) [pr [yes]] [pr [no]]
There *is* a primitive called "distance" you might want to
check it out.
Daniel
OpenWorld Learning
Previous by thread:
RE: MIA, Ask an Expert: abs xcor ycor and heading
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.
|