Exemple #1
0
 public Warrior Execute(Warrior father, Warrior mother, Parameter parameter)
 {
     if (father.CodeLines.Count() >= parameter.MarsParameters.MaxWarriorLen) return father;
     List<WarriorLine> newLines = new List<WarriorLine>(father.CodeLines);
     newLines.Insert(Statics.MainRandom.Next(father.CodeLines.Count()), Generator.GenerateRandomLine(parameter.MarsParameters.Coresize));
     father.CodeLines = newLines.ToArray();
     return father;
 }
Exemple #2
0
 public Warrior Execute(Warrior father, Warrior mother, Parameter parameter)
 {
     for (int i = 0; i < Statics.MainRandom.Next(father.CodeLines.Count() / 2); i++)
     {
         father.CodeLines[Statics.MainRandom.Next(father.CodeLines.Count())].Instructor = (Instructors)(byte)Statics.MainRandom.Next(EnumHelper.GetEnumLen(typeof(Instructors)));
     }
     return father;
 }
Exemple #3
0
 public Warrior Execute(Warrior father, Warrior mother, Parameter parameter)
 {
     if (father.CodeLines.Count() <= 2) return father;
     List<WarriorLine> newLines = new List<WarriorLine>(father.CodeLines);
     newLines.RemoveRange(Statics.MainRandom.Next(father.CodeLines.Count()), 1);
     father.CodeLines = newLines.ToArray();
     return father;
 }
Exemple #4
0
 public Warrior Execute(Warrior father, Warrior mother, Parameter parameter)
 {
     for (int i = 0; i < Statics.MainRandom.Next(father.CodeLines.Count() / 2); i++)
     {
         if (Statics.MainRandom.NextDouble() >= 0.5)
             father.CodeLines[Statics.MainRandom.Next(father.CodeLines.Count())].Number1 =
                 (short)Statics.MainRandom.Next(parameter.MarsParameters.Coresize);
         else
             father.CodeLines[Statics.MainRandom.Next(father.CodeLines.Count())].Number2 =
                 (short)Statics.MainRandom.Next(parameter.MarsParameters.Coresize);
     }
     return father;
 }
Exemple #5
0
        public Grid(Parameter parameters, Cell[,] cells, List<GridWarrior> warriors)
        {
            StartingTime = DateTime.Now;
            Parameters = parameters;

            Sleeper = new ConcurrentQueue<Warrior>();
            Cells = cells;
            Warriors = warriors;

            _usedSimulator = new Simulator(parameters);
            _evolver = new Evolver.Evolver(parameters);
            _run = false;
        }
Exemple #6
0
        public Grid(Parameter parameters)
        {
            StartingTime = DateTime.Now;
            Parameters = parameters;

            Sleeper = new ConcurrentQueue<Warrior>();
            Cells = new Cell[Parameters.GridParameters.Size, Parameters.GridParameters.Size];
            Warriors = new List<GridWarrior>();

            _usedSimulator = new Simulator(parameters);
            _evolver = new Evolver.Evolver(parameters);
            _run = false;

            FillGrid();
        }
 public Warrior Execute(Warrior father, Warrior mother, Parameter parameter)
 {
     for (int i = 0; i < Statics.MainRandom.Next(father.CodeLines.Count() / 2); i++)
     {
         if (Statics.MainRandom.NextDouble() >= 0.5)
             father.CodeLines[Statics.MainRandom.Next(father.CodeLines.Count())].AddressingMode1 =
                 (AddressingModes)
                     (byte) Statics.MainRandom.Next(EnumHelper.GetEnumLen(typeof (AddressingModes)));
         else
             father.CodeLines[Statics.MainRandom.Next(father.CodeLines.Count())].AddressingMode2 =
                 (AddressingModes)
                     (byte) Statics.MainRandom.Next(EnumHelper.GetEnumLen(typeof (AddressingModes)));
     }
     return father;
 }
Exemple #8
0
        public Warrior Execute(Warrior father, Warrior mother, Parameter parameter)
        {
            switch (Statics.MainRandom.Next(5))
            {
                case 0:
                    return Random(father, mother);
                case 1:
                    return UpperLower(father, mother);
                case 2:
                    return UpperUpper(father, mother);
                case 3:
                    return LowerLower(father, mother);
                case 4:
                    return LowerUpper(father, mother);
            }

            return Random(father, mother);
        }
Exemple #9
0
        public PluginManager(Parameter parameter)
        {
            // Basic hardcoded plugins
            Plugins = new List<IEvolverPlugin>
            {
                new AddLine(),
                new ChangeAddressingModes(),
                new ChangeEnd(),
                new ChangeInstructors(),
                new ChangeModifiers(),
                new ChangeNumbers(),
                new Crossover(),
                new RemoveLine()
            };

            LoadPlugins();

            foreach (PluginChance pluginChance in parameter.EvolverParameters.Plugins)
            {
                this[pluginChance.Name].Chance = pluginChance.Chance;
            }
        }
Exemple #10
0
 public Evolver(Parameter parameters)
 {
     Parameters = parameters;
     PluginManager = new PluginManager(parameters);
 }
Exemple #11
0
 private void restartToolStripMenuItem_Click(object sender, EventArgs e)
 {
     grid.StopAsync();
     Paras = ParameterLoader.FromFile("settings.cfg");
     grid = new Grid(Paras);
     grid.StartAsync(Threads);
 }
Exemple #12
0
 public Warrior Execute(Warrior father, Warrior mother, Parameter parameter)
 {
     father.EndLine = new WarriorEndLine((short)Statics.MainRandom.Next(father.CodeLines.Count()));
     return father;
 }
Exemple #13
0
 public bool Possible(Warrior father, Parameter parameter)
 {
     return father.CodeLines.Count() < parameter.MarsParameters.MaxWarriorLen - 1;
 }
Exemple #14
0
 public bool Possible(Warrior father, Parameter parameter)
 {
     return father.CodeLines.Count() >= 2;
 }