Alice Community  

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

Reply
 
Thread Tools Display Modes
Random number not so random
Old
neveser
Guest
 
Status:
Posts: n/a
Default Random number not so random - 11-20-2010, 08:41 PM

I'm trying to generate a random number and assign a variable that number.
It stays stuck at 1.

The code is
whichAnimal set value to random number minimum=1 maximum=3 Integeronly=true

whichAnimal is my numeric parameter.

I used the watch and it stays at 1.
   
Reply With Quote
random generation
Old
cmurphyart
Guest
 
Status:
Posts: n/a
Default random generation - 11-20-2010, 10:12 PM

I too am having problems with the random number. I think I will try to replicate the bees and the random flowers from page260 and see if I can see where my current dilema is with the SharkPursuit exercise. Anyone want to offer help?
   
Reply With Quote
Old
debussybunny563
Senior Member
 
debussybunny563's Avatar
 
Status: Offline
Posts: 852
Join Date: May 2010
Arrow 11-21-2010, 01:11 PM

Quote:
Originally Posted by neveser View Post
I'm trying to generate a random number and assign a variable that number.
It stays stuck at 1.

The code is
whichAnimal set value to random number minimum=1 maximum=3 Integeronly=true

whichAnimal is my numeric parameter.

I used the watch and it stays at 1.
If the variable/parameter is in the method (on the right in the picture), instead of the object (on the left in the picture), then the "watch this variable" thing won't display it; it'll just show what value you had originally entered for it.

To have the "watch this variable" work during runtime, you'll need to make the variable for the object, not the method.
Attached Images
File Type: jpg variables03.JPG (39.4 KB, 34 views)


Last edited by debussybunny563; 12-21-2012 at 12:00 AM.

|--------------------------------------------------------------------------------------------------|
|Link to weapons collection: http://www.alice.org/community/showthread.php?t=7368 |
|--------------------------------------------------------------------------------------------------|

I have been dead for quite some time now; not much hope for resurrection.
   
Reply With Quote
Old
neveser
Guest
 
Status:
Posts: n/a
Default 11-21-2010, 01:36 PM

Here ya go x2495iiii
Attached Files
File Type: a2w spanishVocab.a2w (1.89 MB, 5 views)
   
Reply With Quote
Old
Captain Bravo
Guest
 
Status:
Posts: n/a
Smile 11-23-2010, 11:18 PM

I came across this just yesterday.

I wanted to create a method for a game where on car collision one of three animations would occur randomly. I used random number minimum=1 maximum=3 Integeronly=true just like you did and it would always stay at 1 or at least long enough for me to believe so.

The way I increased the "randomness" was to set random number minimum=1 maximum=100 Integeronly=true and then make my animations variable run when it was less than 34, 67 or 101 that way there was more numbers to be selected.

My programming tutor was telling me about how Java's random number isnt infact random, so this is how we worked around that. Don't know if that helps
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.