Alice Community How do I move a hole randomly within a boundry

 How do I move a hole randomly within a boundry
 brunkdaddy Guest   Status: Posts: n/a How do I move a hole randomly within a boundry - 05-06-2010, 01:25 AM Hi Guys, I have forum surfed this issue for hours now and I can't figure it out. The issue is I have a box that a contains a hole, this hole must move randomly around inside the box (with duration 0) but can never return to the centre of the box (where it started). My Alice code looks like this atm (note: the distance from the centre of the box to each side of the box is 10m): If hole distance to centre > 10 (stuck here, but I want it to move to a random spot in the box) Else hole move left random number minimum = -10 maximum = 10 hole move forward random number minimum = -10 maximum = 10 Any help would be greatly apperciated!
 x2495iiii Super Moderator     Status: Offline Posts: 3,508 Join Date: Dec 2008 Location: Somewhere in the Continental U.S. 05-06-2010, 02:38 PM Make four number variables, leftVar, rightVar, upVar, and downVar Place four squares with their against each edge of the box, making sure to keep the square's centers touching the bottom of the box. Then you'd need a complex method that might looks something like this: rightVar set value to circle dist from right square - circle's width leftVar set value to circle dist from left square - circle's width (etc. for the other two variables) Loop infinity times: circle move right [random number [min = -leftVar] [max = rightVar] [integerOnly = false]] meters circle move up [random number [min = -downVar] [max = upVar] [integerOnly = false]] meters That should do it. (')>
 screenshot
 brunkdaddy Guest   Status: Posts: n/a screenshot - 05-07-2010, 07:39 PM Thanks for the reply, I tried to do what you said as best I could but it didn't seem to work - I have posted a link to a screenshot of the code but to help ill do a diagram too: nwPost.........................................neP ost .......................centre..................... ..... swPost.........................................seP ost the hole has to move around but not go outside the box outlined by the posts. here is the link: http://yfrog.com/20screenshot20100508at103p Cheers.

 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