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(); } }
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); }
public void AddInput(Neuron inputNeuron) { inputs.Add(inputNeuron); }
public void AddNeuron(Neuron newNeuron) { rules.AddNeuron(newNeuron); }
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); } }
public void AddNeuron(Neuron neuron) { if (neuron.IsInput) { inputs.Add((InputNeuron)neuron); } else if (neuron.IsOutput) { outputs.Add((OutputNeuron)neuron); } allNeurons.Add(neuron); }
private void RemoveNeuron(Neuron neuron) { rules.RemoveNeuron(neuron); }
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); } }