Beispiel #1
0
    // TODO make this truly breed
    private Action[] breed(Specimen a, Specimen b)
    {
        Action[] aActions = a.GetActions();
        Action[] bActions = b.GetActions();
        Action[] result   = new Action[numberOfActions];
        for (int i = 0; i < numberOfActions; i++)
        {
            float mutationValue = r.value;
            result[i] = (mutationValue < mutationPercentage) ? CreateNewTrait(i == 0 ? 0 : result[i - 1].executionTime) : ((int)Math.Round(r.value) == 0) ? aActions[i] : bActions[i];
            // Debug.Log("a"+i+": " + aActions[i].Item1 + ", " + aActions[i].Item2 + ", " + aActions[i].Item3);
            // Debug.Log("b"+i+": " + bActions[i].Item1 + ", " + bActions[i].Item2 + ", " + bActions[i].Item3);
            // Debug.Log("result "+i+": " + result[i].Item1 + ", " + result[i].Item2 + ", " + result[i].Item3);
        }

        // sort actions by action times
        SortActionsByExecutionTime(result);
        return(result);
    }