// Constructor
 public Chapter9Fig3Rocket(GameObject rocketObj, Vector2 l, Chapter9Fig3DNA _dna, Chapter9Fig3Obstacle ob, int totalRockets)
 {
     HitTarget    = false;
     target       = ob;
     acceleration = Vector2.zero;
     velocity     = Vector2.zero;
     position     = l;
     DNA          = _dna;
     finishTime   = 0;           // We're going to count how long it takes to reach target
     recordDist   = 10000;       // Some high number that will be beat instantly
     HitObstacle  = false;
     g            = GameObject.Instantiate(rocketObj, position, Quaternion.identity);
 }
    // Initialize the population
    public Chapter9Fig3Population(GameObject rocketObj, Vector2 screen, float mutation, int numberOfRockets, float lifeTime, Chapter9Fig3Obstacle obTarget)
    {
        rocketObject = rocketObj;
        mutationRate = mutation;
        population   = new Chapter9Fig3Rocket[numberOfRockets];
        matingPool   = new List <Chapter9Fig3Rocket>();
        Generations  = 0;
        screenSize   = screen;
        target       = obTarget;

        // Making a new set of creatures
        for (int i = 0; i < population.Length; i++)
        {
            Vector2 position = new Vector2(0, -screenSize.y);
            population[i] = new Chapter9Fig3Rocket(rocketObj, position, new Chapter9Fig3DNA(lifeTime), target, population.Length);
        }
    }
    private Vector2 screenSize;                    // Size of the screen in meters or UnityUnits

    // Start is called before the first frame update
    void Start()
    {
        // Sets main cam to orthographic, sets size to 10
        setupCamera();

        // Initialize variables
        lifeCycle  = 0;
        recordTime = lifetime;

        // Top middle of the screen
        target = new Chapter9Fig3Obstacle(0, screenSize.y - 2f, 4f, 2f);

        // Create a population with a mutation rate, and population max
        population = new Chapter9Fig3Population(rocketPrefab, screenSize, mutationRate, populationSize, lifetime, target);

        // Create the obstacle course
        obstacles = new List <Chapter9Fig3Obstacle>();
        obstacles.Add(new Chapter9Fig3Obstacle(0, 0, 14, 2));
    }