1.How can ask the random node not to generate a list of values that are within the desired range??
Example:
min value-0
max value-100
Exception-50 to 60
How to set the minimum and maximum difference between the random generated value??
Example
min value-0
max value-100
min difference between the generated result
max difference between the generated result
So this code block takes four inputs - a minimum value, a maximum value, a minimum void, and a maximum void.
It then crates a random list just like the Math.Random node. It then finds the midpoint of the void (half way between the minimum void and the maximum void). It then tests if any of the resulting numbers are between the minimum void and the midpoint of the void, and generates a new random number between the minimum value and the minimum void, and replaces the initial input with that. Numbers which weren’t between the minimum void and the midpoint of the void and tests if they are between the midpoint of the void and the maximum void, and replaces them with a random number between the maximum void and the maximum number.
This maintains some of the initial dispersion of the randomization - that is if a number was randomly in the lower half of the void it is replaced with a number below the void, and if a number is in the upper half of the void it will be replaced by a number above the void.
Hi, Jacob thanks for the reply,
Let me explain wat i tried to convey on point 2,
I am trying to create curtain grids with random node, The problem comes in when the grids are generated close to each other
hence reducing the height of the curtain panel, which is practically not possible so I am now looking for a something that allows me to specify the minimum and maximum spacing between the curtain grids.
hope the screen shops helps you understand the question better…!!
I am fairly new to dynamo and these codes are complex to me, but it was clear what these codes are programmed to do as I went through, I am just wondering how to pass the void range if I have a list that isn’t in a range for instance on the above example i need a exception on say 31,46,83and 92
No I am an architect if you are asking by seeing my username, that was probably a default suggestion signup page gave me and no you are first to ask…!!!
Instead of using a Math.Random node to generate the number, you should generate the spacing. Start by dividing the total length by your shortest allowable spacing to get the minimum number of panels. Then use the Math.Random node to generate the spacing between each panel for a list that is as long as the minimum number. Next use a mass addition technique (there is a node for this but I don’t recall where, perhaps clockwork?) to get the location of each panel line along the grid - effectively the results of the math.random node but sorted in order (which is ok based on what you described your situation as). Discard any numbers which are beyond the total length, and proceed on your way.
I almost created it with little coding and more of googling, Except that it is working fine on python console
but not sure how to translate to dynamo version,could you share some tutorials that exp[ains it…?
here is the console code and screen shot :
#create random numbers with exception
minvalue = 0
maxvalue =100
amount= 10
exception=[1,6,43,67,82,93]
import random
ran=random.sample(range(minvalue,maxvalue),amount)
print("ran",ran)
a=[i for i in exception if i in ran]
len_a=len(a)
print("a",a)
if a==[]:
final_ran=ran
else:
b=[x for x in ran if x not in a]
print("b",b)
ran1=ran=random.sample(range(minvalue,maxvalue),(maxvalue-minvalue))
print("ran1",ran1)
c= list(set(ran1 + ran))
d=[i for i in exception if i in ran1]
e=[x for x in ran1 if x not in d]
f=b+e
f=list(set(f))
print ("f",f)
final_ran=f[:amount]
print(final_ran)
if int(len(final_ran))!=amount:
print(amount,"Numbers cannot be created try reducing the value of amount")
Well converted from design script to Python, you’re less new than you think!
I am not a Python guru, but I can see that your Python code needs four inputs - click the plus sign on the left and wire in the inputs so your code knows where to start.
I need something a bit more complex…and i can’t figure it out…
i have for example 16 circular curves above eachother and i need a rondom point on all of them. But if the first point is at 0.4 then for the next ring i need to exclude that quadrant… so the random number must not be between 0.275 and 0.525 … let’s asume the next input is 0.925… then the next input must not lie between 0.8 and 0.05…
i know this is tricky… but i hope someone can help…