Esempio n. 1
0
    /// <summary>
    /// Evaluate the provided black box against the prey capture task,
    /// and return its fitness score.
    /// </summary>
    /// <param name="box">The black box to evaluate.</param>
    /// <returns>A new instance of <see cref="FitnessInfo"/>.</returns>
    public FitnessInfo Evaluate(IBlackBox <double> box)
    {
        // Perform multiple independent trials.
        int fitness = 0;

        for (int i = 0; i < _trialsPerEvaluation; i++)
        {
            // TODO: Change RunTrial() to return 0 or 1, so that we can sum the result without performing a conditional branch.
            // Run a single trial, and record if the prey was captured.
            if (_world.RunTrial(box))
            {
                fitness++;
            }
        }

        // Fitness is given by the number of trials in which the agent caught the prey.
        return(new FitnessInfo(fitness));
    }
 public void RunTrial()
 {
     _world.RunTrial(_agent);
 }