Generative Art - Assignment six

Due: 2014-01-15 10:30a

Objectives

[15 points] Flow

The outcome of this assignment will seem very familiar – you’ve been staring at my version of this assignment in the margins of every webpage on the course site. These two examples are the same sketch with different scales applied to the noise.

Assignment6

Assignment6b

This exercise requires an interesting mix of noise and agents. In the noise field example that I gave you, we visualized 2D noise by sampling with the noise() function and using the result to color in squares. I want you to continue to imagine the canvas being mapped to this collection of random-ish numbers between 0 and 1, so every location has a different number associated with it. However, this time, instead of using that value for a color, we are going to interpret it as a direction.

Now, imagine our ant being dropped down onto the canvas. At every location, it can look down at an arrow on the floor which tells it which direction to go next. Since the directions have a direct correspondence to the locations on the canvas, any two ants that step on the same location will then follow the same path from that point on. This is what causes those strong paths through the space. Those are the “expressways” – points that funnel all of our ants onto the same path.

Build the agent

The first step is to build your agent (or ant, if you prefer). The agent has some basic state information that it needs to keep track of: the x and y coordinates of its current location, and the size of the steps that it takes. We are going to vary the size of the steps to keep our agents to falling into expressways too rapidly.

The constructor should set these to be reasonable values. Set the x and y values to be some random locate on the canvas, and make the step size be some random number between 1 and 10 (or something along those lines – feel free to experiment).

Write an update() function that calculates a new position based on the current location, draws the line between the two points, and then updates the agent’s position. This is very much like the drunken ant. The main difference is that we will use noise() to determine the angle that the agent is facing. Pass the current x and y values to the noise function. Like the noise field example, we will want to scale these inputs down by some significant factor. Add a variable at the top of the sketch to control this and multiply both x and y by it when you use them as inputs to the noise function. Since we want to use this random number as a direction, you will need to scale the result to get values between 0 and 2π.

Now you can calculate your next position. Do this the way we computed points on a circle, using sin() and cos(). The radius of the circle is the step size you are using for the agent. This will give you a new x and y. Draw a line from the old location to the new point you calculated. Then update the position of your agent to the new location.

Finally, if the agent wanders off screen, generate a new point at random and plop it down there. You can play the same trick we did with the ant and “wrap the screen”, but you will find that if you do eventually all of your agents will wind up on the same expressway.

Everything else

The agent is the hard part, and it is largely just the ant from the previous assignment. Almost everything else comes from emergence and scale.

At the top of the sketch, create a new array of type Agent. In setup(), initialize the array to hold some very large number of agents (as in thousands). Use a for loop to populate the array with new Agent objects. Then, in draw, you will iterate through the agents and for each one, you can call its update() function.

Have some fun

As usual, I want you to take a little time to play with this example. Obviously, much of the effect comes from lots of agents wandering around with very low alpha values. Experiment with the colors. Your agents might even all be colored differently. You can do this by generating some random number in the constructor and then setting the stroke before you draw the line to that value. You could also generate another random number that determines color based on location. This could be at the same noise scale as the direction or not. Different agents could operate on different noise scales. You could break into 3D noise and give different agents different noise layers. Another possibility is to use the partially opaque black rectangle trick that I showed you a couple of classes back to gradually fade out the old lines. This will keep your sketch looking very dynamic. There is a lot you could do to this, so have some fun.

Naming your sketch

I would like you to name the sketch using this pattern: username_hw6.

Take a picture

Play with the distance and the coloring (and anything else that strikes you), and then please use the code I gave you in assignment 2 to take at least one picture of some state of your sketch that you like. Name it using the pattern username_hw6-####.png.

Documentation

Don’t forget the documentation block below at the top of your sketch. Make sure that you specify what you did that was cool and interesting.

/**
Assignment Six

A description of the sketch.

Your name
The date
**/

Turning in your work

I would like this code turned in in the DROPBOX on MiddFiles. You can refer to the reference on the LIS wiki to help you connect to the file server.