Ejemplo n.º 1
0
        public string[] GenerateRandomNames(NamingConditions conditions)
        {
            var leaders = conditions
                          .Molecules
                          .ToWeightedDictionary(m => m.GetWeight(PositionType.Beginning));

            return(conditions
                   .TotalNames
                   .Enumerate <string>((i, c, p) => GetName(conditions, leaders))
                   .Distinct()
                   .OrderBy(n => n)
                   .ToArray());
        }
Ejemplo n.º 2
0
        private string GetComponent(NamingConditions c, WeightedDictionary <Molecule> leaders)
        {
            return(Random.Next(c.MinimumGroups, c.MaximumGroups)
                   .Enumerate <Molecule>((i, count, p) =>
            {
                if (i == 0)
                {
                    return leaders.GetRandomItem();
                }

                var leadType = p.LeadType.GetOpposite();

                var weightType = i == count - 1
                        ? PositionType.End
                        : PositionType.Middle;

                return c.Molecules.GetRandom(leadType, weightType);
            })
                   .Select(m => m.Value)
                   .StringJoin()
                   .ToTitleCase());
        }
Ejemplo n.º 3
0
 private string GetName(NamingConditions conditions, WeightedDictionary <Molecule> leaders)
 {
     return(conditions.NameComponentCount
            .Enumerate <string>((i, c, p) => GetComponent(conditions, leaders))
            .StringJoin(" "));
 }