/**
   World functions
 */

import _ from 'underscore';

export const create = () => {
  return {
    tripods: [],
    food: []
  };
};

export const addTripod = (world, tripod) => {
  world.tripods.push(tripod);
};

export const addFood = (world, food) => {
  world.food.push(food);
};

export const eatFood = (world, food) => {
  const idx = _.indexOf(world.food, food);
  if (idx > -1) {
    world.food.splice(idx, 1);
  }
};

@@ -418,12 +418,165 @@
  1);%0A  %7D%0A%7D;%0A
+%0Aexport const closestFood = (world, position) =%3E %7B%0A  if (_.isEmpty(world.food)) return null;%0A  return _.min(world.food, (f) =%3E position.distance(f));%0A%7D;%0A

Add getClosestFood function to world