require("babel/register");
var Seeder = require('./app/seeder');
var Entity = require('./app/entity');
var simulateWorld = require('./app/simulator');

function run(generations=100, population=30) {
  var initialGeneration = Seeder.make(30);
  var framesToSimulate = 60;

  var fitnessScenario = {
    startingPosition: {
      x: 100,
      y: 100,
    },

    expectedEndPosition: {
      x: 200,
      y: 100,
    },

    duration: 60,

    fitness(entity) {
      var distance = {
        x: Math.abs(this.expectedEndPosition.x - entity.position.x),
        y: Math.abs(this.expectedEndPosition.y - entity.position.y),
      }

      return 1000 - (distance.x + distance.y);
    }
  };

  var entities = initialGeneration.map(individual => new Entity(individual, fitnessScenario.startingPosition));

  entities.forEach(entity => simulateWorld(entity, fitnessScenario.duration));

  console.log(entities.map(e => e.position));
  return entities.map(function (entity) {
    return {
      entity: entity,
      fitness: fitnessScenario.fitness(entity),
    };
  });
}

module.exports = run;

@@ -149,130 +149,8 @@
 );%0A%0A
-function run(generations=100, population=30) %7B%0A  var initialGeneration = Seeder.make(30);%0A  var framesToSimulate = 60;%0A%0A  
 var 
@@ -171,18 +171,16 @@
 o = %7B%0A  
- 
- 
 starting
@@ -179,33 +179,47 @@
 startingPosition
-:
+() %7B%0A    return
  %7B%0A      x: 100,
@@ -238,21 +238,24 @@
 0,%0A    %7D
-,%0A
+;
 %0A  
+%7D,%0A%0A
   expect
@@ -279,18 +279,16 @@
     
-  
 x: 200,%0A
     
@@ -279,26 +279,24 @@
     x: 200,%0A
-  
     y: 100,%0A
@@ -299,18 +299,14 @@
 00,%0A
-  
   %7D,%0A%0A
-  
   du
@@ -563,20 +563,139 @@
 ;%0A    %7D%0A
-  
 %7D;
+%0A%0Afunction run(generations=100, population=32) %7B%0A  var initialGeneration = Seeder.make(30);%0A  var framesToSimulate = 60;%0A
 %0A%0A  var 
@@ -792,24 +792,26 @@
 tingPosition
+()
 ));%0A%0A  entit
@@ -887,54 +887,8 @@
 );%0A%0A
-  console.log(entities.map(e =%3E e.position));%0A
   re

Fix all entities sharing common position, extract fitnessScenario