Esempio n. 1
0
    /// <summary>
    /// Create a template of a PhenotypeNetwork, to use on sensing adjacent creatures.
    /// </summary>
    /// <param name="phenoNetEditor">Wrapper for PhenotypeNetwork.</param>
    /// <param name="layer">Layer in which network exists (probably 0).</param>
    /// <param name="name">Name of network.</param>
    /// <param name="hiddenNodesPerLayer">Nodes per hidden layer.</param>
    /// <param name="layersHiddenNodes">Number of hidden layers in the network.</param>
    /// <param name="outputActionNames">Names of output actions, whose output networks will be connected to this network.</param>
    /// <param name="hiddenNodeActiv">The type of activation function used by the hidden nodes.</param>
    /// <param name="outputNodeActiv">The type of activation function used by the output nodes. Note: the output of this function should be in the range [0,1].</param>
    public static void createPhenotypeNet(PhenotypeNetworkEditor phenoNetEditor, int layer, string name, int hiddenNodesPerLayer, int layersHiddenNodes,
                                          List <string> outputActionNames, ActivationBehaviorTypes hiddenNodeActiv, ActivationBehaviorTypes outputNodeActiv)
    {
        phenoNetEditor.setInLayer(layer); // called by default with index of layer user clicked
        phenoNetEditor.setName(name);
        phenoNetEditor.createInputNodes();
        // set index of output layer based on hidden nodes
        int outputLayer = layersHiddenNodes + 1;

        // for every hidden layer
        for (int i = 0; i < layersHiddenNodes; i++)
        {
            phenoNetEditor.insertNewLayer(i + 1);
            // add every node in that layer
            for (int j = 0; j < hiddenNodesPerLayer; j++)
            {
                makeHiddenNode(phenoNetEditor, hiddenNodeActiv, i + 1);
            }
        }

        for (int i = 0; i < outputActionNames.Count; i++)
        {
            makeOutputNode(phenoNetEditor, outputNodeActiv, outputActionNames[i], outputLayer);
        }
    }