English 中文(简体)
Genetic Programming with the Mandelbrot Set
原标题:

I m reading a chapter in this fascinating book about using genetic programming to interactively evolve images. Most of the function set is comprised of simple arithmetic and trig functions (which really operation on and return images). These functions make up the internal nodes of the parse trees that encode our images. The leaves of the tree, or the terminal values, are random numbers and x,y coordinates.

There s a section about adding iterative functions of the complex plane to the function set:

Say the genetics inserts a particular Mandelbrot set as a node somewhere in a bushy tree. The function expects two arguments: mandel(cReal, cImag), treating them as real and imaginary coordinates in the complex plane. If the genome just happened to supply the pixel coordinates (x,y), and mandel() were the root node, you would get the familiar Mset. But chances are that cReal and cImag are themselves the results of whole branches of functions, with many instances of coordinates x,y scattered out among the leaves. Enter the iteration loop, orbit around for a while, and finally escape with some measure of distance to the Mset attractor, such as the number of iterations.

My question is how would you make a Mandelbrot set renderer as a function that takes the real and imaginary coordinates of a point on the complex plane as arguments and returns a rendering of the Mandelbrot set?

问题回答

I m not sure if this actually answers your question, but my understanding of the text you quoted simply says that the mandel function is just another function (like multiplication, min, max, addition, etc) that can appear in your genetic program.

The mandel function, like the multiplication function, takes two arguments (in_1 and in_2) and returns a single value. Whereas the multiplication function just returns in_1 * in_2, the mandel function might do something like this:

int mandel(int in_1, int in_2) {
  x = 0
  y = 0
  iteration = 0
  max_iteration = 1000

  while( x*x + y*y <= (2*2) && iteration < max_iteration ) {
    xtemp = x*x - y*y + in_1
    y = 2*x*y + in_2
    x = xtemp

    ++iteration
  }

  if( iteration == max_iteration ) return 0
  else return iteration
}

If your whole genetic program tree consists of nothing but the mandel function with one input as x and the other input as y, then repeatedly evaluating your program for a bunch of different (x,y) values and saving the result will give you a nice picture of the Mandelbrot set.

Of course, the neat thing about genetic programming is that the inputs can be fancier than just x and y. For example, what would the result look like if one input was x and the other input was x + 2*y? Or if one input was x and the other was mandel(x,y)?





相关问题
Genetic Programming with the Mandelbrot Set

I m reading a chapter in this fascinating book about using genetic programming to interactively evolve images. Most of the function set is comprised of simple arithmetic and trig functions (which ...

How to render Mandelbulb-style 3D fractals

I m interested in experimenting with equations for 3D fractals (a la Mandelbulb). Does anyone know of a framework that will allow me to supply a 3-coordinate, Mandelbrot-style function, identifying a ...

Fractal terrain generation problem

I m trying to get a simple 1D fractal terrain generator to work for a 2D game. But for some reason it always either makes a hill, a valley, or a flat line, as seen in this output of the segments (x1, ...

improving drawing pythagoras tree

I have written program for drawing pythagoras tree fractal. Can anybody see any way of improving it ? Now it is 89 LOC. import java.awt.*; import java.util.Scanner; import javax.swing.*; public ...

Fractal based Image compression algorithm (and source code)

I am looking for a decent fractal based compression algorithm for images. So far I only find dead links to the FIF image format and dead links pointing to Iterated Systems Inc which then became ...

How to model rules for generating geometric patterns?

For my problem it would be best to find a numeric representation of kazakh national ornaments for generating new ones. But other approaches are also fine. The ornaments essentially consist of ...

Code golf: the Mandelbrot set

Usual rules for the code golf. Here is an implementation in python as an example from PIL import Image im = Image.new("RGB", (300,300)) for i in xrange(300): print "i = ",i for j in xrange(...

热门标签