public void MoveOneNeuron(Neuron n, Neuron nNewLocation) { //copy the neuron attributes and delete them from the old neuron. n.Copy(nNewLocation); MainWindow.theNeuronArray.SetCompleteNeuron(nNewLocation); //for all the synapses going out this neuron, change to going from new location //don't use a foreach here because the body of the loop may delete a list entry for (int k = 0; k < n.Synapses.Count; k++) { Synapse s = n.Synapses[k]; nNewLocation.AddSynapse(s.targetNeuron, s.weight, s.isHebbian); } //for all the synapses coming into this neuron, change the synapse target to new location for (int k = 0; k < n.SynapsesFrom.Count; k++) { Synapse reverseSynapse = n.SynapsesFrom[k]; //(from synapses are sort-of backward if (reverseSynapse.targetNeuron != -1) { Neuron sourceNeuron = MainWindow.theNeuronArray.GetNeuron(reverseSynapse.targetNeuron); sourceNeuron.DeleteSynapse(n.id); sourceNeuron.AddSynapse(nNewLocation.id, reverseSynapse.weight, reverseSynapse.isHebbian); } } n.Clear(); }
public void MoveOneNeuron(Neuron n, Neuron nNewLocation) { n.AddUndoInfo(); nNewLocation.AddUndoInfo(); //copy the neuron attributes and delete them from the old neuron. n.Copy(nNewLocation); MainWindow.theNeuronArray.SetCompleteNeuron(nNewLocation); if (FiringHistory.NeuronIsInFiringHistory(n.id)) { FiringHistory.RemoveNeuronFromHistoryWindow(n.id); FiringHistory.AddNeuronToHistoryWindow(nNewLocation.id); } //for all the synapses going out this neuron, change to going from new location //don't use a foreach here because the body of the loop may delete a list entry for (int k = 0; k < n.Synapses.Count; k++) { Synapse s = n.Synapses[k]; if (s.targetNeuron != n.id) { nNewLocation.AddSynapseWithUndo(s.targetNeuron, s.weight, s.model); } else { nNewLocation.AddSynapseWithUndo(nNewLocation.id, s.weight, s.model); } n.DeleteSynapseWithUndo(n.synapses[k].targetNeuron); } //for all the synapses coming into this neuron, change the synapse target to new location for (int k = 0; k < n.SynapsesFrom.Count; k++) { Synapse reverseSynapse = n.SynapsesFrom[k]; //(from synapses are sort-of backward if (reverseSynapse.targetNeuron != -1) //? { Neuron sourceNeuron = MainWindow.theNeuronArray.GetNeuron(reverseSynapse.targetNeuron); sourceNeuron.DeleteSynapseWithUndo(n.id); if (sourceNeuron.id != n.id) { sourceNeuron.AddSynapseWithUndo(nNewLocation.id, reverseSynapse.weight, reverseSynapse.model); } } } n.Clear(); }
public void MoveOneNeuron(Neuron n, Neuron nNewLocation) { //copy the neuron attributes and delete them from the old neuron. n.Copy(nNewLocation); //for all the synapses going out this neuron, change to going from new location //don't use a foreach here because the body of the loop may delete a list entry if (n.synapses != null) { for (int k = 0; k < n.synapses.Count; k++) { Synapse s = n.Synapses[k]; Synapse s1 = nNewLocation.AddSynapse(s.TargetNeuron, s.Weight); if (s1 != null && s.IsHebbian) { s1.IsHebbian = true; } } } //for all the synapses coming into this neuron, change the synapse target to new location if (n.synapses != null) { for (int k = 0; k < n.synapsesFrom.Count; k++) { Synapse reverseSynapse = n.SynapsesFrom[k]; //(from synapses are sort-of backward if (reverseSynapse.TargetNeuron != -1) { Neuron sourceNeuron = MainWindow.theNeuronArray.GetNeuron(reverseSynapse.TargetNeuron); Synapse s = sourceNeuron.FindSynapse(n.Id); if (s != null) { s.TargetNeuron = nNewLocation.Id; nNewLocation.SynapsesFrom.Add(new Synapse(sourceNeuron.Id, s.Weight)); } } } } n.Clear(); }