public void ThenTheChildContainsAMixtureOfTheGeneticCode()
        {
            PlantCrossOver crossOver          = new PlantCrossOver(new System.Random());
            RuleSet        leftParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "F", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "+F[+F+F]"
                      }
                  } }
            });

            RuleSet rightParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "F", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "-F[-F-F]"
                      }
                  } }
            });


            RuleSet result = crossOver.CrossOverV2(leftParentRuleSets, rightParentRuleSets);
            string  fRule  = result.Rules["F"][0].Rule;

            Debug.Log(fRule);
            Assert.That(fRule, Is.EqualTo("+F[+F+F]").Or.EqualTo("+F[-F-F]").Or.EqualTo("-F[+F+F]").Or.EqualTo("-F[-F-F]"));
        }
        public void ThenTheEntireCrossOverRuleIsWrappedInBrackets()
        {
            PlantCrossOver crossOver          = new PlantCrossOver(new System.Random());
            RuleSet        leftParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "L", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "['''^^O]"
                      }
                  } }
            });

            RuleSet rightParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "L", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "[[-FA\\L^S]'''^^O]"
                      }
                  } }
            });

            RuleSet result = crossOver.CrossOverV2(leftParentRuleSets, rightParentRuleSets);
            string  lRule  = result.Rules["L"][0].Rule;

            Debug.Log(lRule);
            Assert.That(lRule[0], Is.EqualTo('['));
            Assert.That(lRule[lRule.Length - 1], Is.EqualTo(']'));
        }
        public void ThenTheChildContainsEitherTheParentsDna()
        {
            PlantCrossOver crossOver          = new PlantCrossOver(new System.Random());
            RuleSet        leftParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "F", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "+F+F"
                      }
                  } }
            });

            RuleSet rightParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "F", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "-F-F"
                      }
                  } }
            });

            RuleSet result = crossOver.CrossOverV2(leftParentRuleSets, rightParentRuleSets);
            string  fRule  = result.Rules["F"][0].Rule;

            Assert.That(fRule, Is.EqualTo(leftParentRuleSets.Rules["F"][0].Rule).Or.EqualTo(rightParentRuleSets.Rules["F"][0].Rule));
        }
        public void ThenTheChildContainsTheMissingRule()
        {
            PlantCrossOver crossOver          = new PlantCrossOver(new System.Random());
            RuleSet        leftParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "F", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "+F[+F+F]"
                      }
                  } }
            });

            RuleSet rightParentRuleSets = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "F", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "-F[-F-F]"
                      }
                  } },
                { "A", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "-A[-A-A]"
                      }
                  } },
            });

            RuleSet result = crossOver.CrossOverV2(leftParentRuleSets, rightParentRuleSets);

            Assert.That(result.Rules["A"], Is.Not.Null);
        }