コード例 #1
0
ファイル: Program.cs プロジェクト: EbrithilNogare/mff
 public DequeEnum(DequeArray <U> deque, int count, int blockSize, bool direction)
 {
     array              = deque;
     this.blockSize     = blockSize;
     this.beginPosition = deque.Front;
     this.count         = count;
     Reset();
     endPosition    = deque.Back;
     this.direction = direction;
 }
コード例 #2
0
        public void Overwrite2(NetworkAuto genome)
        {
            //used in itterating all the axons and nurons
            var g_axons  = genome.axons.ListItems();
            var g_nurons = genome.nurons.ListItems();

            foreach (Nuron n1 in g_nurons)
            {
                //tries to find the matching nuron in the current network
                Nuron n0 = nurons.GetValue(n1.Index);

                if (n0 != null)
                {
                    ////copies the genome data if it finds a match
                    //n0.Func = n1.Func;
                }
                else
                {
                    //creates a copy of the first nurons and adds it
                    n0 = new Nuron(this, n1);
                    nurons.Add(n0.Index, n0);
                }
            }

            foreach (Axon a1 in g_axons)
            {
                //tries to find the matching axon in the current network
                Axon a0 = axons.GetValue(a1.Index);

                if (a0 != null)
                {
                    //copies the genome data if it finds a match
                    a0.Weight  = a1.Weight;
                    a0.Enabled = a1.Enabled;
                }
                else
                {
                    //creates a copy of the first axon and adds it
                    a0 = new Axon(a1);
                    axons.Add(a0.Index, a0);
                }
            }


            ////////////////////////////////////////////////////////////////////


            //used to clean up the remaining Axons
            int count1 = genome.axons.Count - axons.Count;

            count1 = Math.Min(count1, 0) + 8;
            var trash1 = new DequeArray <Axon>(count1);
            var ittr1  = axons.ListItems();

            //marks missing Axons for deletion
            foreach (Axon a in ittr1)
            {
                if (genome.axons.HasKey(a.Index))
                {
                    continue;
                }
                else
                {
                    trash1.PushFront(a);
                }
            }

            //deletes the missing Axons
            while (!trash1.Empty)
            {
                Axon del = trash1.PopFront();
                axons.Remove(del.Index);
            }

            //used to clean up the remaining Nurons
            int count2 = genome.nurons.Count - nurons.Count;

            count2 = Math.Min(count2, 0) + 8;
            var trash2 = new DequeArray <Nuron>(count2);
            var ittr2  = nurons.ListItems();

            //marks missing Nurons for deletion
            foreach (Nuron n in ittr2)
            {
                if (genome.nurons.HasKey(n.Index))
                {
                    continue;
                }
                else
                {
                    trash2.PushFront(n);
                }
            }

            //deletes the missing Nurons
            while (!trash2.Empty)
            {
                Nuron del = trash2.PopFront();
                nurons.Remove(del.Index);
                del.ClearData();
            }

            trash1.Dispose();
            trash2.Dispose();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: EbrithilNogare/mff
 public Deque()
 {
     this.array = new DequeArray <T>(blockSize);
 }