Creative Commons colophon
4-Variable IQ Test

Context Free

I found this on Apple’s list of Mac OS X software: Context Free. Too much fun; and it runs on Windows, Mac OS X, and Linux. Here are a couple of the provided examples (source code in the extended entry):

Tangle Sierpinski
startshape SPIKES

rule SPIKES {
    SPIKE {}
    SPIKE { r 90 }
    SPIKE { r 180 }
    SPIKE { r 270 }
}

rule SPIKE {
    LSPIKE {}
}

rule SPIKE {
    RSPIKE {}
}

rule LSPIKE {
    SQUARE {}
    LSPIKE { y 0.98 s 0.99 r 1}
}

rule LSPIKE 0.01 {
    SPIKE { r 90 }
    SPIKE { r -90 }
    LSPIKE { y 0.98 s 0.99  r 1}
}

rule RSPIKE {
    SQUARE {}
    RSPIKE { y 0.98 s 0.99 r -1}
}

rule RSPIKE 0.01 {
    SPIKE { r 90 }
    SPIKE { r -90 }
    RSPIKE { y 0.98 s 0.99  r -1}
}
startshape Top

rule Top {
    Sierpinski { r -13.5 b 0.5 }
}

rule SierpinskiOrig {
    Shape { }
    Sierpinski { s 0.5 r 5
        y -1 x 0  }
    Sierpinski {  s 0.5 r 5
        y 0.5 x -0.866025  }
    Sierpinski { s 0.5 r 5
        y 0.5 x 0.866025  }
}
rule Sierpinski {
    Shape { }
    Sierpinski { s 0.6 r 5 b 0.2
        y -1.5 x 0  }
    Sierpinski {  s 0.6 r 5 b -0.2
        y 0.75 x -1.2990375  }
    Sierpinski { s 0.6 r 5
        y 0.75 x 1.2990375  }
}

# comment out all but one 
#   of these rules for Shape:
rule Shape { CIRCLE { } }
#rule Shape { Triangle { s 0.5 } }
#rule Shape { Triangle { } }
    // this last one fills the image

rule Triangle { 
    Arm { r 0 }
    Arm { r 120 }
    Arm { r -120 }
} 

rule Arm {
    CIRCLE { }
    Arm { y 0.1 s 0.9 }
}

Comments