Beispiel #1
0
        void initialize(List <AnimatedNeuron> neurons, List <AnimatedSynapse> synapses, List <AnimatedReceptor> receptors)
        {
            action   = true;
            treshold = 1;

            this.neurons   = new List <BalancedNeuron>();
            this.receptors = new List <BalancedReceptor>();
            this.synapses  = new List <BalancedSynapse>();
            map            = new Dictionary <AnimatedElement, BalancedElement>();

            foreach (AnimatedNeuron an in neurons)
            {
                BalancedNeuron neuron = new BalancedNeuron(an);
                this.neurons.Add(neuron);
                map.Add(an, neuron);
            }

            foreach (AnimatedReceptor ar in receptors)
            {
                BalancedReceptor receptor = new BalancedReceptor(ar);
                this.receptors.Add(receptor);
                map.Add(ar, receptor);
            }

            foreach (AnimatedSynapse synapse in synapses)
            {
                this.synapses.Add(new BalancedSynapse(synapse, map));
            }

            extra = false;
        }
Beispiel #2
0
        public void repulse(BalancedReceptor r, float factor)
        {
            PointF delta = diff(position, r.position);

            float distance = delta.X * delta.X + delta.Y * delta.Y;
            float force    = Math.Min((float)(k2 * factor / distance), 0.5f);

            shift.X += (float)(force * delta.X / Math.Sqrt(distance));
            shift.Y += (float)(force * delta.Y / Math.Sqrt(distance));
        }