2016 Eggs

IMG_1064

This year, I’m using a new drawing app that I’ve been working on to generate files to load into Inkscape and draw using the Eggbot. In general the app processes an image file and creates an SVG based on it. These are several different renderers. The four eggs above are the most abstract. The algorithm draws wandering lines based on the brightness values of pixels in the image.

The image below uses a hatching program that can be quite photo realistic. I have not yet drawn it successfully using the Eggbot and sharpies. I did manage to draw it with pencil, only to have it smear off the eggshell.

Screen Shot 2016-03-20 at 7.16.45 PM

Eggbot eggs 2015 : genetic algorithm

IMG_0693

This year’s addition to my eggbot programs is a genetic algorithm that evolves complex sine waves. Each of the eggs in the photo above was printed from the same program with waves evolved from random seeds.

The individual designs

Each design is a sine wave with eight different parameters:

  1. Amplitude
  2. Length
  3. The number of waves to be strung together
  4. Amplitude of the first modulation applied to the amplitude
  5. Length of the first modulation applied to the amplitude
  6. Amplitude of the second modulation applied to the amplitude
  7. Length of the second modulation  applied to the amplitude
  8. The modulations to be used (either 1 or both 1 & 2)

The video above shows how the 8 parameters modulate the wave and how patterns build up over time.

How the genetic algorithm works

Each time the program is run, an initial population is created with 50 individual designs — each with random values assigned to the eight parameters. You then rate each individual design before evolving the next generation. The algorithm chooses individuals to carry on to the next generations (highly rated designs are more likely to be carried forward, but low rated designs may still be used).

Designs that are carried forward are likely to be bred with other designs chosen for the next generation. Breeding involves picking a random integer N between 1 and 8 and taking the first N parameters of one individual and swapping them with the first N parameters of the other. This cross-over of the parameters creates new variations of the designs with qualities of both individuals (the parents). There is also a slim chance that one or more of the child’s parameters will change (mutate) between generations.

The evolution process makes it relatively easy to search through a very wide range of possible combinations of parameter values by simply choosing designs with aspects that you like and seeing what different combinations of these qualities look like.

I found that populations of 50 individuals are broad enough to get very interesting results in fewer than 10 generations while not having to rate too many design with each evolution.

The output

Below is a collection of 10 different designs generated in the same session.

Untitled 3

Each column in the image above shows the lineage of the design in the top row. This top row is the 5th generation. The next row down is the highest rated parent from the 4th generation. Coincidentally, neither of these designs were changed between the 3rd and 4th generation.

The code

The program is written in processing and the source is available on github.

The algorithm is not limited to sine waves. To implement your own design, modify the Indivdual.pde file with any number of parameters. All my parameters are floats between 0 and 1, but this is not a requirement so long as you adjust your this class’ mutate function to fit your variable types.

The other classes in the repository set up the UI and manage the evolution or individuals over multiple generations. You may choose to manipulate the following three variables in GA_eggbot.pde to work with different population sizes and different probabilities for crossovers and mutations.

Screen Shot 2015-04-06 at 11.17.39 AM

If you do make a design of your own, let me know in the comments below.

Eggs 2014

Image

Sine waves were a popular choice for this year’s eggs. And the Minecraft pigs were in demand as always.

All the eggs pictures except the pigs were plotted directly from Processing, the pigs were drawn using Inkscape.

I’ll post the files to Github within  a couple weeks.

update: code and svg files are now available on Github.

eggs

This year’s eggs were designed using Nodebox and Inkscape.

Charlie worked mostly in Nodebox. It’s patch-based programming was right at his level and copy, rotate and wiggle all got a lot of action.

Wyatt found inspiration in Minecraft and we worked together to write a letter writing script in Python to print out an wiki entry on egg. Then he created a vector version of the pixelated egg in Inkscape.

The video below shows some highlights from production.

First attempt to control eggbot from Flash: halftone pictures

This weekend, I was able to get Flash talking to the EiBotBoard of my Egg Bot via Tinkerproxy 2.0. Fun stuff.

The trickiest part was finding the right file within /dev to point Tinkerproxy at. The EiBotBoard shows up as /dev/cu.usbmodemNNN which is quite different from the way an Arduino board shows up.

With the proxy in place, I set up a Flash file to load images, transform them into halftone dot patterns and then plot them onto eggs. Plotting is done with 3 different commands, one to raise and lower the pen, one to turn the egg (xaxis) and the last to move the pen (yaxis).

First attempt to control eggbot from Flash: halftone picturesFirst attempt to control eggbot from Flash: halftone pictures 2