示例#1
0
        private void panel1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                Neuron spawnedNeuron;

                if (rbNeuron.Checked)
                {
                    spawnedNeuron = new Neuron();
                }
                else if (rbInputNeuron.Checked)
                {
                    spawnedNeuron = new InputNeuron();
                }
                else if (rbOutputNeuron.Checked)
                {
                    spawnedNeuron = new OutputNeuron();
                    ((OutputNeuron)spawnedNeuron).OutputEvent += (obj, args) => MessageBox.Show("AYY LMAO");
                }
                else
                {
                    throw new InvalidOperationException("No radio button is checked!");
                }

                myNetwork.AddNeuron(spawnedNeuron);
                NeuronDisplay disp = new NeuronDisplay(spawnedNeuron);
                disp.Location = new Point(Cursor.Position.X - this.Location.X, Cursor.Position.Y - this.Location.Y);
                this.Controls.Add(disp);
                disp.BringToFront();
            }
        }
示例#2
0
        public NeuronDisplay(Neuron neuron)
        {
            InitializeComponent();

            linkedNeuron = neuron;

            if (neuron.GetType() == typeof(InputNeuron))
            {
                this.BackColor = Color.Blue;
            }
            else if (neuron.GetType() == typeof(OutputNeuron))
            {
                this.BackColor = Color.Orange;
            }

            Form1.GetInstance().displays.Add(linkedNeuron, this);
        }
示例#3
0
 public void AddInput(Neuron inputNeuron)
 {
     inputs.Add(inputNeuron);
 }
示例#4
0
 public void AddNeuron(Neuron newNeuron)
 {
     rules.AddNeuron(newNeuron);
 }
示例#5
0
 public void RemoveNeuron(Neuron neuron)
 {
     if (!allNeurons.Contains(neuron))
     {
         throw new InvalidOperationException("Neuron to remove doesn't exist!");
     }
     else
     {
         allNeurons.Remove(neuron);
         if (inputs.Contains(neuron))
             inputs.Remove((InputNeuron)neuron);
         if (outputs.Contains(neuron))
             outputs.Remove((OutputNeuron)neuron);
     }
 }
示例#6
0
        public void AddNeuron(Neuron neuron)
        {
            if (neuron.IsInput)
            {
                inputs.Add((InputNeuron)neuron);
            }
            else if (neuron.IsOutput)
            {
                outputs.Add((OutputNeuron)neuron);
            }

            allNeurons.Add(neuron);
        }
示例#7
0
 private void RemoveNeuron(Neuron neuron)
 {
     rules.RemoveNeuron(neuron);
 }
示例#8
0
        private void AddRandomNeuron()
        {
            // Create neuron or InputNeuron
            Neuron n;
            int neuronType = rng.Next(0, 100);

            if (neuronType > 50)
            {
                n = new Neuron();
            }
            else
            {
                n = createRandomInput();
            }

            // Get random other neuron in network
            Neuron other = null;
            if (rules.Neurons.Length > 0)
                other = GetRandomNeuron();

            // Add neuron to network
            rules.AddNeuron(n);

            // Connect it to the other neuron
            if (other != null)
            {
                n.AddInput(other);
            }
        }