Grasshopper

algorithmic modeling for Rhino

Hi all,

Is there a way to use the "Random" component and not get duplicate numbers as a result?
Like shown in the picture.

Thanks,
Adam

Views: 18397

Attachments:

Replies to This Discussion

Generate a series of numbers inside your acceptable range. Use the Random Reduce component to remove however many you want, then use Random component plugged into a Sort component to randomly sort your list of unique numbers.

Attachments:
Hm, interesting solution, couldn't work for me exactly because I'm using these numbers to call a "List Item" and need a full range from 0 to 29 in a random order, but I actually realized that simply using jitter would work just fine. Thanks a lot though.
I like Chris' idea to use [Random Reduce] on known series of numbers, but then instead of randomly sorting the remaining values you can just use [Jitter] to shuffle them.

It seems like there should be an option on the "Random" component to turn on and off repeating values...
It's not repeating values, it's identical values. When you generate 50 random values in the 1-100 range, it is technically possible to ensure that you don't get any overlap. However if you generate 50 random values in the 1-20 range, you must get overlapping values, as per the pigeon-hole principle.

See this Wikipedia article on some details.

If you have a list of numbers you're willing to accept, but you want to randomize the order, then Chris' and Taz' solutions are excellent. A switch on Random that would automatically remove any duplicates, would interfere with the the [N] input, since it's not always possible to generate [N] unique random numbers.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
David, has there been any word of the random reduce function being buggy? I have a series of lists, each with only 3 numbers, and it doesn't seem to EVER cull the last one. All three are in the same branch. I am feeding a different seed to each branch to get a different pattern...something appears to be up
Ah, my mistake. I forgot the upper bound of Random ranges are exclusive, while the lower bounds are inclusive. I fixed it, but it's going to be a while until the next release hits the 'shelves'.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
thanks David...just wanted to know that I wasn't doing something wrong. I got around it with a bit of jitter...

best!
forgot the attachement... Philipp
Attachments:
Nice one, Taz. I forgot about Jitter. Fewer components is much better.

Hi, I am having a similar problem getting a really random selection from a list. I have a list of 6 points. I want to randomly choose 1 point from this list every 100ms. I tried random reduce to get down to the one point. But I always get the same point. From what I understand I need to insert a different seed value if I want a different point to remain after the reduction. so I need to generate random seed values...yikes, you can see how this problem is getting circular here. I tried jitter and it also seems to result in the same number all the time...

BTW, I am using Firefly to collect sensor data every 100ms. so if I have to I can use this to make my point selection more random but I just can't think of how.

 

Also, in the future I would like the option to increase the possibility of some of those 6 points to be selected more often than others. I was hoping to use the graph mapper to achieve this. 

 

But for now I just really need to figure out how to select one point from a list of six points that gives me a different result every 100ms! pls help....

Why don't you connect some sort of unstable sensor to Arduino, and use this as your seed value? In this case, something buggy (on the hardware side) is what you want. Obviously this would be 1 of many solutions for this.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service