Repeatable Randomness

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
nik282000
Posts: 6
Joined: Sun Nov 10, 2013 8:35 pm

Repeatable Randomness

Post by nik282000 »

I'm working on animating some Context Free Art and I noticed that even when you define the random see with /v
the "randomness" is quite different if any of the variables in the code have changed. In my example I am changing
the "r" value in one location. Is the way that weighted rules get picked influenced by the rule's contents and might
there be a way I can work around this to have "random" trees that branch at the same step regardless of the rest
of the variables?

If not I can think of a few ways to simulate the randomness I am looking for but none of them would produce
trees as nice as the built in Context Free Art engine.

Thanks,
-Nick

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: Repeatable Randomness

Post by MtnViewJohn »

Context Free uses a tree of random number seeds instead of a global pseudo-random number generator. This is done so that a variation doesn't change radically when you change the rendering resolution. To keep things interesting, the actual text of each shape replacement in a rule is reduced to a 64-bit value that we call its "entropy". This entropy value gets exclusive-ORed into the random seed during the shape replacement. If you change the text of a shape replacement then you change the entropy, which changes the randomness of the descendent shapes.

The solution to your problem is simple. If you have a value that you want to change without affecting randomness then store this value in a global variable and reference the global variable in your shape rules. The entropy of a variable is derived from its name, not its value. So you can change a value without affecting randomness.

nik282000
Posts: 6
Joined: Sun Nov 10, 2013 8:35 pm

Re: Repeatable Randomness

Post by nik282000 »

Awesome! Thanks for the explanation and easy fix too!

Post Reply