Alice Community  

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

Reply
 
Thread Tools Display Modes
problems with random number
Old
alicestudent10
Guest
 
Status:
Posts: n/a
Question problems with random number - 02-24-2010, 04:03 PM

I have to create a guessing game and let alice generate a random number for you to guess and then have 2 objects give you higher lower ques. I have gotten this to kinda work, but after you guess incorrect it generates a new random number which defeats the purpose. How do I have it set a random number and keep it.

Example:
Ask for guess
Loop:
IF [guess] = (random number)
dance
Else
If guess > (random number)
say too high
Else
If guess < (random number)
say too low
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 02-24-2010, 07:14 PM

Create a number variable with the "Create Variable" button under the properties tab on the left side of the screen. Name it whatever you like and set it's value to 0. Then, have that variable set its value to a random number at the start of your world. Now, replace the arguments in you if/else statements with "if [guess] == <your variable>" and you should be fine.


(')>
   
Reply With Quote
It works
Old
alicestudent10
Guest
 
Status:
Posts: n/a
Default It works - 02-24-2010, 07:26 PM

I swear I have tried that before, but it works! You are awesome! Thank you!
   
Reply With Quote
Old
zarfang8
Guest
 
Status:
Posts: n/a
Default 02-24-2010, 07:39 PM

You could also do this with a list. This will work for not only a custom range of numbers, but you could use specific numbers, (such as, only even numbers between one and ten, Example: 2,4,6, and 8.) This also works will colors, objects, etc.

After you make this list, have a variable set to a random (color,number, whatever you chose) from your list.
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default 02-26-2010, 08:40 PM

Ooh! Guess-a-color! I like it!


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
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.