Exemplo n.º 1
0
        public void Generate(Entity entity, Random random, double percent, int tree)
        {
            if (OKField == null)
            {
                OKField   = new Field();
                FailField = new Field();
            }

            OKField.Generate(entity, random, percent, tree);
            FailField.Generate(entity, random, percent, tree);

            if (AvailableAnalyzers == null)
            {
                AvailableAnalyzers = AppDomain.CurrentDomain.GetAssemblies()
                                     .SelectMany(s => s.GetTypes())
                                     .Where(p => typeof(IAnalyzer).IsAssignableFrom(p)).ToList();
                AvailableAnalyzers.Remove(typeof(IAnalyzer));
            }

            if (Analyzer == null)
            {
                test = percent;
            }

            if (percent - random.NextDouble() >= 0)
            {
                Analyzer = (Activator.CreateInstance(AvailableAnalyzers.ElementAt(random.Next(0, AvailableAnalyzers.Count()))) as IAnalyzer);
                Analyzer.Generate(entity, random, percent);
            }
            else
            {
                Analyzer.Generate(entity, random, percent);
            }
        }
Exemplo n.º 2
0
 public Code Run(Entity entity, Tick tick)
 {
     if (Analyzer.Analyze(entity, tick))
     {
         OKField.Run(entity, tick);
     }
     else
     {
         FailField.Run(entity, tick);
     }
     return(Code.Add);
 }
Exemplo n.º 3
0
 public ICommand Clone() => new Analyze()
 {
     Analyzer = Analyzer.Clone(), FailField = (Field)FailField.Clone(), OKField = (Field)OKField.Clone()
 };