Lua Script » Randomizer

by ralf • Sunday February 3rd, 2008
Posted in Lua Scripts, Oxidizer Blog

It’s always a pleasure to learn something new; to be exposed to unexplored workflows and ideas — this is where the true beauty of any virtual community shines. Having had the past few days to toy around with this script I’ve gained insights into Oxidizer that may have gone otherwise untapped, I’m hoping that the same will be true for others. A big shout of thanks to ralf for generously sharing this one!

~Scott

The basic idea for this script is to batch create a large group flames directly in Oxidizer’s main window. By limiting certain parameters the script is able to generate flames much quicker than is typically achieved when using the ‘Gene Pool’.

Randomizer Images

A few notes about the script: it is very simple, although admittedly quite ugly (I had never programmed in Lua before Dave put this into Oxidizer). I basically just took Dave’s “create_genome_from_scratch.lua” script and wrapped a FOR-loop around it, so that it creates 100 genomes from scratch with randomized coefficients. You can change the number of genomes you want to have per batch (line 35, “nbat=100”).

Incidentally, that is roughly the frequency you can expect; out of 100 random draws, one or two might have some interesting aspects, and the rest are pure junk; of course this also depends on the settings. Some combinations of transforms are more likely to produce interesting results than others — this is what we’re exploring here.

In Lua, comments are started by a double hyphen (“–“), and you’ll see a lot of commented lines in the script that you don’t have to worry about. Currently the script only uses two Xforms and two variations per Xform, but you can easily expand that to use more of each. You can see parts of the commented code where I did exactly that, you can just uncomment or copy those parts.

The affine coefficients are randomized for each Xform, where I (somewhat arbitrarily) set the ranges to [-1.1,+1.1] for the first two pairs and [-0.5,+0.5] for the final coefficient pair. You can modify this of course to some setting that you might discover works better.

I also switched off the global symmetry (sym=”No Symmetry”), but you can include a random symmetry as well (uncomment line 61 and comment out line 62). The Xform weight and symmetry is randomized between [0,1], and you can modify this. For the variations, one has to pre-select which variations are to be included, then the script randomizes their weights to whatever range you like.

The current setting uses a cylinder-based combination (weights = +1 or -1), with some random spherical and sinusoidal thrown in. This is a bit like cooking. Try changing the variations and you get all kinds of funny creatures.

Finally, I don’t invoke any randomization on the post coefficients, since this more often than not has a tendency to destroy otherwise nice looking flames. Typically, I instead explore the effect of post-coefficient transforms *after* the script has produced a nice candidate that is ready to be tweaked. But it is simple enough to also randomize the post coefficients in the script if you want to.

I think that about covers it, let me know if you have questions. Happy randomizing!

Download Randomizer Lua Script.



6 Comments

  1. ralf
         February 4, 2008

    Thanks Scott – for more examples of images created by the randomizer, I just uploaded a new gallery to my site, which is 100% randomizer:
    http://www.twelfthnight.se/ff3/g5.htm

    Again, a huge thanks to Dave for putting the scripting capability into Oxidizer, which gives us almost limitless flexibility to experiment with all sorts of crazy things that he can’t be bothered to program for us :)

  2. Pharmagician
         February 4, 2008

    Amazing images, Ralf! I’ve spent all weekend with the script (thanks for that!) and it’s been great. Now, having looked at your newest galleries, I can see I should also experiment with variations and perhaps adding another transform. There just aren’t enough hours in the day (night!)….

  3. ralf
         February 5, 2008

    Glad to hear you’re finding it useful – “experiment” is definitely the keyword here. Some additional pointers.

    1. The script can be eminently used as a learning tool: by systematically probing simple combinations you gradually build up an understanding of what the transforms will do, by themselves or in combinations. Try simple things like just two sphericals (like in my gallery #5), two cylinders, two sinusoidals etc, then step up in complexity and experiment with 2+2 combos, e.g. (cyl+sphere)x(cyl+julia) and so on.

    2. Another script I use in conjunction with the randomizer is the tweaker:
    http://homepage.mac.com/rflicker/files/tweaker.lua
    This one serves the purpose of liberating you from the tedium of adjusting coefficients by hand in order to fine-tune a genome, which can be a bit of a pain. The idea is that once you have an interesting-looking candidate genome, you want to find out if it can be made even nicer by making small adjustments to the coefficients, i.e. “…maybe if I go a little bit in that direction in N-space the genome will look even nicer..” Or maybe it won’t. The only way to find out is to adjust the coefficients and see what happens. Now, Dave is working on something that will make editing in Oxidizer a lot more enjoyable, but until that is published, I’m using this tweaker script for this purpose.

    3. If you are not already doing this, a nice workflow improvement is to use the Breeder as a genome clipboard, for temporary storage of candidate genomes while you are running the randomizer and the tweaker in the main Oxidizer window. My randomization workflow is typically like this:
    1) run the randomizer
    2) drag candidates to the Breeder
    3) clear the Main list (cmd-N)
    4) drag first candidate from Breeder to Main
    5) run tweaker
    6) iterate 2-5 until you’re happy
    7) iterate 1-6 until it’s time to go to bed :)

    4. There are three virtues of working with simple genomes in the randomizer:
    a) faster generation
    b) easier to understand what’s going on
    c) higher probability of finding the “sweet spots”

    Although I don’t have a calculation for (c), it is my observation that this appears to be the case. It does seem intuitive that the more parameters you randomize, the likelihood of finding particular combinations goes down. Then again, the parameter space is very unintuitive, and it also seems likely that the number of sweet spots goes up when you add in more transforms, so the two effects work in opposite directions. But still I think that the first effect wins, that is: the ratio of hits/misses appears to go down rapidly as you increase the complexity of the genome. This is not to dissuade you from experimenting with more complex settings, just a speculation about what might happen.

  4. Pharmagician
         February 5, 2008

    Wow – I echo Scott’s big shout of thanks! This is really generous of you – you’re giving away your secrets! It hadn’t occurred to me to use the breeder as a clipboard – that’s saved some time! And the tweaker works beautifully. The last few days I had been running your randomizer, choosing a couple of candidates, then adding a third, linear, transform and hand-tweaking its coordinates (incl negative values) and getting interesting results. As a non-maths-whiz I have no idea if that’s intelligent or just good luck…! Thanks again. Now I suppose I should go to the office…

  5. Don Larson
         February 5, 2008

    Thank you!

    Don

  6. Dante
         February 13, 2008

    LOL. I just started today, and before reading any of this got the idea to use the breeder as a clipboard. Convergent evolution….

Sorry, comments for this entry are closed at this time.


1 Trackbacks/Pingbacks

  1. Pingback: Rampant Mac » Blog Archive » Oxidizer Desktops & More at Twelfth Night on February 5, 2008

Size

Colors