Yes indeed, it’s from The Blind Watchmaker… Dawkins wrote that for Apple Macintosh.
Yes, I had a Mac IIs at the time, with 5Mbytes RAM and a 105Mbytes hard drive.
In my app. RealCADD, I have a script which can draw things like this :
Changed the code,
that is not the same as
Length=Length-1
If length > 0 Then
Tree(G, Xnew,Ynew, length, dir-1,DX,DY)
Tree(G, Xnew,Ynew, length, dir+1,DX,DY)
End If
base from your original screenshot i would use this
If length > 0 Then
Tree(G, Xnew,Ynew, length-1, dir-1,DX,DY)
Tree(G, Xnew,Ynew, length-1, dir+1,DX,DY)
End If
seems you used it before
With :
Var DX() As integer = Array(-7, -5, -3, -1, 1, 3, 5, 7)
Var DY() As integer = Array(1, 3, 5, 7, -7, -5, -3, -1)
I have this :
Is that OK? or only half?
If it is OK, it is probably your first point which is not good.
I start with canvas1.width / 2 , canvas1.height / 2
If you’re interested in recursion, this will give you a good handle on the concept.
Good!
But it is an infinite loop…
Ahum, the link you posted is to your comment ?!?
Hi, I gave the DX and DY a random value ranging from -9 to 9. But, and Dawkins is quite vague about his parameters, the biomorph should be symmetrics. Your params give a very interesting outcome.
I too started with a center point in the canvas.
The link doesn’t work…
I’ll attach my project and you can have a look.
my tests
Button
Sub Pressed() Handles Pressed
Var p As New Picture(Self.Width, Self.Height)
Self.Backdrop = p
Var dx() As Integer = Array( 0, 1, 1, 1, 0, -1, -1, -1)
Var dy() As Integer = Array( -1, -1, 0, 1, 1, 1, 0, -1)
Var g As Graphics = p.Graphics
g.Translate g.Width / 2.0, g.Height / 2.0
Var length As Integer = 5 '1-10 depth
Tree(g, 0, 0, length, 0, dx, dy)
End Sub
Module Method
Public Sub Tree(g as Graphics, x as Integer, y as Integer, length as Integer, dir as Integer, dx() as Integer, dy() as Integer)
If length <= 0 Then Return 'END
Var xnew, ynew As Integer
'check dir 0-7
If dir < 0 Then
dir = dir + 8
ElseIf dir >= 8 Then
dir = dir - 8
End If
'calculate new position
xnew = x + length * 5 * dx(dir)
ynew = y + length * 5 * dy(dir)
'recursive calls for new branches
Tree(g, xnew, ynew, length-1, dir-1, dx, dy)
Tree(g, xnew, ynew, length-1, dir+1, dx, dy)
'draw the path
g.DrawLine x, y, xnew, ynew
End Sub
a interesting site with js source, could be used for games.
https://web.archive.org/web/20150927213752/http://www.well.com/~hernan/biomorphs/
That’s it! It was just an DX and DZ thing apparently. My values were too high.
I moved the length test to the beginning of Tree as there’s no point in continuing if length=0
My recollection is that the program would produce a set of images from small variations in the parameters, then you could choose an image that looked the closest to some particular thing (a dinosaur, say). Then it used the params from that picture as the starting point and repeated. And you chose again, and so on. After very few iterations, you got your dinosaur (or whatever).
Technically, infinite recursion.
Yes. Dawkins uses a third parameter he called Gene(9). The Genes array steer the DX and DY arrays and the Length/Order value. Haven’t implemented yet but the code for this is:
Order = Gene(9)
DX(3) = Gene(1)
DX(4) = Gene(2)
DX(5) = Gene(3)
DX(1) = -DX(3)
DX(0) = -DX(4)
DX(2) = 0
DX(6) = 0
DX(7) = -DX(5)
DY(2) = Gene(4)
DY(3) = Gene(5)
DY(4) = Gene(6)
DY(5) = Gene(7)
DY(6) = Gene(8)
DY(0) = DY(4)
DY(1) = DY(3)
DY(7) = DY(5)
Unclear what the original values for Gene() are. The essence is that the Biomorph is drawn with six slightly shifted params. User selects the most appealing one and restarts the process, thus imitating natural selection.
What is the order value?