示例#1
0
        public void Execute(Settlement settlement)
        {
            var nameGroup = gateway.All();
            var names     = nameGroup.SelectMany(x => x.Names);
            var gen       = new MarkovNameGenerator(names, Order);

            settlement.Name = gen.Generate(MaximumLength);
        }
示例#2
0
        public void ShouldBuildAStringBasedOnValuesNotToExceedASpecifiedLength()
        {
            var names = new string[] { "Alpha", "Bravo", "Charlie", "Delta" };
            var gen   = new MarkovNameGenerator(names, 1);
            var name  = gen.Generate(6);

            Assert.True(name.Length <= 6);
        }
示例#3
0
        public void OrderCanBeIncreasedToProvideMoreConsistencyOfTokens()
        {
            /*
             *  Given abacad with an order of 2
             *  Then we should generate tokens like
             *  __ => a, _a => b, ab => a, ba => c, ac => a, ca => d, ad
             */
            var names = new string[] { "abacad" };
            var gen   = new MarkovNameGenerator(names, 2);
            var tok   = gen.States.First(x => x.Key == "ab");

            Assert.NotNull(tok);
            Assert.Equal("a", tok.Tokens.Keys.First());

            //With this model, the only valid generation is the input string
            Assert.Equal("Abacad", gen.Generate(6));
        }