Exemplo n.º 1
0
        public FragmentList GetSomePreviousFragments(Fragment frag)
        {
            FragmentList lst = new FragmentList(null);
            OverlapComparer olc = new OverlapComparer(true);
            int i = list.BinarySearch(frag, olc);
            if (i<0) throw new Exception("tilsyneladende blev "+frag+" ikke fundet i denne liste");
            //			int o = ~i;
            while (i > 1 && olc.Compare(this[i-1],frag) == 0 ) i--;

            while(olc.Compare(this[i],frag) == 0)
            {
                lst.Add(this[i]);
                i++;
            }
            if ( (lst.Count < lowerBound && (simpleChance-1 >= rnd.Next(100))) || rnd.Next(100)<ambientSimpleChance ) // 5% chance for spring
            {
                NextComparer ncmp = new NextComparer(true);
                int j = list.BinarySearch(frag, ncmp);
                while (j > 1 && ncmp.Compare(this[j-1],frag) == 0 )  j--;
                while(ncmp.Compare(this[j],frag) == 0)
                {
                    lst.Add(this[j]);
                    j++;
                }
            }
            return lst;
        }
Exemplo n.º 2
0
        // w1 w2 w3
        //    w1 w2 w3
        public FragmentList GetSomeNextFragments(Fragment frag)
        {
            FragmentList lst = new FragmentList(null);
            OverlapComparer olc = new OverlapComparer(false);
            int i = list.BinarySearch(frag, olc);
            if (i<0) throw new Exception("tilsyneladende blev "+frag+" ikke fundet i denne liste");
            //			Console.WriteLine("fandt next: "+list[i]);
            //			int o = ~i;
            while (i > 1 && olc.Compare(this[i-1],frag) == 0 )
            {
                //				Console.WriteLine("backtrack!");
                i--; // ?
            }

            while(olc.Compare(this[i],frag) == 0)
            {
                lst.Add(this[i]);
                i++;
            }
            if ( (lst.Count < lowerBound && (simpleChance-1 >= rnd.Next(100))) || rnd.Next(100)<ambientSimpleChance ) // 5% chance for spring
            {
            //				Console.Write("enabling simple-compare for "+frag.ToString()+" - it only had "+lst.Count+" nextfragments...");
                NextComparer ncmp = new NextComparer(false);
                int j = list.BinarySearch(frag, ncmp);
                while (j > 1 && ncmp.Compare(this[j-1],frag) == 0 )  j--;
                while(ncmp.Compare(this[j],frag) == 0)
                {
                    lst.Add(this[j]);
                    j++;
                }
            //				Console.WriteLine(" now it has "+lst.Count+" to choose from");
            }
            return lst;
        }