The digital code used to send back signals from Mars by Mariner 9 can easily be designed recursively.
One part of the algoritm needs the inversion of a pattern of 1s and 0s. Due to the way color is representsd in CDFG this is easy.
Choose a hue for repenenting 1 and for 0 choose a hue 180 away. Now redrawing any pattern of 1s and 0s with a setting h 180 will swap the colors.
The code could probable be more compact but I wanted a definite number of recursions. It is trivial to extend the code to those having more bits in each codeword.
startshape MARINER{color}
rule CODE0{
SQUARE{x 0 y 0 h 0 sat 1 b 1}
}
rule CODE1{
CODE0{x 0 y 0}
CODE0{x 0 y 1}
CODE0{x 1 y 1}
CODE0{x 1 y 0 h 180 sat 1 b 1}
}
rule CODE2{
CODE1{x 0 y 0}
CODE1{x 0 y 2}
CODE1{x 2 y 2}
CODE1{x 2 y 0 h 180 sat 1 b 1}
}
rule CODE4{
CODE2{x 0 y 0}
CODE2{x 0 y 4}
CODE2{x 4 y 4}
CODE2{x 4 y 0 h 180 sat 1 b 1}
}
rule CODE8{
CODE4{x 0 y 0}
CODE4{x 0 y 8}
CODE4{x 8 y 8}
CODE4{x 8 y 0 h 180 sat 1 b 1}
}
rule CODE16{
CODE8{x 0 y 0}
CODE8{x 0 y 16}
CODE8{x 16 y 16}
CODE8{x 16 y 0 h 180 sat 1 b 1}
}
rule CODE32{
CODE16{x 0 y 0}
CODE16{x 0 y 32}
CODE16{x 32 y 32}
CODE16{x 32 y 0 h 180 sat 1 b 1}
}
rule MARINER{
CODE32{x 0 y 0}
CODE32{x 0 y 64}
CODE32{x 64 y 64}
CODE32{x 64 y 0 h 180 sat 1 b 1}
}
Actually, this is a topic you could write further about - maybe I'm the only one missing the point, but the mariner inversion stuff you're talking about only raised interrogations in me.
Still, this code starts with contrasted lines, then goes on with grey goo as expected, and eventually produces a black rectangle - this final step is surprising (maybe a bug ?) :
startshape scene
rule scene {
totoBW { }
totoCOLOR { x 1}
}
rule totoBW {
SQUARE { }
totoBW [ s 1 0.5 y -0.5 b -1]
totoBW [ s 1 0.5 y 0.5 b 1]
}
rule totoCOLOR {
SQUARE { b 1 sat 1}
totoCOLOR [ s 0.5 1 x -0.5 ]
totoCOLOR [ s 0.5 1 x 0.5 hue 180]
}
Last edited by lagroue on Wed Aug 03, 2005 5:38 am, edited 2 times in total.