|
Kyma Forum
![]() Tips & Techniques
![]() not quite random
|
| next newest topic | next oldest topic |
| Author | Topic: not quite random |
|
phillipm Member |
I am looking for a way to generate a not-quite-random series of numbers. Specifically, I want to randomly choose between 9 possible integers (0 1 2 3 4 5 6 7 8) ... that's the easy part. BUT ... I never want the same number twice in a row. With such a small universe of random numbers to choose from, this happens quite a lot with true random selection. I've run into this situation before always resorted to a "brute force" solution of some sort. But I'd like to figure out a true solution this time, if possible. (Sheesh ... someday I hope I will actually learn smalltalk/capytalk. Maybe when I retire.) IP: Logged |
|
SSC Administrator |
If you always add a random amount to your previous selection, and you make sure that the amount you're adding is never 0, then it should give you a sequence without repeats. code: By adding a random integer from 1 to 8 to your previous value you should avoid repeating a number. Then you could take the new sum modulo 9 to keep it within the range you specified. IP: Logged |
|
JulianLeviston Member |
Carla, do you keep these examples and add them to the expressions library on next release? I reckon that'd be an awesome thing, coz this would be a prime candidate, no? ![]() IP: Logged |
|
SSC Administrator |
Thanks, Julian, that's a great idea! Now just have to figure out which category it belongs under... IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() |
|
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.