## How to Grow a Painting With Generative Art

What if you could plant a “seed”, and grow a painting? Surely that would save the artist a lot of trouble learning pesky things like how to draw.

As it turns out, such a thing is possible. Computer generated artwork is nothing new. Who could forget Dire Straits’ Money for Nothing?

And, of course, my own blog gallery is full of digital artwork.

But with digital painting and drawing, the computer is simply another tool, like a paintbrush or charcoal stick, used to create an image.

I’m proposing we step away from that, and let the computer take the creative reins.

It’s an application of genetic programming.

If you’ve never heard of genetic algorithms and evolutionary programming, the idea is to apply the concepts of evolution and “survival of the fittest” to solve problems in mathematics and computer science.

To solve a problem, you consider potential solutions to be “organisms.” As organisms, solutions mate and produce offspring. “Organisms” which represent better solutions are given a higher chance of mating. After several generations, you should have a fairly good set of solutions.

A classic example of an application would be the traveling librarian problem.

Suppose your local librarian had to deliver books to all five of her branches. In which order should she visit the cities so that she travels the fewest miles?

View Larger Map

In this example, the solution is represented as the permutation of five towns

Solution 1 “gene” = { Warsaw, Faison, Beulaville, Rose Hill, Magnolia}

and represents a total journey of 76.3 miles.

The permutation below represents a total journey of 90.0 miles.

Solution 2 “gene” = { Faison, Rose Hill, Beulaville, Magnolia, Warsaw }

Let’s suppose these two “organisms” are selected to mate. Just like human children inherit their parents’ eyes, hair, etc. These “children” can inherit their own parents’ properties.

To produce the children, we can apply a “reorder crossover” on the last three towns.

Solution 1 has Beulaville, Rose Hill, Magnolia as the last three towns. In solution 2, they appear in the order: Rose Hill, Beulaville, Magnolia.

To produce the first child, we take solution 1 and reorder these last three towns so that they appear in the order the mate, solution 2, has them in. The first child is:

Child 1 “gene” = { Warsaw, Faison, Rose Hill, Beulaville, Magnolia}

Solution 2 has Beulaville, Magnolia, and Warsaw as the last three towns. In solution 1, they appear in the order: Warsaw, Beulaville, Magnolia. The second child is:

Child 2 “gene” = { Faison, Rose Hill, Warsaw, Beulaville, Magnolia}

Child 1 ends up representing a distance of 82.9 miles. Child 2 ends up representing a distance of 90.2 miles.

View Larger Map
Child 2 never lived up to its parents’ expectations.
They wanted him to be a doctor. He went into ventriloquism.

Neither children were as successful as their parents. In the next generation, they’ll be less likely to mate.

This is due to what is called the fitness function. The job of the fitness function is to assign to each solution a chance of mating. A simple one for the traveling librarian problem would be to divide 100 by the distance traveled, so that shorter trips have a higher chance of surviving to the next generation.

The idea is to identify traits that yield good results, and try to create solutions that take on those traits.

In our problem, Magnolia and Rose Hill are near each other. Solutions that place these towns next to one another are more likely survive to the next generation, just like real organisms develop traits that aid in their survival in the wild.

So what about art? A popular way to create art on a computer is to apply transformations, functions which alter the image. As a quick example, consider this drawing of Agreeable Andy:

“I don’t want to be an example!”

And three functions: “Rotate by 90 degrees”, “Flip horizontally”, and “Color the left half red.”

Depending on the order we apply them to Andy, we get a different result:

“Get me off this thing!”

Look familiar? Each drawing is the product of a permutation of functions. Each permutation can be an “organism.”

The organisms are:

S1 = { Horizontal flip, Rotate 90 degrees, Left half red }

S2 = { Left half red, Rotate 90 degrees, Horizontal flip }

Now all we need is a fitness function, something to determine which qualities are desirable.

Oh, it turns out computers aren’t all that great at having these kinds of preferences.

But you are! All you need is a program that presents you with art. You select which ones you like, and the program will eventually identify which qualities you like. You get to play nature, selecting which “creatures” are most likely to survive.

Such a program exists, too. If you want something to play with, go download Evolvotron. It produced the image at the top of this post.

Evolvotron screenshot.

The screenshot above shows the program at launch. The images are fairly simple, but if you keep at it long enough, you can generate some intricate and complex ones.

I don’t see why generative art needs to live entirely in the realm of the abstract. If it’s not out there already, I don’t think it’ll be too long before someone thinks of combining Evolvotron with, say, Makehuman.

“Evolved art” raises an interesting question, though. Who is the artist? See the image at the top of the post? I didn’t really do anything to make it. I didn’t do the work involved in painting the image. I didn’t even write the program.

On the other hand, the image wouldn’t exist if it weren’t for me.

Am I the artist merely because I have an eye for a particular result? What do you think?

## Mathematics vs. Nature for People Who Hate Math

… For People Who Hate Math is the worst title for a feature on this blog. If you hate math, why are you reading this?

