My approach was the following: I create an object called a walker (create with mouseclick), whose main properties are a position, a direction, and a colour $\mathbf{c}_0$ (or rule). The walker has a list of locations in front of it from which it may sample the pixel colour. Each walker carries a cost-function $f=f(\mathbf{c},\mathbf{c}_0)$ whose value depends on the sensed colour $\mathbf{c}$ and its colour $\mathbf{c}_0$. Armed with the cost function, the walker is asked to change its direction towards the sensed location with minimal cost. One natural choice of cost-function is $f_{+}=|\mathbf{c}-\mathbf{c}_0|^2$, which measures the colour-space distance to its colour $\mathbf{c}_0$. This cost function is labelled philic. The opposite is a walker that walks towards the colour that is maximally different from its colour, i.e. $f_{-} = -f_{+}$ (phobic). There is also an option to change the definition of $\mathbf{c}_0$ (away from its colour self) to darkness (black), brightness (white) or any other preset colour (input). The locations in front are defined by an angular span (sensewidth) and a length (senselength).
Once the direction is updated based on the sensed pixel response, the walker steps toward its direction at a predefined, but somewhat fluctuating length. After moving, it interacts with a background colour mesh, either by smearing nearby pixels (the SMEAR option above) or pulling the pixel underneath it towards its colour $\mathbf{c}_0$.
I probably forgot to mention a lot, but I am confident you will figure things out. Have fun!