Example #1
0
 public Story(string title, string author, string seed, List<KeyValuePair<string, string>> chapters, Histograph graph)
 {
     _title = title;
     _author = author;
     _seed = seed;
     _chapters = chapters;
     _graph = graph;
 }
Example #2
0
        public Story GenerateStoryObject(string seed, int chapterCount, int chapterLength, int weightDistSelect, int weightChangeOption)
        {
            flags.Clear();
            graph = new Histograph();
            LongRandom rngBase = new LongRandom(seed);
            rand = new LongRandom(seed);
            ChangeWeights(rand, weightDistSelect);
            AssignGlobals(rand);

            string title = GenerateFrom(patternBank["T"].GetPattern(rand));
            string author = GenerateFrom(patternBank["B"].GetPattern(rand));

            List<KeyValuePair<string, string>> chapters = new List<KeyValuePair<string, string>>();

            for (int i = 0; i < chapterCount; i++)
            {
                rand = new LongRandom(rngBase.Next());
                string chapterTitle = GenerateFrom(patternBank["C"].GetPattern(rand));
                int paragraphs = rand.Next(3 + 4 * chapterLength, 8 + 4 * chapterLength);
                StringBuilder builder = new StringBuilder();

                for (int j = 0; j < paragraphs; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        GenerateFromOutline(builder, oIntros);
                        builder.AppendLine("\r\n");
                    }
                    else if (i == chapterCount - 1 && j == paragraphs - 1)
                    {
                        GenerateFromOutline(builder, oEndings);
                    }
                    else
                    {
                        GenerateFromOutline(builder, oBodies);
                        builder.AppendLine("\r\n");
                    }
                    if (weightChangeOption == 2)
                    {
                        ChangeWeights(rand, weightDistSelect);
                    }
                }
                if (weightChangeOption == 1)
                {
                    ChangeWeights(rand, weightDistSelect);
                }
                chapters.Add(new KeyValuePair<string, string>(chapterTitle, builder.ToString()));
            }
            return new Story(title, author, seed, chapters, graph);
        }