Maybe you were searching for pictures of cats, and came upon this page by mistake because the universe is out to get you. In that case, I hope this cheers you up.

Or, maybe you don’t really hate math, but understanding what the gist of it is just proved rather elusive. In that case, this week’s post is just for you.

Mathematics is different from the other sciences. If you take a chemistry course, you can see the power of chemistry on the first day. On my first day of chemistry in high school, my teacher explained how there was enough chemical power in the storage room to level the building, should terrorists attack. Note that these were the pre-9/11 days.

I’m not sure how reducing the building to rubble before the terrorists could was a viable anti-terrorist strategy. But in Texas, we just didn’t question these things. Then she set the ceiling on fire.

Chemistry!

But what of mathematics? Chemistry is hard. From day one, though, I had at least a general idea of what we were after. We were seeking a better understanding of real, observable events. Math, on the other hand, seemed like just an arbitrary set of made-up rules.

There’s a good reason for that, too. Math is an arbitrary set of made-up rules.

This is a common question I hear: Where does ___ arise in nature? The answer, more often than not, is “it doesn’t.”

Case in point, 2 + 2 can equal 5. All you need to do is change the rules, which isn’t that hard to do since they were all made up in the first place.

There’s no natural reason 2 + 2 must equal 4. There is a practical reason. We use mathematics as a language. Just like we use the word cow to describe a large, horned animal that serves as the butt of many Far Side cartoons, we use the word two to describe the quantity of cats currently whining at me for their lunch.

The rules that people learn when they take a class like Algebra were designed for a purpose. There’s no reason they can’t change.

The difficulty in learning math is that not only is it a set of rules, it’s a very complex set of rules, all dependent on each other.

For example, let’s take a clock – and see how this simple device unravels almost everything you learned in elementary school.

We’ve all known for a while that any number, added to zero, is itself. So if you take the 4 position on a clock, advance the hour hand 12 spaces, it’s back to 4. Hence, on a clock,

$4 + 12 = 4$

But 4 + 0 = 4. This means 0 and 12 are the same numbers.

This completely messes up multiplication. Now $4 \times 3 = 0$. It also messes up division. $4 \times 5 = 20$, but since 20 = 8 + 12, and 12 is the same as 0, then 20 also equals 8 + 0.

So $4 \times 5 = 8$.

It gets worse. Try to divide both sides of that equation by 5, and you’ll see the “fraction” $\frac{8}{5}$ equals 4.

But it turns out you can’t really do that – not because it seems strange. There are stranger looking things that turn out to be valid. No, it turns out we completely obliterated the concept of division itself.

The concept of division itself is built upon rules that we just threw out. Whoops. Who needs multiplication and division, anyway?

The science of mathematics is in figuring out what happens when you change the rules, or add new ones. The catch is that, unlike chemistry or physics, mathematics is a beast mankind created. That’s right. We did this to ourselves.

The difficulty in learning math is that there isn’t much that arises out of nature to help you. The chemists who first cracked the secrets of fire had easy access to all the samples they needed. The physicists who determined the physics of falling objects had an ample supply of gravity at their disposal.

Everything in math arises out of something someone else had previously established.

Here’s another illustration. One of the most arbitrary constructions of them all – polynomials – comes out of a very small set of groundwork rules.

Polynomials don’t occur in nature, and nothing in nature seems to suggest the idea. But two simple man-made rules do.

Polynomials are members of a set of objects that adhere to two specific rules: Any two polynomials added together must be in the set, as well as any two polynomials multiplied together.

Let’s start with x. If x is in the set of polynomials, then x + x, or 2x, is in the set. This means x + 2x, or 3x, is in the set. So is 2x + 3x = 5x, 2x – 5x = -3x, etc. Following this logic, any multiple of x is in the set.

We can apply the same principle to multiplication. Since x is in the set of polynomials, the product of x and x is also in the set. So $x^2$ is also a polynomial.

But this means the product of x and $x^2$, or $x^3$, is a polynomial.

Don’t forget we can add any of these powers to themselves any number of times. Since $x^3$ is a polynomial, so is $2x^3$ and $31x^3$.

Finally, we can add all these multiples of powers. So $x + x^2 + 31x^3$ is also a polynomial. Every polynomial is constructed from multiples of powers of x.

Nothing in nature suggested we could do this. It was simply the product of saying, “let’s create a set and a couple of rules that its objects must obey, and see what happens when we run with it.”

If you’re in the crowd of “people who never saw the gist of mathematics,” try looking at the subject from the perspective of a game: learning how to play, given a set of rules printed on the back of the box cover.

When you get really good, or just bored, you can look at it from the perspective of that kid who had to change the rules so he’d always win. The changes didn’t always make sense to the observer, but that kid sure knew what he was doing.

## Author Obligations and the Millennial Generation

Like last week’s post, this week’s topic was suggested by my wife. For those not in the know: you, too, can suggest a topic. Almost anything that falls within the realm of “storytelling, art, and mathematics” is welcome – even if the fit is vague.

