Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How to make a robot pick up 19 rocks in order of the nearest to the robot.
Old
hydude777
Member
 
Status: Offline
Posts: 25
Join Date: Apr 2011
Default How to make a robot pick up 19 rocks in order of the nearest to the robot. - 02-23-2012, 07:39 AM

Suppose there are 19 rocks on the ground, separated in random positions.
A robot, starting from approximately center of the rocks, goes off to collect rocks that are NEAREST to the robot's position. After collecting all 19 rocks, the robot returns to its original place.
How would you do it??????????????????????????????????????

This is what i have currently, and it seems to be not working so well.....
Attached Files
File Type: a2w robot pick up rock.a2w (4.30 MB, 12 views)
   
Reply With Quote
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 02-23-2012, 09:37 AM

Getting into array lists?
The deal is to get every object that is picked up in one list. You've probably done that already.
The way we'd do this in Java is that we would make a for loop (In this case, a "Do All in Order") We would then set a number variable to the first index's distance away from the robot, as well as another variable with the actual index number. We would then go down the list with this loop, checking if each object in the list's distance away from the robot is less than our variable. If it is, the object's distance away and index will replace the respective variables. If it isn't, do nothing and move to the next index.

After the loop is done, we would have the robot move to the closest index of the list as found in the previous method and collect it by making it no longer show. We would then have this process repeated until all rocks are collected. This can be done with another loop, a Do All Together for efficiency, to find if all of the rocks "are Showing".
   
Reply With Quote
Old
hydude777
Member
 
Status: Offline
Posts: 25
Join Date: Apr 2011
Default 02-23-2012, 02:20 PM

Thank you Mr.K for helping me all the time I post questions,
you've been a great help!
Thanks very much!
   
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 ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.