Monday 6 November 2023

Music Therapy Book Illustration - self-avoiding random walk (Project queue = 3)

My daughter attends weekly music groups online, and the music therapist who runs them approached me and asked if I would collaborate on a book chapter that she has been asked to write. Given I am trying to be an artist, and trying to express myself visually, I thought it would be appropriate (and interesting!) to do so in the chapter, so I am trying to create an image that represents my experience attending the groups. After a lot of noodling, I decided I wanted to represent the connectivity they give my daughter and I (which is also a key theme in the book chapter). To do that, I decided to revisit an experiment I did a while ago to create branching organic shapes that fill a given space. My previous attempt struggled because the code to determine if branches overlapped wasn't reliable, and the algorithm also worked recursively, so it drew one whole 'branch' to the tip before moving to the next one, giving a result that looked like this:
So I decided to try a different approach, using instead a grid of 'cells' which can be occupied or unoccupied. Starting at a random point, I do a random walk selecting an adjacent unoccupied cell, until there are no unoccupied adjacent cells (typically because it has looped back on itself and got 'painted into a corner'). I think pick an occupied cell at random, and repeat the process. Over time I get a pattern that looks like this:
I am writing this up retrospectively, so it's only fair to say I spent a good few hours ironing out kinks, especially diagonal crossings - the basic algorithm didn't consider diagonals as 'blocking' so there were a lot of places where the line entered on one diagonal, crossed the top, and exited on the other diagonal, creating an 'X' shape. The solution being to consider diagonals as a special case, and forbidden one diagonal if the other was already 'occupied'.

No comments:

Post a Comment