Friday, November 21, 2008

Cellular automata lace

Hi folks!
This is an idea I'd been vaguely intending to develop for quite a while, but didn't get around to seriously implementing until last week.
So, a cellular automaton is a rule for taking a grid of binary numbers, and generating a new grid in which the value of each entry is determined by the previous entry in the same and adjacent squares. So, if you take a 1-dimensional cellular automaton, it takes a row of 1's and 0's, and makes a new row, and each entry is determined by the entry above it and it's two neighbours. They're extremely simple, but they can produce some suprisingly complex patterns.
My idea was to use this to generate lace patterns - the 1's represent holes, the 0's plain stitches. There are some technicalities to overcome - lace knitting has left- and right-leaning holes, and while you could just pick one and apply it everywhere, I wanted something which would reflect the way digits 'travel' in CA patterns, so that you would arrive at a pattern of left and right travelling lines, meeting, annihilating, generating new lines. You can do this in a reasonably canonical ways - by looking at the three digits on the previous row you can more or less say it's heading left or it's heading right. There are some cases where a choice needs to be made though, so I just choose these. This loses some of the generality, but isn't too bad.
Having made these choices, I wrote a short program to choose a cellular automata 'rule' at random, pick some starting conditions, and apply the rule to generate a pattern. A second program then looks through the 1's this gives, and by looking at the arrangement above them translates this into a pattern of K, YO, K2tog and SKP stitches. Putting the output of this into a spreadsheet then gives you a lace pattern, and best of all, this is all entirely automatic. One such spreadsheet is here(for now- may need to move that at some point). (alternate rows are plain)

There's a couple of problems - this particular pattern involves a lot of double yarn overs. I'm told you can manage this by working K1 P1 on the alternate row, but I suspect it may be neater to write a quick program to look through the pattern and eliminate these - I think that wouldn't obscure the pattern and might need to a nicer finished piece, as well as easier knitting. So I need to try those out and see which solution I prefer.
The other problem is that there aren't that many 1D cellular automata, 16, by my count. While CA were very much the motivation for doing this, I kind of feel that sticking with them is selling the lace pattern generating half of the programme a bit short - it could apply equally well to any binary grid. So while this is a good starting point, I'm thinking about maybe inventing some slightly more elaborate generating rules - a quick way would be to allow a block to be decide by the five blocks above it, or the previous two time steps. Another approach I'd like to try would be to replace the binary grid with trinary, which would give a much wider family of rules, then map all the 2's back to 1 to produce a grid to feed into the lacing programme.

So yes, let's to play with. I particularly wanted to mention this because there was an extremely timely xkcd comic about cellular automata. In fact, I think the CA he's talking about simulating the universe with there may well be the same one in my lace pattern, though I haven't looked too closely.

So, anyone for an extremely geeky shawl?

Thursday, November 13, 2008


Ok, just a quick post cos I realise I haven't written anything here for months.
So, I decided to make some roses for a rose-loving friend. I had a fiddle around with a couple of rose patterns, particularly a nifty one from Knittiana which involved twisting your knitting to form petals(I love that about knitting - that whatever you can possibly do wrong, someone somewhere will have found a use for). But I couldn't make them come out how I wanted, they all looked kinda rose-ish, rather than actually like a rose.

Then I came across a great crochet pattern for them from RS Island crafts, which was very simple and turned out really well. I haven't done much crocheting, so I was very impressed with how well this turned out, and heartily recommend the pattern.
I did have some trouble with the sewing up, particularly attaching the stems to the flowers, but that's probably me just now knowing how to sew.

So yep, there's some roses! Should be getting back to posting soon, I have a project or two underway that I've been too busy to blog yet.

Happy knitting!