Skip to content

Instantly share code, notes, and snippets.

@kmaher9
Created September 9, 2018 00:16
Show Gist options
  • Select an option

  • Save kmaher9/2275c340000bea8b4350cbbb97e25572 to your computer and use it in GitHub Desktop.

Select an option

Save kmaher9/2275c340000bea8b4350cbbb97e25572 to your computer and use it in GitHub Desktop.
var population
var lifespan = 200 // this will be used to determine how long a stick lives for, and how many genes it has
var visualLifespan // helper to draw to screen
var count = 0 // incrementally measures lifespan
var target // my circle, that is a circle and represents nothing else metaphorically
function setup() {
createCanvas(800, 600)
population = new Population()
visualLifespan = createP()
target = createVector(width/2, 50) // draw the circle in the middle of the screen, at the top
}
function draw() {
background(42, 49, 57)
population.run() // instantiate a generation of sticks - 25 of them
visualLifespan.html(count) // draw the lifecycle to the screen
count++
if (count == lifespan) { // everytime count reaches 200, the length of a lifecycle, a new generation is created
population = new Population()
count = 0
}
ellipse(target.x, target.y, 16, 16)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment