Alice Community  

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

Reply
 
Thread Tools Display Modes
Use Random Numbers and Direction ?
Old
itrimble
Guest
 
Status:
Posts: n/a
Default Use Random Numbers and Direction ? - 08-22-2008, 06:05 PM

This is the deal. I am working on a world where a shark chases fish. The part that is working is that when the shark gets close to the fish, the fish is supposed to swim away a RANDOM distance. That is ok. The problem I am having is that The fish is also supposed to swim away a Random DIRECTION . I am not sure what method I have to call to get the fish to swim in the random direction that the method calls.

Or is there a way to use the object parameter in conjunction with the random direction feature? Ex: Shark swim to Random Object [fish1, fish2, or fish3] at the same time my random direction uses the same Random Object to go the random direction.
Attached Files
File Type: a2w SharkPursuit.a2w (2.37 MB, 147 views)

Last edited by itrimble; 08-22-2008 at 06:11 PM. Reason: add attachment
   
Reply With Quote
Random Direction
Old
DrJim
Guest
 
Status:
Posts: n/a
Default Random Direction - 08-22-2008, 07:13 PM

See attached. The key is to have the object face in an random direction and then move "forward."

I've added a bit to make sure that each time the world is run, the result is different. The Alice random number generator isn't really "random." (Most software "random number generators" aren't - there is lots more in the forum on this subject if you are interested.)
Attached Files
File Type: a2w Random Move.a2w (218.9 KB, 345 views)
   
Reply With Quote
A ha !!
Old
itrimble
Guest
 
Status:
Posts: n/a
Smile A ha !! - 08-22-2008, 07:55 PM

That was so simple. I do not know why i did not think of that.
Having the chicken turn left either 0 or 1 revolution was brilliant.
Then have the chicken move forward 1 meter. That way it is always changing direction and moving forward.


Sometimes I can't see the forest through the trees.


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