char0 Posted October 15, 2013 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 13 Reputation: 0 Joined: 12/20/11 Last Seen: March 21, 2017 Share Posted October 15, 2013 (edited) Hello, I'm trying to generate random numbers not repeated for an array ".p" using the same size an array ".s$". But the NPC is accusing infinite loop. How could I generate numbers not repeated 0-19 without error? Grateful for help, Char0. Edited October 15, 2013 by char0 Quote Link to comment Share on other sites More sharing options...
Emistry Posted October 15, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted October 15, 2013 you can try this http://upaste.me/r/7c658f 1 Quote Link to comment Share on other sites More sharing options...
Capuche Posted October 15, 2013 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 616 Joined: 07/05/12 Last Seen: March 20 Share Posted October 15, 2013 I don't understand what you wanted to do but about How could I generate numbers not repeated 0-19 without error? setarray .@tmp, 0,1,2,3,4,5; .@size = 6; while( .@size ) { .@r = rand( .@size );// pick a number between 0-19 set .p[.@i], .@tmp[.@r]; deletearray .@tmp[.@r],1; .@size--; .@i++; } 1 Quote Link to comment Share on other sites More sharing options...
char0 Posted October 15, 2013 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 13 Reputation: 0 Joined: 12/20/11 Last Seen: March 21, 2017 Author Share Posted October 15, 2013 Thank Capuche and Emistry. The Emistry code worked fine, but both were very helpful. Quote Link to comment Share on other sites More sharing options...
Question
char0
Grateful for help, Char0.
Edited by char0Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.