The Nature of Code
- Spring 2011
- Section 1: Tuesdays 12:30 - 3:00 pm
- Section 2: Wednesdays 12:30 - 3:00 pm
- Daniel Shiffman, email@example.com
- Office Hours Signup
Week 1 -- Jan 25/26 -- Numbers and Vectors
- Class Intro / Overview
- Processing review
- Randomness, Probability, and Perlin Noise
- Object Oriented Programming Review & Vectors
- Assignment: Sign up for the class mailing list: firstname.lastname@example.org
- Assignment: Take a look at these two examples of a square randomly moving around the screen: Walker without vectors, Walker with vectors. Find an example of real-world "natural" motion and develop a set of rules for simulating that behavior. Ideas: nervous fly, hopping bunny, slithering snake, etc. See if you can avoid using randomness, or at least consider your use of random carefully and justify it. Consider the challenge of usual minimal visual design, i.e. only grayscale primitive shapes. Can you give your "being" a personality? Can it express emotions -- happiness, sadness, fear, etc.? Post a link to your work, as well as any thoughts on the above, on the homework wiki.
- Reading: Processing PVector tutorial, also available as PDF.
- PDF Handout about probability (available via course mailing list)
- Mathematics and Physics for Programmers, Chapter 5 -- Vectors, Danny Kodicek
- Reading: Computational Beauty of Nature, Introduction, Gary William Flake (you must be logged in through NYU to access the online version.)
- Reading: Probability Theory -- great friendly site!
Week 2 -- Feb 1/2 -- Vectors and Forces
- Object Oriented Programming Review & Vectors
- Core examples
- Supplemental reading:
- Homework (choose one / create your own) Post your work on the wiki:
- Rework your motion sketch from week 1 using PVector. Try incorporating the concept of forces into the environment by affecting only the acceleration. Create a formula for calculating a dynamic acceleration, one that changes over time based on any number of factors. Make more than one object by creating an array.
- Create an example where instead of objects bouncing off the edge of the wall, an invisible force pushes back on the objects to keep them in the window. Can you weight the force according to how far the object is from an edge, i.e. the closer it is, the stronger the force?
- Create pockets of air resistance / friction in a Processing sketch. Try using circles instead of rectangles, i.e. pockets of mud (or ice). What if you vary the strength (drag / friction coefficient) of each circle? What if you make some of them the opposite of drag—i.e., when you enter a given pocket you actually speed up instead of slow down?
- Can you create an example where all of the Mover objects are attracted to the mouse, but repel each other? Think about how you need to balance the relative strength of the forces and how to most effectively use distance in your force calculations.
- Research a force not covered in class and implement it as a vector.
- Use the concept of forces to visualize some input (could be data, literal example would be get windspeed online and translate to a wind force in Processing, but feel free to think more abstractly)
Week 3 -- Feb 8/9 -- Oscillations
- (First, continuation of Forces)
- Polar vs. Cartesian Coordinates
- Graphing waves (perlin noise waves)
- 2D trig equation graphing ("graphing inequalities")
- Core examples
- Supplemental Reading:
- Assignment: Incorporate oscillatory motion into a previous assignment (or create a new one). Some suggestions:
- Create a simulation where objects are shot out of a cannon. Each object should experience a sudden force when shot (just once) as well as gravity (always present). Step 2. Add rotation to the object to model its spin as its shot from the cannon. How realistic can you make it look?
- Create a moving body with a shape made from oscillating parts, i.e. the object moves according to the usual vector motion, but its shape incorporates oscillation around its center point. Consider tying the speed of oscillation to the speed of motion. Think of a butterfly’s flapping wings or the legs of an insect. Can you make it appear that the creature’s internal mechanics (oscillation) drive its locomotion? Example Answer
- Research and implement a simulation of Torque.
- String together a series of pendulums so that the endpoint of one is the origin point of another.
- Create an example that simulates a box sliding down an incline with friction. Note that the magnitude of the friction force is equal to the normal force.
- Rework the wave examples to have a Wave class and visualize the wave using something other than circles. Example Answer (minus the change in visualization)
- Using the Spring example as a basis, create a system of multiple bobs and spring connections. How would you have a Bob connected to a Bob with no fixed anchor?
Week 4 -- Feb 15/16-- Particle Systems
- Advanced Object Oriented Programming -- Inheritance and Polymorphism
- Examples and tutorial
- Supplemental Reading
- Homework exercise -- At this point we're a bit deeper in the semester and approaching the midterm project. Feel free to simply start on a midterm idea or continue something you've been working on previously. If you are stuck as to what to do, here are a few exercise suggestions:
- Use a particle system in the design of a "Mover" object. In other words take, say, one of our earlier examples and instead of rendering a Mover object as a simple circle, emit particles from the mover's location. Consider using the Asteroids example and emit particles from the ship when a thrust force is applied.
- Create a particle system where the particles respond to each other via forces. For example, what if you connect the particles with spring forces? Or an attraction / repulsion force?
- Model a specific visual effect using a particle system -- fire, smoke, explosion, waterfall, etc.
- Create a simulation of an object shattering into many pieces. How can you turn one large shape into thousands of small particles?
Week 5 -- Feb 22/23 -- Physics Libraries!
- Box2D tutorial: http://www.shiffman.net/teaching/nature/box2d-processing/
- Box2D particle System: http://www.shiffman.net/itp/classes/nature/box2d_2010/liquid
- Google code repository: http://code.google.com/p/pbox2d/
- Reading: This isn't terribly exciting, but read the Box2D manual. It's actually quite helpful for the concepts (you can ignore the code and focus on our class examples instead.)
- Homework: Work on midterm project due to present Week 7. Your midterm assignment should build off of the concepts we've covered this first half of the semester, however you should feel free to think non-traditionally, i.e. your midterm need not simply be a Processing sketch. Please include both visual and text documentation of your project, i.e. you might include a short paragraph description, links to relevant projects, video documentation, screenshots, or online applet, etc. The midterm need not be a finished project, it is useful to use this time to build out a single component of a larger idea. If you are stuck, some midterm suggestions are:
- Extend one of the examples into 3D
- Design a single creature (that you imagine living in a larger eco-system).
- Develop a non keyboard/mouse way of interacting with an environments' forces (i.e. video tracking, sensors, etc.)
- Use physics simulation to fabricate something -- a print, a sculpture, etc.
Week 6 -- Mar 1/2 -- More Libraries, Steering Behaviors
- Toxiclibs tutorial: http://www.shiffman.net/teaching/nature/toxiclibs/
- Connected systems (using toxiclibs): http://www.shiffman.net/teaching/nature/toxiclibs/
- A bit more on inheritance + interfaces
- Autonomous Agents and Steering Behaviors
- Supplemental Reading
- Assignment: Complete midterm project, post link to wiki and be prepared to present next week. Please note again this doesn't not need to be a fully realized project. In addition to whatever prototype implementation you preset, I encourage you to use drawings, images, video, and text to describe your idea
Week 7 -- Mar 8/9 -- Present Midterm
Week 8 -- Mar 22/23 -- Complex Systems
- Self-Organization Craig Reynolds' Boids -- Alignment, Cohesion, Separation
- Reading: Chapter 15, Cellular Automata, Computational Beauty of Nature, Flake
- Reading: Chapter 16 — Autonomous Agents and Self-Organization, The Computational Beauty of Nature, Gary William Flake,
- Reading: Conway's Game of Life, Scientific American, 1970
- Reading: Exploring Emergence, Mitchel Resnick and Brian Silverman Epistemology and Learning Group MIT Media Laboratory
- Reading: From Ants to People, an instinct to Swarm
- Assignment: Choose one of the following options or create your own.
- Develop your midterm project one step further based on class feedback / discussion.
- Using the flocking example as a model, develop your own set of rules for boid interaction.
- Implement Flake's "View" rule, described in Computational Beauty of Nature
- Create a flow field that changes over time
- Create a flow field based on image data
- Use applyForce() in Box2D or addForce() in Toxiclibs to create a flocking simulation in one of those physics engines
- Combine the concepts of Cellular Automata with the flocking example -- what happens if you assign each boid a "state" which influences its behavior?
- Consider the state of a cell to be its color. What types of image processing filters can you create using the principles of Cellular Automata?
- Develop your own rules for a Cellular Automata, 1D or 2D. This could be something completely made up or a simulation of real-world phenomena. For example, forest fires: [http://en.wikipedia.org/wiki/Forest-fire_model] or Predator, Prey [p. 191 of Computational Beauty of Nature.]
- Develop an alternative "Game of Life" with time as factor, i.e. what does it mean for a cell to be "alive" or "dead" for many frames in a row.
Week 9 -- Mar 29/30 -- More Complex Systems + Self-Similarity
- Wolfram CA, The Game of Life
- Fractals, MandelBrot Set
- Reading: The Computational Beauty of Nature, Gary William Flake, Chapter 5 — Self-Similarity and Fractal Geometry, Chapter 6 — L-Systems and Fractal Growth
- Reading: Algorithmic Beauty of Plants -- suggested
- Watch: Nova: The Hidden Dimension
- Assignment: Sign up for a final project proposal and presentation slot. Include in your proposal a title, brief description, and links to things you want to show / talk about -- work that inspired you, reference pages, sketches you've made, sample programs/code, previous projects, etc. Tues, Wed
Original Week 10 -- Apr 5/6 -- CANCELLED!!!
Week 10 -- Apr 12/13 -- Final Project Proposals
- This week will be entirely final project proposals. Schedule is here: Tues, Wed
Week 11 -- MAKEUP SESSION -- Friday, Apr 15, 12:30 - 3:00 PM or Monday, April 18, 2:30 - 5:00 PM -- Genetic Algorithms
- In this make-up session, I will finish off our discussion of fractals and present on Genetic Algorithms. It doesn't matter whether you are in the Tuesday or Wednesday section, you can pick whether you prefer to attend Friday or Monday. Please sign-up on the make-up wiki so that I get a sense of how many people will be coming to each session. MakeUp Wiki Schedule
- Interactive evolution
- EcoSystem Simulation
- Reading: The Computational Beauty of Nature, Gary William Flake, Chapter 20 — Genetics and Evolution
- Reading: Evolved Virtual Creatures, Karl Sims, Siggraph 1994
- Reading: Artificial Evolution for Computer Graphics, Karl Sims (ACM SIGGRAPH ‘91 Conference Proceedings, Las Vegas, Nevada, July 1991.)
Week 12 -- Apr 19/20 -- Neural Networks, Remaining Final Project Proposals, and misc. workshop time
Week 13 -- Apr 26/27 -- Final Project Presentations
Week 14 -- May 2/3 -- Final Project Presentations
Students are required to complete a programming exercise each week. Documentation for each assignment should be posted to the linked wiki page.
Requirements: (no incompletes)
- 50% homeworks
- 30% final project
- 20% class participation, attendance