public Dictionary <object, object> loadFrame(CreationFrame frame, int index) { Dictionary <object, object> result = new Dictionary <object, object>(); Random random = new Random(); bool added = false; Neuron neuron = frame.Neuron.Neuron; if (neurons.Find(k => k.Neuron == neuron) == null) { PointF position = randomPoint(random); AnimatedNeuron an = new AnimatedNeuron(neuron, position); CreatedNeuron cn = new CreatedNeuron(an); neurons.Add(an); result.Add(neuron, cn); added = true; } else { result.Add(neuron, true); } foreach (CreationData data in frame.Data) { if (data.Synapse.Changes.First <CreationData>() == data) { AnimatedNeuron pre = neurons.Find(k => data.Synapse.Pre == k.Neuron); AnimatedNeuron post = neurons.Find(k => data.Synapse.Post == k.Neuron); AnimatedSynapse synapse = synapses.Find(k => pre == k.Pre && post == k.Post); if (synapse == null) { AnimatedSynapse syn = new AnimatedSynapse(pre, post, data.Synapse); CreatedSynapse cs = new CreatedSynapse(syn); synapses.Add(syn); result.Add(syn.Synapse, cs); if (syn.isDuplex()) { result.Add(syn.Duplex, cs); } } else { synapse.setDuplex(data.Synapse); } } } if (added) { balance(); } return(result); }
public void loadBrain(Brain brain) { Random random = new Random(); Presentation.brain = brain; balanceSize(); AnimatedElement.Area = area; AnimatedElement.Size = size; BalancedElement.Size = size; foreach (Neuron neuron in brain.Neurons) { PointF position = randomPoint(random); neurons.Add(new AnimatedNeuron(neuron, position)); } foreach (AnimatedNeuron pre in neurons) { foreach (Synapse synapse in pre.Neuron.Output) { foreach (AnimatedNeuron post in neurons) { if (post.Neuron == synapse.Post) { AnimatedSynapse syn = synapses.Find(k => pre == k.Pre && post == k.Post); if (syn == null) { synapses.Add(new AnimatedSynapse(pre, post, synapse)); } else { syn.setDuplex(synapse); } break; } } } } String[] data = { brain.Neurons[0].Word, brain.Neurons[1].Word }; addQuery(data, 4, 0.6f); queryAccepted(query, null); }
protected override void mouseMove(object sender, MouseEventArgs e) { if (shift != null) { base.mouseMove(sender, e); return; } if (active != null) { if (active.active(e.Location)) { return; } if (mapHistory.ContainsKey(active)) { mapHistory[active].hide(); } active = null; time = 0; return; } foreach (CreatedSynapse synapse in synapses) { AnimatedSynapse s = synapse.Synapse; if (s.active(e.Location, false)) { active = s.getState(false); return; } if (s.isDuplex() && s.active(e.Location, true)) { active = s.getState(true); return; } } }
public CreatedSynapse(AnimatedSynapse synapse) { this.synapse = synapse; }
public BalancedSynapse(AnimatedSynapse synapse, Dictionary <AnimatedElement, BalancedElement> map) { this.synapse = synapse; pre = map[synapse.Pre]; post = map[synapse.Post]; }