   canvas.setHeight  400
   canvas.setWidth  600
 
-  turns = 0
   bugs  = starting_bugs()
   render_game canvas, bugs
 
-  next_turn bugs, canvas, turns
-  make_chart '#jitterbug_progress_chart_svg'
-
-next_turn = (bugs, canvas, turns) ->
+  next_turn bugs, canvas
+
+next_turn = (bugs, canvas) ->
   next_iteration bugs
   render_game canvas, bugs
 
-  if turns < 1000
-    setTimeout((-> next_turn bugs, canvas, turns + 1), 50)
+  if bugs.turns % 10 == 0
+    stats = bugs.names.map((name) -> bugs.stats[name])
+    make_chart '#jitterbug_progress_chart_svg', stats
+
+  if bugs.turns < 1000
+    bugs.turns += 1
+    setTimeout((-> next_turn bugs, canvas), 50)
 
 empty_grid = ->
   grid = []

    [yLabel, yAxis, center],
    [null,   null,  xAxis ]
  ]).renderTo(svg_id)
  panZoom   = new Plottable.Interaction.PanZoom(xScale, null)
  center.registerInteraction(panZoom)

jitterbug_game = (canvas_id) ->
  canvas = new fabric.Canvas 'jitterbug_game_canvas',

    color:     color
    serial:    (bugs.next_serial += 1)

  unless bugs.stats[name]?
    bugs.stats[name] = [{iteration: 0, count: 0, name: name}]
    bugs.names.push name

  bugs.stats[name][0].count += 1

random_location = (bugs) ->
  x = random_num 59
  y = random_num 39
