Alice Community  

Go Back   Alice Community > Alice 2 > Suggestion Box

Reply
 
Thread Tools Display Modes
Since when does MAX mean LESS THAN?
Old
RecoJohnson
Junior Member
 
Status: Offline
Posts: 9
Join Date: Nov 2011
Location: Canada
Default Since when does MAX mean LESS THAN? - 11-07-2011, 07:45 PM

Alice is really frustrating to work with because of simple non-logical elements like this...

  Send a message via MSN to RecoJohnson  
Reply With Quote
Old
Powerhouse64
Senior Member
 
Powerhouse64's Avatar
 
Status: Offline
Posts: 54
Join Date: Nov 2011
Location: In ur base, movin ur stuffs
Default 11-07-2011, 07:56 PM

You sir seem to just be unfortunately unlucky! I just plugged that same program into Alice and got a satisfactory spread of numbers! Alice just didn't pick four for a bit for you apparantly!


Hogwarts: Where everything is made up, and the points don't matter
   
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 11-07-2011, 08:16 PM

I've had the same thing happen to me before. I think it was a bug that was fixed in the updates.

I don't suppose your copy of Alice is old?
   
Reply With Quote
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 11-07-2011, 11:45 PM

Less of a bug and more of an off-by-one error. See, when programming people tend to make lots of off-by-one's, especially when concerning inequalities. They're really hard to find because they don't generate an error, and are somewhat hard to find under a massive stack of code. Likely all the guy had to do was change the operator for the max random number from < to <=.
   
Reply With Quote
Random number
Old
aikmin
Senior Member
 
aikmin's Avatar
 
Status: Offline
Posts: 85
Join Date: Mar 2008
Default Random number - 11-08-2011, 01:59 AM

This is not a bug. Random number returns a Double value between 0 and 1 (not including 1). For minimum, Alice simply add the "min value" to the generated number. For maximum, Alice multiply the "max value" with the generated number.

Note: This is not something Alice made up.

Edit: "integerOnly==true" returns the int of the Double value and not the Round to prevent you from getting 1.

random number min=0, max=1, integerOnly=true always return 0

0.12 returns 0
0.55 also returns 0
0.99 also returns 0

By definition of the Random number [ min, max ).

Last edited by aikmin; 11-08-2011 at 02:13 AM.
   
Reply With Quote
Old
RecoJohnson
Junior Member
 
Status: Offline
Posts: 9
Join Date: Nov 2011
Location: Canada
Default 11-08-2011, 06:14 PM

@aikmin

So how exactly is a number calculated?
I tried what you said :



@Mr Kidnapper - Not really a bug but a programming error I agree.
But.. doesn't bug == programming error?

@x2495iiii I am using Alice 2.2, and I have the latest version of Java installed.

@Powerhouse64 can you post a screenshot? I want to see this
  Send a message via MSN to RecoJohnson  
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 11-08-2011, 08:59 PM

This is not a "bug." In most programming languages the start of something is not '1' it is '0'

So at the moment disregard the minimum value and assume it is 0. So your maximum is whatever you want say 6. So you can get 0 , 1 , 2 , 3 , 4 , and 5. Now count how many numbers that is. 6 The maximum really specifes how many numbers you can display starting with 0. That is why it is a bit odd.

Let's take your first example.

Min : 1
Max : 4

However remember that the computer starts with 0 so instead make it :

Min : 0
Max : 4

So what you would be able to display 0 , 1 , 2 , 3. Note how we have 4 numbers. But wait we have a problem your output did not show 0.

So this is what I think Alice does. It finds the numbers we just found above and then uses the minimum value to determine how many of those it should display. In your case since you specified 1 it would display 4 - 1 or 3 different numbers. Them being 1 , 2 , and 3.

Hope that is not too confusing.


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
   
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 ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.