If you haven’t seen my “about me” page, I teach mathematics. I started teaching my senior year at The University of Tulsa. I was put in charge of what were called “quiz sections.” Some of you may have heard of “supplemental instruction,” peer-lead tutoring sessions which numerous colleges provide. “Quiz sections” were similar, although I was given the additional responsibility of administering quizzes. The novelty of grading papers lasted one day.

I was the same age as the students, and lived on campus. Both of these facts resulted in more than one amusing situations.

My geology lab partner was one of my students.

Every so often I’d bump into them at a party, where we’d learn we had mutual friends.

Except for the kid who dropped the class after one of these encounters, any initial awkwardness was swiftly eradicated by the realization, Oh! We have the same friends. And we’re the same age.

We’re even in the same clubs. My last year in Tulsa, I joined APO, which is a community service fraternity. A few of my students joined with me, and we’d work at the food bank and build houses for Habitat for Humanity together.

Then I graduated, moved to North Carolina, and grew older. Sometime over the span of the next four years, I managed to complete my doctorate. In my spare time, I aged a bit more.

One day, not too long ago, I realized I was now a different person. Then I realized I was wrong. I’m pretty much the same me. The students were different.

Sometime between 2004 and 2013, the world decided it needed to be constantly plugged in. Then it decided it no longer needed wires.

My “internet empire” was recently upgraded, but my art gallery still reflects the hand-crafted-HTML internet I grew up with. What happened?

I’m not that old. I was born in 1983. So whose generation am I in?

It turns out I’m in the gray area between Generation X and the Millennial Generation. I missed out on most of the events which shaped Generation X. But the information age blast that affects so many of the Millennials didn’t really hit me until I was almost in high school.

1996, the year of Space Jam and Dolly the Sheep, ushered in the end of pay-by-hour AOL. For the majority of my childhood, “online” meant HAL-PC, Houston’s local BBS. Next year’s collegiate freshman class had just been born.

For today’s eighth-grader, “online” means near-instantaneous access to just about every form of media imaginable. In the palm of their hands. If this doesn’t blow your mind, chances are you’re a Millennial.

Let’s play a comparison game. My childhood. Theirs. I don’t think we grew up out of the same world.

It’s not just access to information that has changed. Even more so, the role of creator has changed.

First, there’s the obvious: everyone can be a content creator. How do you think this blog got here? It wasn’t because I submitted my posts to a publishing agency that decided I had something worthwhile to say.

One day I decided I’m going to author a blog. Then I did. And if anybody doesn’t like it, I can stick out my tongue and go, pfffffffffffffttttttttttt, which used to be theme song of internet connectivity.

Second, the relationship between creators and consumers has changed. There’s a lot that can be said about this. Intellectual property and copyright is a dissertation in itself.

So I’m going to address a question my wife brought up at dinner last night.

Q: What obligations do authors have to their readers?

Both of us are in fields where there’s diminishing tolerance for being set in our ways. I was reminded of this late last semester, when I received an email from a student at 1 am. I didn’t respond until I woke up the next morning, after he already asked me why I didn’t reply.

I don’t think it’s such a horrible thing to not be available 24/7. People aren’t, but information is. At least, that’s what we’re now used to.

As for authors, and content creators in general, there’s less and less room for the person who produces work behind a curtain.

In a way, we seem to be heading back to the days of the storyteller, telling a tale before a crowd and a fire. These were the days when the audience had a personal connection with the creator. They were there. They could ask questions, discuss the story, or whatever else they wished.

I’d hesitate a bit to say the internet provides “personal connections,” but how many of you have tracked down the website of your favorite author so you could ask a question or find out a bit more about them? How many of you have looked for their Facebook, Google Plus, or Twitter page, only to be vastly disappointed to find out they had none of these?

If you were born after 1995, “the internet” has been a household name for just about your entire life. “If it’s not online, it probably doesn’t matter.” If it’s not the case now, eventually that line will be a death sentence for the hopes of anyone wanting to publish without an internet presence.

This isn’t a case of traditional publishing versus electronic publishing. Whatever media is bought, in whatever form, this is the case of the consumer’s growing desire to feel connected to the producer.

Popular books aren’t just books. They’re cultures. Think of the vast library of fan fictions associated with top novels. I had never heard of “fan fiction” until I got to college. Now, fan fiction is endorsed by Amazon.

Picking up a copy of, say, Harry Potter, was doing more than just selecting a book to read. It was an invitation to participate in a sub-culture.

Going forward, I expect to see the wall dividing the producer and the consumer continue to crumble. Lurking in the shadows will be increasingly difficult. The author will take more of the role of a performer, expected to interact with their audience.

What do you think? Are we headed to a new golden age of authorship and readership?

* * *

Speaking of interaction, let me say “thank you” to everyone who has submitted a solution to A Conundrum of Eggs 1. If you’re sitting on an answer, it’s not too late to submit one yourself!

Much like its inspiration, A Tangled Tale, the answers aren’t revealed until the end of the tale. Since A Conundrum of Eggs has three installments, this rule may need to be tweaked so that nobody has to wait until October.