Exemple #1
0
        public void Mutate()
        {
            if (solver.RandomHelper.Mutate(100))
            {
                Inspirational = solver.AvailableInspirationals[solver.RandomHelper.GetShort(solver.AvailableInspirationals.Length)];
            }

            if (LeftNode != null)
            {
                LeftNode.Mutate();
            }
            if (RightNode != null)
            {
                RightNode.Mutate();
            }

            if (LeftNode == null)
            {
                if (solver.RandomHelper.Mutate(20))
                {
                    LeftNode = CreateRandomNode();
                }
                else if (solver.RandomHelper.Mutate(20))
                {
                    LeftNode = this.Clone(solver);
                }
            }
            else
            {
                if (solver.RandomHelper.Mutate(50))
                {
                    LeftNode = null;
                }
            }

            if (RightNode == null)
            {
                if (solver.RandomHelper.Mutate(20))
                {
                    RightNode = CreateRandomNode();
                }
                else if (solver.RandomHelper.Mutate(20))
                {
                    RightNode = this.Clone(solver);
                }
            }
            else
            {
                if (solver.RandomHelper.Mutate(50))
                {
                    RightNode = null;
                }
            }
        }
Exemple #2
0
        public static string InspToLine(Inspirational insp)
        {
            string line = String.Concat(insp.Name, "\t\t");

            foreach (int i in insp.Proficiencies)
            {
                if (i > 0)
                {
                    line = String.Concat(line, i.ToString());
                }
                line = String.Concat(line, "\t");
            }
            line = String.Concat(line, insp.Inspiration.ToString(), "\t");
            line = String.Concat(line, insp.Uses.ToString(), "\t");
            line = String.Concat(line, insp.Diff.ToString());
            return(line);
        }
Exemple #3
0
        public void AddInspirational(Inspirational inspirational)
        {
            var uses               = inspirationalUses[inspirational.Id]++;
            var modifier           = Math.Min(8, 2 + uses);
            var givenProficiencies = inspirational.Proficiencies;

            var inspiration = 0;

            Diff += inspirational.Diff;

            for (var i = 0; i < givenProficiencies.Length; i++)
            {
                var val = givenProficiencies[i];

                if (val != 0)
                {
                    proficiencies[i] += val;
                    inspiration      += val * modifier;
                }
            }

            Inspiration += inspiration / 2;
        }