Two different inputs must never be routed to the same output, and two different outputs must never be routed from the same input.
On a trigger you want to swap the routing of only two of the inputs to their respective outputs. So if In3 and In5 are selected for swapping this time, and they are routed as In3->Out4 and In5->Out2, then after the trigger the routing is now In3->Out2 and In5->Out4. The other routings are unchanged.
On each trigger two random inputs are selected for swapping.
Is that correctly understood?
What you also kind of need to specify is:
What are the minum and maximum values of N? Because modules are limited.
Since random is sometimes completely random, and sometimes repeats itself, is it acceptable that sometimes one or both of the inputs selected in the previous step is selected for swapping again? Because if the answer is “no” then we’re looking at something more advanced that needs to “remember” and not repeat until N swaps have gone by. Something more sequential but still non-deterministic rather than completely random. Because sometimes random won’t feel random.
Yes! Thank you. Sorry to keep the language too vague—I’m looking for a general method, and didn’t want to get anyone bogged down in specific modules, routing triggers vs. CV, or exactly how many routings, but I see how that was unhelpful.
Ok. I’m cooking on something but… sorry to disappoint but using existing modules there’s no way I can get around this being a problem of combinatorial explosion. Anything above N=4 gets rapidly completely out of hand. Would you still like a solution for N=always 4?
To avoid the combinatorial explosion this really needs to be made as a dedicated module, as I see it.
Here’s the code for a solution in BASICally. Yes, it is ungainly and repetitive, due to some safeguards in the language, and it only goes up to six outputs, because BASICally only has six outputs. ON the other hand, just one module!
A trigger to IN9 will cause two of the assignments to switch.
WHEN start()
for pos = 1 to 6
grab[pos] = pos
next
' Initialize the mapping.
for pos = 1 to 6
pull_pos = floor(random(1, 7 - pos))
out_map[pos] = grab[pull_pos]
' Put last value from grab[] into the location
' we just selected from.
grab[pull_pos] = grab[7 - pos]
next
END WHEN
WHEN trigger(IN9)
switch1 = floor(random(1, 7))
for dummy = 1 to 2 STEP 0
switch2 = floor(random(1, 7))
if switch1 != switch2 THEN
EXIT FOR
END IF
NEXT
temp = out_map[switch1]
out_map[switch1] = out_map[switch2]
out_map[switch2] = temp
END WHEN
ALSO
out_num = out_map[1]
if out_num == 1 THEN
out1 = in1
elseif out_num == 2 THEN
out2 = in1
elseif out_num == 3 THEN
out3 = in1
elseif out_num == 4 THEN
out4 = in1
elseif out_num == 5 THEN
out5 = in1
elseif out_num == 6 THEN
out6 = in1
END IF
out_num = out_map[2]
if out_num == 1 THEN
out1 = in2
elseif out_num == 2 THEN
out2 = in2
elseif out_num == 3 THEN
out3 = in2
elseif out_num == 4 THEN
out4 = in2
elseif out_num == 5 THEN
out5 = in2
elseif out_num == 6 THEN
out6 = in2
END IF
out_num = out_map[3]
if out_num == 1 THEN
out1 = in3
elseif out_num == 2 THEN
out2 = in3
elseif out_num == 3 THEN
out3 = in3
elseif out_num == 4 THEN
out4 = in3
elseif out_num == 5 THEN
out5 = in3
elseif out_num == 6 THEN
out6 = in3
END IF
out_num = out_map[4]
if out_num == 1 THEN
out1 = in4
elseif out_num == 2 THEN
out2 = in4
elseif out_num == 3 THEN
out3 = in4
elseif out_num == 4 THEN
out4 = in4
elseif out_num == 5 THEN
out5 = in4
elseif out_num == 6 THEN
out6 = in4
END IF
out_num = out_map[5]
if out_num == 1 THEN
out1 = in5
elseif out_num == 2 THEN
out2 = in5
elseif out_num == 3 THEN
out3 = in5
elseif out_num == 4 THEN
out4 = in5
elseif out_num == 5 THEN
out5 = in5
elseif out_num == 6 THEN
out6 = in5
END IF
out_num = out_map[6]
if out_num == 1 THEN
out1 = in6
elseif out_num == 2 THEN
out2 = in6
elseif out_num == 3 THEN
out3 = in6
elseif out_num == 4 THEN
out4 = in6
elseif out_num == 5 THEN
out5 = in6
elseif out_num == 6 THEN
out6 = in6
END IF
END ALSO