Advertisement
xxdriesxx

Markov Chain Name Generation

Jun 24th, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. string name = "";
  2. double chanceOfEnd = 0.0;
  3.  
  4. string currentRule = keys[_randomGenerator.Next(0, keys.Count)];
  5. name += currentRule;
  6.  
  7. while (_rules.ContainsKey(currentRule))
  8. {
  9.     currentRule = _rules[currentRule][_randomGenerator.Next(0, _rules[currentRule].Count)];
  10.     name += currentRule;
  11.  
  12.     if (_randomGenerator.NextDouble() < chanceOfEnd)
  13.         break;
  14.     else
  15.         chanceOfEnd += 0.1;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement