public void Chain_WithRestrictiveMaximumOrder_DoesntAlwaysQuoteCorpus() { var chainWithBackoff = new MarkovChainWithBackoff <char>(5, 2); chainWithBackoff.Add("fool"); var deterministicRand = new Random(0); var resultWithBackoff = string.Join("", chainWithBackoff.Chain(deterministicRand)); Assert.Equal("fol", resultWithBackoff); }
static string GenerateQuoteWithBackoff() { Random rand = new Random(); // Order 3 is the highest order that actually makes a meaningful difference. // Targeting 2 next states seems like it hits a balance of high and low orders. MarkovChainWithBackoff <string> chain = GetChainWithBackoff(3, 2); IEnumerable <string> result = chain.Chain(rand); string generatedQuote = string.Join(" ", result); return(TruncateQuote(generatedQuote)); }