Swizzbeat Posted January 1, 2014 Author Posted January 1, 2014 (edited) Sorry but this is not right: random(WORLDS.length() - 1) An example: random(28); This can gives you the number 0 or the number 27 and all numbers beetween this two numbers. But not the number 28. This is right: random(WORLDS.length()) Nevermind you're right this API is freaken horrible. Edited January 1, 2014 by Swizzbeat
Soldtodie Posted January 1, 2014 Posted January 1, 2014 *facepalm* The length method returns the TOTAL amount of index's in the array. For example if you had an array of {1, 2, 3} the maximum index would be 2 however length() would return a value of 3. I know. Now use random(3); The highest amount you can get is 2. 1
blabla123 Posted May 23, 2014 Posted May 23, 2014 Sorry to gravedig but this is the right thread to ask this. How would I change it so that I have an initial array WORLDS and when I hop to a certain world, it would be withdrawn from the initial array and put into a second one, lets say WORLDSHOPPED. Then I would hop again, but it would pick a random world from the remaining worlds in WORLDS array. That would go on and on and at the end if there would be no worlds left in WORLDS and they were all in WORLDSHOPPED, all the values would go back into the WORLDS array. So I would hop all the worlds - NOT HOPPING TO PREVIOUS ONES - and after I have hopped all the worlds, "the counter" would reset. How would code for something like that look like?
Swizzbeat Posted May 23, 2014 Author Posted May 23, 2014 Sorry to gravedig but this is the right thread to ask this. How would I change it so that I have an initial array WORLDS and when I hop to a certain world, it would be withdrawn from the initial array and put into a second one, lets say WORLDSHOPPED. Then I would hop again, but it would pick a random world from the remaining worlds in WORLDS array. That would go on and on and at the end if there would be no worlds left in WORLDS and they were all in WORLDSHOPPED, all the values would go back into the WORLDS array. So I would hop all the worlds - NOT HOPPING TO PREVIOUS ONES - and after I have hopped all the worlds, "the counter" would reset. How would code for something like that look like? Learn Java.
Botre Posted May 23, 2014 Posted May 23, 2014 Sorry to gravedig but this is the right thread to ask this. How would I change it so that I have an initial array WORLDS and when I hop to a certain world, it would be withdrawn from the initial array and put into a second one, lets say WORLDSHOPPED. Then I would hop again, but it would pick a random world from the remaining worlds in WORLDS array. That would go on and on and at the end if there would be no worlds left in WORLDS and they were all in WORLDSHOPPED, all the values would go back into the WORLDS array. So I would hop all the worlds - NOT HOPPING TO PREVIOUS ONES - and after I have hopped all the worlds, "the counter" would reset. How would code for something like that look like? http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html