Alice Community  

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

Reply
 
Thread Tools Display Modes
Random Direction
Old
Laur07
Junior Member
 
Status: Offline
Posts: 11
Join Date: Jun 2011
Default Random Direction - 06-11-2011, 10:32 PM

Hey, for my project i need to make my person move in a random direction, I know how to make it move a random distance but I am struggling with the direction, does anyone know how to do this ?

Thank you !
   
Reply With Quote
Old
David B
Senior Member
 
David B's Avatar
 
Status: Offline
Posts: 1,145
Join Date: Dec 2010
Location: N/A
Default 06-12-2011, 12:23 AM

Quote:
Originally Posted by Laur07 View Post
Hey, for my project i need to make my person move in a random direction, I know how to make it move a random distance but I am struggling with the direction, does anyone know how to do this ?

Thank you !
This probably isn't the best way, but it should work, and was the first idea that came to mind. What don't you have Alice select a random number, and then have an if/else method that basically says that if the random number equals this then have the person turn this direction, otherwise, have him turn this direction. You could also put an if/else loop within an if/else loop to make the randomization even more random. I hope this helps!
   
Reply With Quote
Old
TauTrumpsPi
Senior Member
 
TauTrumpsPi's Avatar
 
Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
Default 06-12-2011, 07:05 AM

Or you could use the "Choose true" function and have it "choose left" within an if/else 25% of the time, right, forward, and back. So something like this

IF choose true (25%)
Person move forward
ELSE
IF Choose true (25%)
person move left
ELSE
IF Choose true (25%)
person move backward
ELSE
person move right


--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes

Wondering about my Avatar?
http://en.wikipedia.org/wiki/Tardigrade

Wondering about my username?
http://www.youtube.com/watch?v=jG7vhMMXagQ
   
Reply With Quote
Old
David B
Senior Member
 
David B's Avatar
 
Status: Offline
Posts: 1,145
Join Date: Dec 2010
Location: N/A
Default 06-12-2011, 09:02 AM

Quote:
Originally Posted by TauTrumpsPi View Post
Or you could use the "Choose true" function and have it "choose left" within an if/else 25% of the time, right, forward, and back. So something like this

IF choose true (25%)
Person move forward
ELSE
IF Choose true (25%)
person move left
ELSE
IF Choose true (25%)
person move backward
ELSE
person move right
I didn't understand any of that, which is probably why I didn't think of it.
   
Reply With Quote
Old
ElectricKirby
Senior Member
 
ElectricKirby's Avatar
 
Status: Offline
Posts: 164
Join Date: May 2011
Location: Dreamland, Planet Popstar
Default 06-12-2011, 09:12 AM

Make a list with all six directions in it, then drag the list to wherever you need a random direction, and select random_item_from_world.nameOfList


My Favorite Resources:
Uploading Images - http://tinypic.com/

File Sharing - http://www.4shared.com/

Textures - http://www.filterforge.com/

Convertible Game-Ripped Models - http://models-resource.com/

Music - http://www.brawlcustommusic.com/gamelist
   
Reply With Quote
Old
DensetsuNoKaboom
Senior Member
 
DensetsuNoKaboom's Avatar
 
Status: Offline
Posts: 1,188
Join Date: May 2010
Location: e4eaf2
Default 06-12-2011, 11:28 AM

Quote:
Originally Posted by tautrumpspi View Post
or you could use the "choose true" function and have it "choose left" within an if/else 25% of the time, right, forward, and back. So something like this

if choose true (25%)
person move forward
else
if choose true (33.3%)
person move left
else
if choose true (50%)
person move backward
else
person move right
correctiooooooon!!!


Thank you for taking the time to read this signature. This signature loves you.
   
Reply With Quote
Old
David B
Senior Member
 
David B's Avatar
 
Status: Offline
Posts: 1,145
Join Date: Dec 2010
Location: N/A
Default 06-12-2011, 02:05 PM

Quote:
Originally Posted by DensetsuNoKaboom View Post
correctiooooooon!!!
What did you mean by that post?
   
Reply With Quote
Old
TauTrumpsPi
Senior Member
 
TauTrumpsPi's Avatar
 
Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
Default 06-12-2011, 04:04 PM

I think I get what he is trying to say.

Since this a random chance without replacement, you can't just have the first one at 25% and continue from there. After you rule out the first one, there are only 3 left, so you need the next one to be at 33%. Then 2 left, so 50%, then 1 left, 100%.

Thanks for the correction. Though I do think that ElectricKirby's idea is the easiest, now that I see it.


--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes

Wondering about my Avatar?
http://en.wikipedia.org/wiki/Tardigrade

Wondering about my username?
http://www.youtube.com/watch?v=jG7vhMMXagQ
   
Reply With Quote
Old
Laur07
Junior Member
 
Status: Offline
Posts: 11
Join Date: Jun 2011
Default 06-12-2011, 04:34 PM

Thank you for your responses, i will give it a try later i hope it works Thanks so much!
   
Reply With Quote
Reply


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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.