Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualByteTroll

Posted 11 October 2012 - 03:52 PM

The reason you are getting the same values over and over again is beacuse you are using "result" to compare, but you never change it's value. The value of "result" is initially set using the
double result = start + (random * (end - start));
but that is never going to get executed again (thus it is going to pick the value once and keep that value). You will need to call
result = start + (random * (end - start));
after every "if...elseif" statement.

See the example I posted. After every block I recall
result = start + (random * (end - start));
giving random a new value.


EDIT: I misread your reply, so above is only an idea of why I think you are getting the issue.
EDIT2: Opps, I meant giving "result" a new value. Not "random."

#2ByteTroll

Posted 11 October 2012 - 10:27 AM

The reason you are getting the same values over and over again is beacuse you are using "result" to compare, but you never change it's value. The value of "result" is initially set using the
double result = start + (random * (end - start));
but that is never going to get executed again (thus it is going to pick the value once and keep that value). You will need to call
result = start + (random * (end - start));
after every "if...elseif" statement.

See the example I posted. After every block I recall
result = start + (random * (end - start));
giving random a new value.


EDIT: I misread your reply, so above is only an idea of why I think you are getting the issue.

#1ByteTroll

Posted 11 October 2012 - 10:26 AM

The reason you are getting the same values over and over again is beacuse you are using "result" to compare, but you never change it's value. The value of "result" is initially set using the
double result = start + (random * (end - start));
but that is never going to get executed again (thus it is going to pick the value once and keep that value). You will need to call
result = start + (random * (end - start));
after every "if...elseif" statement.

See the example I posted. After every block I recall
result = start + (random * (end - start));
giving random a new value.

PARTNERS