Ejemplo n.º 1
0
        public void add(char key)
        {
            if (builder == null)
            {
                builder      = new BuiltElement("");
                builder.Left = position;
                builder.Top  = 8;
            }

            builder.add(key);
        }
Ejemplo n.º 2
0
        public bool erase()
        {
            if (!builder.erase())
            {
                return(false);
            }

            if (sequence.Count == 0)
            {
                return(true);
            }

            SequenceElement last = sequence.Last <SequenceElement>();

            builder = new BuiltElement(last);
            sequence.Remove(last);

            return(false);
        }
Ejemplo n.º 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);
        }