コード例 #1
0
ファイル: Vocabulary.cs プロジェクト: gcfavorites/fnordbot
 internal Vocabulary()
 {
     prevSortedFragments = new FragmentList( new FragmentComparer( SortWord.PreviousWord ) );
     centerSortedFragments = new FragmentList( new FragmentComparer( SortWord.CurrentWord  ) );
     nextSortedFragments = new FragmentList( new FragmentComparer( SortWord.NextWord ) );
     canStartFragments = new FragmentList( null);
     wordlist = new WordList();
     rnd = new Random();
 }
コード例 #2
0
ファイル: Fragment.cs プロジェクト: gcfavorites/fnordbot
        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;
        }
コード例 #3
0
ファイル: Fragment.cs プロジェクト: gcfavorites/fnordbot
        // 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;
        }
コード例 #4
0
ファイル: Fragment.cs プロジェクト: gcfavorites/fnordbot
        public FragmentList GetSomeFragmentsByWord(Fragment frag)
        {
            MatchComparer mc = new MatchComparer();
            //
            FragmentList lst = new FragmentList(null);

            int i = list.BinarySearch( frag, mc );
            if (i < 0) log.Warn("GetSomeFragmentsByWord fandt ikke ord, binsearch returnerede "+i+" ("+~i+")");
            while (i>1 && mc.Compare(this[i-1], frag)==0) i--;

            while(i>0 && mc.Compare(this[i],frag) == 0)
            {
                lst.Add(this[i]);
                i++;
            }
            return lst;
        }