Beispiel #1
0
        void addSequence()
        {
            int index = tuple.Item1 + 1;

            sequence = new CreationSequence();
            sequences.Insert(index, sequence);

            while (++count < length && tracking[count].Item1 != index)
            {
                ;
            }

            for (int i = count; i < tracking.Count; i++)
            {
                int it1 = tracking[i].Item1 + 1;
                int it2 = tracking[i].Item2;
                tracking[i] = new Tuple <int, int>(it1, it2);
            }

            if (count == length || tuple.Item1 == -1)
            {
                tuple = new Tuple <int, int>(0, -1);
            }

            display.show(sequence);
            built = true;
        }
Beispiel #2
0
        void setFrame(int index)
        {
            frameChanged(index, null);

            if (count > index)
            {
                for (int i = count; i > index; i--)
                {
                    sequences[tracking[i].Item1].Frames[tracking[i].Item2].undo(neurons, synapses);
                }
            }
            else
            {
                for (int i = count + 1; i <= index; i++)
                {
                    sequences[tracking[i].Item1].Frames[tracking[i].Item2].create(neurons, synapses);
                }
            }

            count = index;

            if (index == 0)
            {
                display.clear();
                tuple = tracking[0];
                frame.Neuron.changeType(SequenceElementType.Normal);
                return;
            }

            Tuple <int, int> tup = tracking[count];

            if (tup.Item1 != tuple.Item1)
            {
                sequence = sequences[tup.Item1];
                display.show(sequence);
            }

            changeFrame(sequence.get(tup.Item2), true);
        }
Beispiel #3
0
        public CreationFrame add(CreationSequence sequence, BuiltElement element, int frame)
        {
            CreationFrame result = create(element.Name, frame);
            Neuron        neuron = result.Neuron.Neuron;
            int           index  = sequence.Frames.Count;

            for (int i = 0; i < index; i++)
            {
                Neuron  previous = sequence.Frames[i].Neuron.Neuron;
                Synapse synapse  = neuron.Input.Find(k => k.Pre.Equals(previous));

                if (synapse == null)
                {
                    synapse = new Synapse(previous, neuron);
                    synapses.Add(synapse);

                    neuron.Input.Add(synapse);
                    previous.Output.Add(synapse);
                    result.add(synapse);
                }

                synapse.Change += 1 / (float)(index - i);
            }

            foreach (Synapse synapse in neuron.Input)
            {
                if (synapse.Change == 0)
                {
                    continue;
                }

                int   count  = 0;
                float start  = 0;
                float weight = 0;

                List <CreationData> changes = synapse.Changes;
                synapse.Factor = 0;

                foreach (CreationData cd in changes)
                {
                    if (cd.Frame > frame)
                    {
                        break;
                    }

                    count++;
                    start           = cd.Weight;
                    synapse.Factor += cd.Change;
                }

                synapse.Factor += synapse.Change;
                weight          = (2 * synapse.Factor) / (synapse.Factor + count + 1);

                CreationData data = new CreationData(synapse, result, synapse.Change, start, weight);

                changes.Insert(count, data);
                result.add(data);
                start = weight;

                for (int i = count; i < changes.Count; i++)
                {
                    synapse.Factor += changes[i].Change;
                    weight          = (2 * synapse.Factor) / (synapse.Factor + i + 1);

                    changes[i].Start  = start;
                    changes[i].Weight = weight;

                    start = synapse.Weight;
                }

                synapse.Weight = weight;
                synapse.Change = 0;
            }

            for (int i = frame; i < frames.Count; i++)
            {
                frames[i].Frame = i;
            }

            frames.Insert(result.Frame, result);
            return(result);
        }