コード例 #1
0
    /// <summary>
    /// Creates the desired regulation scheme
    /// </summary>
    public void UpdateBasicRegulation()
    {
        // First resets the regulation list
        moduleController.ResetRegulation();

        // Is it "Active when X is active" or when "X is inactive"?
        if (activeWhenInputActive)
        {
            // "Active when X is active" is the easiest case:
            moduleController.AddInputToReg(inputSelector.value, 1.0);

            // We record this action:
            moduleController.UiManager.WriteToRecord(
                "New regulation for module " + moduleController.ModuleId +
                ": when " + inputSelector.value.ToString() + " active");
        }
        else
        {
            // We record this action:
            moduleController.UiManager.WriteToRecord(
                "New regulation for module " + moduleController.ModuleId +
                ": when " + inputSelector.value.ToString() + " inactive");

            // First checks the special case for "active when bias is inactive"
            // In this case we do not want 2 different connections from bias
            // which would be problematic, because they would share Id!
            if (inputSelector.value == 0)
            {
                // This should never be active, so it uses weight 0
                moduleController.AddInputToReg(inputSelector.value, 0.0);
            }
            else
            {
                // This is the normal case. +1 regulation with bias and -1
                // from the selected input (so when it is active the result
                // is +1 -1 = 0 --> no activation)

                // First adds the auxiliary connection from bias
                moduleController.AddInputToReg(0, 1.0);
                // Then the connection from the selected input, with weight -1
                moduleController.AddInputToReg(inputSelector.value, -1.0);
            }
        }

        // Asks module controller to pass the new regulation scheme to
        // UImanager.
        moduleController.PassRegulation();
    }