Alice Community How to make a robot pick up 19 rocks in order of the nearest to the robot.

 How to make a robot pick up 19 rocks in order of the nearest to the robot.
hydude777
Member

Status: Offline
Posts: 25
Join Date: Apr 2011
How to make a robot pick up 19 rocks in order of the nearest to the robot. - 02-23-2012, 08: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
 robot pick up rock.a2w (4.30 MB, 12 views)

 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 02-23-2012, 10: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".
 hydude777 Member   Status: Offline Posts: 25 Join Date: Apr 2011 02-23-2012, 03:20 PM Thank you Mr.K for helping me all the time I post questions, you've been a great help! Thanks very much!

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge