Software Documentation

Software Documentation

ScriptingDocumentation

Intermediate Last updated: July 8, 2021

2 Randomize

The first time someone asked me to add a randomize function to Finale 3D, I didn’t believe it was a serious request.  How could a randomize function be at all useful in a scripted show?  It would take two or three other people requesting the same thing before I finally added the function.  Only after I added the function did I understand how useful and beautiful randomization can be.   Figure 1 shows a snapshot of the moment I understood its purpose:

 

Figure 1 – A wall of comets as a randomized sequence

 

The wall of comets created by a randomized sequence was one of the most beautiful choreography motifs I’d seen.  You can make such a pattern with just a few steps:

  1. Select a set of positions in line or circle.
  2. Click in the effect palette to add a comet effect to all of them.
  3. Press control-D a few times to duplicate each comet at each position into eight comets.
  4. Press the “S” key to put them into a sequence, with 0.1 seconds or so intervals.
  5. Do the menu item, “Script > Reorder > Randomize”.

Literally, it only takes half a dozen key presses or clicks to create this beautiful pattern.  The way it works is that the randomize function reorders the selected set of effects into a random permutation.  The only requirement for the randomize function is that you select multiple events and they are at different times (otherwise reordering them wouldn’t do anything).

 

Randomizing effect types and angles

The wall of comets example is a random permutation of events shooting from a line of positions.  The randomize function can also randomize a sequence of various effect types shooting from the same position, or a sequence of various angles of the same effect type at the same position.  Thus, you can create a randomized fan of comets with similar appearance to the randomized wall.  You can also insert a large batch of effects at a single position without concern over their order, then put them into a sequence and randomize the sequence to convert the batch of effects into a pleasingly random “bucket toss show”.

Figure 2 shows an example of inserting a batch of four colors of comets, and then putting them into a sequence and then a fan.

 

Figure 2 – A batch of four colors without randomization.

 

Figure 3 shows the result of applying the randomize function after putting the batch into a sequence.

 

Figure 3 – The batch after applying the randomize function.

 

Do you notice anything unusual about Figure 3?  The sequence of colors looks random, but poker players and mathematicians may recognize something is awry.  It turns out there is a difference between sequences that look random and sequences that actually are random.  If you are curious, look at Figure 4 and read on to see what the randomize function is actually doing.

 

Technical note

Soon after adding the randomize function to Finale 3D I got feedback that the function had a bug: it wasn’t producing random sequences.  I couldn’t understand the complaint because I was certain that the function was correct.  Eventually someone showed me what he meant.  He showed me a randomized wall like that in Figure 1, and he pointed out that at various points in the randomized sequence, two or three comets in a row would come from the same position.  And that didn’t look random.

 

Figure 4 – Truly random permutations have runs of the same color, but people say that doesn’t “look” random.

 

That’s when I learned the difference between “truly random” and “looking random”.  Truly random sequences of shots from a set of positions often do have small runs of multiple shots in a row from the same position, but I can’t argue with the complaint.   The runs don’t look random.  The objection is not so apparent in a still image like Figure 4, but it looks a lot worse when you watch a sequence like the wall of comets.

The current randomize function in Finale 3D is substantially more complicated than just rolling the dice to produce a random sequence.  It produces sequences that “look random” even though mathematically they are not.  For the choreographer, they are better than random.

The aesthetic quality of the result depends on the number of events being randomized and, roughly speaking, the number of positions they shoot from (or effect types or angles).   If there are no “good permutations” of events without runs, then the input can be said to be overconstrained.  In these cases, the randomize function does the best it can, but the result will have runs for sure.  The degree to which the input is underconstrained is the ratio of good permutations to all permutations.  The randomize algorithm guarantees no repeats for all underconstrained inputs. It is likely to produce desirably random looking distributions for highly underconstrained inputs, but it can produce undesirable distributions for overconstrained or marginally underconstrained inputs.  In most practical circumstances, though, the randomize algorithm will produce a result that is not worse than true randomization.

 

Random seed

The randomize function produces deterministic results based on a random seed calculated from 1) the ordered list of times being randomized, 2) the ordered list of positions, part numbers, or angles of the effects being randomized, and 3) the size of the undo buffer.   Thus if you do the randomization operation, then undo, then do it again, you will get the identical result; but if you randomize repeatedly you will get a new result each time because you are increasing the size of the undo buffer with each operation.