Little problem with stopping recursion

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

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
Alexander
Posts: 4
Joined: Sun Jan 29, 2006 2:18 pm

Little problem with stopping recursion

Post by Alexander »

Hey,

I'm really new to fractals, so forgive me if this is obvious.


I have made this fractal and it goes on and on.

Code: Select all

startshape TREE

rule TREE {
	SQUARE { }
}

rule SQUARE {
	CIRCLE { }
	SQUARE { y .95 s .99 }
}

rule SQUARE 0.03 {
	CIRCLE { }
	SQUARE { r 30}
	SQUARE { r -6 }
	SQUARE { r 6 }
}
Any way to stop this from continuing ?

Thanks,

Alexander

momo
Posts: 53
Joined: Tue Jul 19, 2005 5:08 am

Post by momo »

you can try setting a size to your SQUARE rules or using a stop rule like this:

Code: Select all

rule SQUARE 0.07 { }
Anyway, setting the size for your SQUARE makes it look better.

Alexander
Posts: 4
Joined: Sun Jan 29, 2006 2:18 pm

Post by Alexander »

hey thx alot momo,

This is what I came up with as my own solution.

Code: Select all

startshape TREE

rule TREE {
	SQUARE { hue 100 sat 1  b 0.3 }
}

rule SQUARE {
	CIRCLE { }
	SQUARE { y .95 s .99 hue 0.2 sat 1  b 0.3  }
}



rule SQUARE 0.0185 {
	CIRCLE { }
	SQUARE { r 30 }
	SQUARE { r -30 }
}

I'll give yours a try in a sec, it's appreciated ;) !

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

Post by MtnViewJohn »

Your first cfdg file is too "branchy": Your second SQUARE rule was generating new SQUAREs faster than your first SQUARE rule was getting rid of them. You can fix this either by reducing the "branchiness" of the second SQUARE rule or make the first SQUARE rule shrink faster.

Your second cfdg file decreased the branchiness of the second rule by decreasing the rule weight and decreasing the number of SQUARE shapes in it. Or you could have left the second SQUARE rule as it was and tweak the first one slightly:

Code: Select all

rule SQUARE {
   CIRCLE { }
   SQUARE { y .95 s .975 }
}

Alexander
Posts: 4
Joined: Sun Jan 29, 2006 2:18 pm

Post by Alexander »

ofc.. never noticed, thanks !

Post Reply