p5js Boids

Okay, sketch 2: Boids!

The basic idea is to create a bunch of particles (the Boids in this case) and apply to them each a series of simple, limited rules that rely neither on communcation between the Boids nor a global controller and see what behaviors you can generate. Specifically, can you replicate the flocking behavior found in birds, since birds can obviously fly together without hitting one another and also without some lead bird giving orders.

Something like this:

For this case, there are three rules:

  • seperation - Fly away from any Boids that are too close to you (to avoid collision)
  • alignment - Align yourself to fly in the same direction as any Boids in your field of vision
  • cohesion - Fly towards the center point of the Boids you can see

read more...


p5js Worms

One thing that I’ve been hoping to get into a bit more is the idea of Generative Art. Essentially, use any of a wide variety of algorithms to generate art. To do that, and so that the art can be generated right in front of you in the browser, I’m going to use the p5js library. It gives you a nice API of graphical primitives and takes a simple setup and draw function and does the rest.

read more...


AoC 2017 Day 21: Fractal Expander

Source: Fractal Art

Part 1: Start with an input image made of . and # pixels. For n iterations, break the image into blocks:

  • If the current size is even, break the image into 2x2 chunks and replace each with a 3x3 chunk
  • If the current size is odd, break the image into 3x3 chunks and replace each with a 4x4 chunk

The replacement rules will be specified in the following format (example is a 3x3 -> 4x4 rule):

.#./..#/### => #..#/…./…./#..#


> In that example, replace this:

> ```
.#.
..#
###

With this:

#..# …. …. #..#

read more...


AoC 2016 Day 17: Md5 Maze

Source: Two Steps Forward

Part 1: Create a 4x4 grid of rooms with doors Up, Down, Left, and Right from each location. To determine if a door is currently open:

  • Calculate MD5(salt + sequence) where sequence is a string containing any combination of UDLR depending on how you got to this room
  • The first four hex values represent the doors Up, Down, Left, and Right respectively: bcdef means open; anything else is closed

Find the shortest path from (0, 0) to (3, 3).

read more...


AoC 2016 Day 16: Dragon Data

Source: Dragon Checksum

Part 1: Generate noise using a modified dragon curve:

  • Start with data a
  • Create a copy of the data b, reverse and invert it (0 <-> 1)
  • Create the string a0b

Repeat until you have enough data, truncate at the end if needed.

From this string calculate a checksum as follows:

  • xor each pair of bits, concatenate the results
  • If the resulting string has an even length, repeat; if it’s odd, stop

Calculate the checksum of a given initial state expanded to 272 bits.

read more...


Fractal Invaders

Today’s post is a follow up to Sunday’s post Procedural Invaders. This time around, we’re going to work through two different space filling algorithms in order to eventually generate something like this:

read more...


Procedural Invaders

Today’s post comes from a long line of ‘inspired by posts’ all pretty much leading back (so far as I can tell) to this post by j.tarbell: invader.procedural from 2003.

The basic idea is that we want to generate ‘invaders’ in the style of space invaders. Except we don’t want 10 or 20, we want tens of thousands. So how do we do it? Well, take a look at this:

read more...