void ShowLayerConfig(NeuralController controller)
    {
        showLayerConfig = EditorGUILayout.Foldout(showLayerConfig, "Hidden Layers");

        if (showLayerConfig)
        {
            int lenght = controller.hiddenLayers.Count;
            for (int i = 0; i < lenght; i++)
            {
                controller.hiddenLayers[i] = EditorGUILayout.IntField(controller.hiddenLayers[i]);
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                controller.hiddenLayers.Add(0);
            }
            if (GUILayout.Button("-"))
            {
                if (lenght >= 1)
                {
                    controller.hiddenLayers.RemoveAt(lenght - 1);
                }
            }
            GUILayout.EndHorizontal();
        }
    }
예제 #2
0
 void Start()
 {
     anim = GetComponent <Animator>();
     anim.SetBool("IsMoving", true);
     wallMask         = LayerMask.GetMask("Wall");
     neuralController = transform.parent.GetComponent <NeuralController>();
     //lineRender = GetComponent<LineRenderer>();
 }
    void ShowCompositionConfig(NeuralController controller)
    {
        controller.inputNodes  = EditorGUILayout.IntField("Input nodes:", controller.inputNodes);
        controller.outputNodes = EditorGUILayout.IntField("Output nodes:", controller.outputNodes);
        ShowLayerConfig(controller);
        GUILayout.BeginHorizontal();

        GUILayout.EndHorizontal();
    }
    public override void OnInspectorGUI()
    {
        NeuralController controller = (NeuralController)target;

        showCompositionConfig = EditorGUILayout.Foldout(showCompositionConfig, "Composition");
        if (showCompositionConfig)
        {
            ShowCompositionConfig(controller);
        }
        base.OnInspectorGUI();
    }
    void OnEnable()
    {
        NeuralController controller = (NeuralController)target;

        showLayerConfig       = false;
        showCompositionConfig = false;
        if (controller.hiddenLayers == null)
        {
            controller.hiddenLayers = new List <int>();
        }
    }
예제 #6
0
        private void Menu_DeleteNeuralNetwork_Click(object sender, EventArgs e)
        {
            neural = null;

            // Visualing
            Menu_CreateNeuralNetwork.Enabled = true;

            Menu_Learn.Enabled             = false;
            Menu_TestNeuralNetwork.Enabled = false;
            Menu_Save.Enabled = false;
            Menu_DeleteNeuralNetwork.Enabled = false;
        }
예제 #7
0
        private void Menu_CreateNeuralNetwork_Click(object sender, EventArgs e)
        {
            neural = new NeuralController(784, 16, 2, 10, new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" });

            // Visualing
            Menu_CreateNeuralNetwork.Enabled = false;

            Menu_Learn.Enabled             = true;
            Menu_TestNeuralNetwork.Enabled = true;
            Menu_Save.Enabled = true;
            Menu_DeleteNeuralNetwork.Enabled = true;
        }
예제 #8
0
    public NeuralNetwork(NetworkComposition networkComposition, bool initDebugger, NeuralController controller)
    {
        this.networkComposition = networkComposition;
        SetupNetworkArchitecture();

        score = 0;

        if (initDebugger)
        {
            networkDebugger = controller.gameObject.AddComponent(typeof(NeuralDebugger)) as NeuralDebugger;
            networkDebugger.Init(this, controller.nodeTexture, controller.targetCanvas);
        }
    }
예제 #9
0
    private SimulationInfo createSimulation(int sim_i, Rect location, int indiv_i)
    {
        GameObject sim = Instantiate(simulationPrefab, transform.position + new Vector3(0, 0, (sim_i * 1000)), transform.rotation);

        sim.GetComponentInChildren <Camera>().rect = location;
        NeuralController player_script = sim.GetComponentInChildren <NeuralController>();

        if (player_script.enabled)
        {
            //Debug.Log("enable ! ");
            player_script.neuralController = metaengine.Population[indiv_i].getIndividualController();
        }
        return(new SimulationInfo(sim, sim.GetComponentInChildren <NeuralController> (), indiv_i));
    }
예제 #10
0
    private void Awake()
    {
        instance = this;

        rb           = GetComponent <Rigidbody>();
        lastFramePos = transform.position;

        results  = new float[2];
        distance = new float[populationPerGen];
        sensors  = new float[3];

        // Sensor directions
        fRaycast = Vector3.forward * 2;
        rRaycast = new Vector3(0.4f, 0, 0.7f);
        lRaycast = new Vector3(-0.4f, 0, 0.7f);
    }
예제 #11
0
    private SimulationInfo createSimulation(int sim_i, Rect location)
    {
        GameObject       sim           = Instantiate(simulationPrefab, transform.position + new Vector3(0, 0, (sim_i * 1000)), transform.rotation);
        NeuralController player_script = sim.GetComponentInChildren <NeuralController> ();

        sim.GetComponentInChildren <Camera> ().rect = location;
        NeuralController[] controllers = sim.GetComponentsInChildren <NeuralController>();
        if (controllers[0].enabled)
        {// BluePlayer Controller
            controllers[0].neuralController = BlueController;
            controllers[0].running          = true;
        }
        if (controllers.Length > 1 && (controllers[1].enabled || (savePathRedPlayer != null && savePathRedPlayer.Trim().Length != 0)))
        {// RedController Controller
            controllers[1].neuralController = RedController;
            sim.GetComponentsInChildren <CarSimpleController>()[1].enabled = false;
            controllers[1].enabled = true;
            controllers[1].running = true;
        }

        return(new SimulationInfo(sim, sim.GetComponentInChildren <NeuralController> (), 0));
    }
예제 #12
0
 public SimulationInfo(GameObject sim, NeuralController playerc, int individual_index)
 {
     this.sim              = sim;
     this.playerc          = playerc;
     this.individual_index = individual_index;
 }
예제 #13
0
 public void AddNeuralController(NeuralController neural)
 {
     controllers.Add(neural);
 }
예제 #14
0
 public bool ConnectWithController(NeuralController controller, out GeneticMixer mixer)
 {
     this.controller = controller;
     mixer           = this;
     return(true);
 }
예제 #15
0
 public RangedMutation(NeuralNetwork ancestorNetwork, NeuralController controller, float mutationRate)
 {
     this.ancestorNetwork = ancestorNetwork;
     this.controller      = controller;
     this.mutationRate    = mutationRate;
 }
예제 #16
0
 public RandomMutation(NeuralNetwork ancestorNetwork, NeuralController controller)
 {
     this.ancestorNetwork = ancestorNetwork;
     this.controller      = controller;
 }