Field Randomizer Node and/or Field Swap Node
Field Randomizer
Add a node that randomizes a field the same way one could do a random shuffle on an array. Maybe a probability input would also be a good thing.
If the node is implemented with no probability:
It copies the field and, for every element, starting from the first, swap the values with a random succeeding element.
If probability is implemented:
It copies the field and, for every element, a random boolean is generated using the provided probability.
- If the boolean is true, the value of the element is swapped with the value of a random succeeding element.
- If the boolean is false, it does nothing on the current element and proceeds to the next.
Note that, if no probability input is added, there would still be a way to get the same result by using a random boolean to switch between the original field and the randomized field.
Field Swap
With this node, you could do the same as the proposed Field Randomize node, but the possibilities would be more.
it's operation on an element would affect succeding elements.
What it would do is for every element, the value would be swapped with the value of the element with index provided by the Index field.
Example:
Value = Integer(3, 2, 9, 8); Swap Index = (1, 2, 2, 0).
first, the original field is copied, so: Result = (3, 2, 9, 8).
- on the element 0, it will swap with element 1, so: Result = (2, 3, 9, 8)
- on the element 1, it will swap with element 2, so: Result = (2, 9, 3, 8)
- on the element 2, it will swap with element 2 (same index, no swap), so: Result = (2, 9, 3, 8)
- on the element 3, it will swap with element 0, so: Result = (8, 9, 3, 2)
Then the node outputs Result which is (8, 9, 3, 2).
This node can be used to randomize the order of elements of a field when feeding the Swap Index input with a random value generated with interval (min = Index , max = operating domain size).
1 Comment
A special case of sorting. And the user can easily enter overlapping indexes, so it can only be handled by sorting in the general case. It's easier to wait for a sort node than this.