"underground" in infinte loop?

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
frogkiller
Posts: 1
Joined: Sun Dec 28, 2008 12:59 pm

"underground" in infinte loop?

Post by frogkiller »

Hi, guys. I find something strange - "underground" example (which comes with program) seems nether stops expanding its rules with ZSW seed. It makes 40 temp files and about 8.000.000 shapes - and i stops it manually. Rendered image looks great at 10000*10000 :)

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

underground

Post by kipling »

It does stop, at around 89 million shapes.
If you do 800*800 you get around 40 million, as it hits a "canvas resize" step which pushes all the unexpanded rules below the size threshold, bringing it to a screaming halt, but just giving you a picture of a dust. However, if you push the resolution up to 1600*1600, 3200*3200 or 6400*6400 (with minimum shape size of 0.1) you get around 89 million shapes (actually 89 127 442), meaning that all of the rules are being terminated naturally, and none by the "too small" rule.

I had a similar set of rules (spaghetti, in the gallery) that occasionally did this. It is not uncommon where the probability of duplication (i.e. adding a new instance of the current rule) is equal to, or only slightly less than the probability of that rule terminating.*

The "underground" cfdg is actually a good example of this -- it is not too hard to see why this happens in this case. The rule ROUTE calls LINE twice (via LINES). The total weight of the LINE rules is 1009.5:
  • A total weight of 1008 on rules with some drawing plus another copy of LINE
  • a weight of 1 on the terminus rule (drawing a shape and halting)
  • a weight 0.5 on the interchange rule, which will spawn a new ROUTE and also keep the LINE going
From this (which can be modelled as a Bernoulli process with p=1/1009.5 if you care to know the technical details) we can deduce that a call to LINE will have on average
  • 1009.5 calls to LINE (i.e. the average "length" of the line is 1009.5 - this is the expected value of a geometric distribution)
  • .5 calls to ROUTE
and so each ROUTE expansion will have on average
  • 2019 calls to LINE
  • 1 call to ROUTE
So this is a real knife-edge case -- if there was any more weight on the interchange rule, then almost all expansions would lead to exponential growth, filling your hard disk with temp files. If there was much less, we would get exponential decay, and most patterns would be short and dull.
As it is, the ZSW variant must have many of the early ROUTE expansions leading to more than 1 ROUTE rules, and it takes quite a while for these all to die out via the terminus version of the LINE rule.[/list]

*... that is, in a pattern with no shrinkage, such as this one. With shrinkage it is a little more complicated, as the other way expansion can end is that "scale" in the pattern gives the cfdg engine another way to stop expansion.

User avatar
askiopop
Posts: 12
Joined: Wed Mar 04, 2009 7:07 pm
Location: Guess

Post by askiopop »

I saw this, so for fun I tried to render it in to a video. When I looked at the file in my documents it rose 200 kb every 5 seconds until it was 1000 kb :shock:. And I still didn't get the video!! Oh well, thankfully it only happens 1/20 of the time.
thank you

Post Reply