Alice Community  

Go Back   Alice Community > Alice 2 > Bugs and Troubleshooting

Reply
 
Thread Tools Display Modes
Problem with "move toward" in conjunction with "distance to"
Old
Tasha
Guest
 
Status:
Posts: n/a
Default Problem with "move toward" in conjunction with "distance to" - 06-06-2008, 05:24 PM

In attempting to do all of the problems I'm assigning to students this summer, I encountered the following problem.

1. Add a dragon and a blimp to the world.
2. Turn the dragon to face the blimp.
3. Move the dragon toward the blimp, the distance between the dragon and blimp.

The problem occurs in step 3. If the amount to move is blimp->distance to dragon, the results are as expected. However, if the amount to move is dragon->distance to blimp, the dragon moves through and past the blimp, such that he ends up about as far away as he started (just on the opposite side of the blimp). It seems that the order in which the objects are presented to the "distance to" function affects the result.

Have I misinterpreted how "move toward" or "distance to" is supposed to work? It would be nice to be able to explain to students why this discrepancy occurs or to confirm this is a bug.

I've attached the problematic code, which includes comments about the starting and ending coordinates of the blimp and the dragon for both cases. I have not yet tested to see whether all objects behave this way, or if it is just the dragon and the blimp.
Attached Files
File Type: a2w BuggyWorld.a2w (1.70 MB, 154 views)
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 06-06-2008, 07:51 PM

Quote:
Originally Posted by Tasha View Post
In attempting to do all of the problems I'm assigning to students this summer, I encountered the following problem.

1. Add a dragon and a blimp to the world.
2. Turn the dragon to face the blimp.
3. Move the dragon toward the blimp, the distance between the dragon and blimp.

The problem occurs in step 3. If the amount to move is blimp->distance to dragon, the results are as expected. However, if the amount to move is dragon->distance to blimp, the dragon moves through and past the blimp, such that he ends up about as far away as he started (just on the opposite side of the blimp). It seems that the order in which the objects are presented to the "distance to" function affects the result.

Have I misinterpreted how "move toward" or "distance to" is supposed to work? It would be nice to be able to explain to students why this discrepancy occurs or to confirm this is a bug.

I've attached the problematic code, which includes comments about the starting and ending coordinates of the blimp and the dragon for both cases. I have not yet tested to see whether all objects behave this way, or if it is just the dragon and the blimp.
Try it with another object in place of the blimp. I did a quick test with the cow in place of the blimp and the problem seemed to go away.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free Scratch tutorials: http://www.dickbaldwin.com/tocHomeSchool.htm
Free Java/C#, etc. tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
Tasha
Guest
 
Status:
Posts: n/a
Default 06-06-2008, 08:47 PM

Quote:
Originally Posted by DickBaldwin View Post
Try it with another object in place of the blimp. I did a quick test with the cow in place of the blimp and the problem seemed to go away.
I tried this again with the dragon and the biplane; everything worked as expected. Then I tried it with the blimp and the biplane and encountered the same error described before. I guess there's a bug while using the blimp. At least now I know one problem students might encounter!
   
Reply With Quote
Old
groucho
Guest
 
Status:
Posts: n/a
Default 06-07-2008, 06:39 AM

The problem may be connected with the initial positioning of the blimp out of the gallery.

When I align the blimp first with ground (or world) and then move it to its desired position , I get consistent results for <otherobject>.distanceTo(blimp) and blimp.distanceTo(<otherobject>) afterwards. Possibly, the alignment step corrects an error introduced by the automatic positioning of the blimp out of the gallery.

It might thus be a good idea to always start with new objects by aligning them to ground, either manually or in a "setTheStage" method as advocated by Dick in his tutorials.
   
Reply With Quote
SImple solution
Old
Mergancyr
Guest
 
Status:
Posts: n/a
Default SImple solution - 12-15-2008, 05:31 PM

Presumably a simple solution would be to use a quick formula like

Distance to X ( minus ( 1/2 X's width + 1/2 object that's moving's width ))

~Merg~
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.