Random Walker

Published January 28, 2018

I wanted to explore how the random walker could be used to create or destroy an image. Could a series of seemingly random actions coalesce to become a coherent whole? I wanted to pull an image into its constituent units, and have those units each move independently of each other, finding their position in the image through a seemingly random path. At first, I gave each walker a destination position in addition to their random starting location. As each walker came close to its destination, it would stop (and change color). It is shown below (with source image in green):

This sort of worked, but because I could not be assured that the walker would reach its destination in a timely manner, I decided to “cheat” randomness and give each walker a predestined fate. I did this by generating each walker at its destination x,y point and running its timeline in reverse before the sketch began. Then, the walker would run forwards through a series of steps (saved in an array) to arrive at its origin / destination:

class Walker {
		this.x = x;
		this.y = y;
		this.steps = [];

        // generate random number of steps so walkers don't 'land' simultaneously
		for (let i=0; i<floor(random(100,800)); i++){

		ellipse(this.x,this.y, 8,8);

		if (this.steps.length > 0){
			let	{x,y} = this.steps.pop();
			this.x = x;
			this.y = y;

		let r = random(1);
		let stepSize = 5;
		if (r < 0.25){
			this.x += stepSize;
		} else if (r < 0.5){
			this.x -= stepSize;
		} else if (r < 0.75){
			this.y += stepSize;
		} else {
			this.y -= stepSize;
		this.x = constrain(this.x,0,width);
		this.y = constrain(this.y,0,height);
		this.steps.push({x: this.x,y: this.y});

To further explore having an image fall apart, I would like to create a series of random walkers which come together to form a 3d point cloud of a recognizable object. Each of these walkers could scatter from a nearby mouse, before following a seemingly random path back home to their position in the cloud. I began on this with a simple 3D random walker: