 create_fly_trap =
   (info) ->
     if info.front == 'OTHER' then 'EAT' else 'TURN_LEFT'
+
+create_moth =
+  (info) ->
+    if info.front == 'OTHER'
+      'EAT'
+    else if info.front == 'EMPTY'
+      'WALK_FORWARD'
+    else
+      'TURN_LEFT'
+
+shuffle_array = (array) ->
+  i = array.length
+  return [] if i is 0
+
+  while --i
+      j = Math.floor(Math.random() * (i+1))
+      [array[i], array[j]] = [array[j], array[i]]

    for y in [0..39]
      grid[x][y] = null

  bugs = grid: grid


  add_bug bugs, 'fly_trap', 'rgb(0,0,255)', create_fly_trap
  add_bug bugs, 'fly_trap', 'rgb(0,0,255)', create_fly_trap
  add_bug bugs, 'fly_trap', 'rgb(0,0,255)', create_fly_trap

  bugs


  bugs  = starting_bugs()
  render_game canvas, bugs

  next_turn bugs, canvas, turns

next_turn = (bugs, canvas, turns) ->
  next_iteration bugs
  render_game canvas, bugs

  if turns < 10
    setTimeout((-> next_turn bugs, canvas, turns + 1), 100)

empty_grid = ->
  grid = []

  for x in [0..59]
