Пример #1
0
 public DublicateCommand(ICommandsList commands, int from, int to)
 {
     Commands = commands;
     Command  = commands[from];
     From     = from;
     To       = to;
 }
Пример #2
0
        private AddCommandMutation GetMutationForStop(ICommandsList commands, int indexToAdd)
        {
            var random = new AddRandom();

            random.TuneStop(indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Пример #3
0
        private ReplaceCommandMutation GetMutationForStop(ICommandsList commands, int replaceIndex)
        {
            var random = new ReplaceRandom();

            random.TuneStop(replaceIndex);
            return(new ReplaceCommandMutation(random, commands));
        }
 public DublicateCommand(ICommandsList commands, int from, int to)
 {
     Commands = commands;
     Command = commands[from];
     From = from;
     To = to;
 }
Пример #5
0
        private DublicateCommandMutation GetDublicateMutation(ICommandsList commands, int dublicateFrom, int dublicateTo)
        {
            var random = new DublicateRandom();

            random.Invoke(dublicateFrom, dublicateTo);
            return(new DublicateCommandMutation(random, commands));
        }
Пример #6
0
        private AddCommandMutation GetMutationForNewInt(ICommandsList commands, NewInt command, int indexToAdd)
        {
            var random = new AddRandom();

            random.TuneNewInt(command.Name, indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Пример #7
0
        private SwapCommandMutation GetSwapMutation(ICommandsList commands, int swapfirst, int swapsecond)
        {
            var random = new SwapRandom();

            random.Invoke(swapfirst, swapsecond);
            return(new SwapCommandMutation(random, commands));
        }
Пример #8
0
 public ReplaceCommand(ICommandsList commands, ICommand now, int index)
 {
     Commands = commands;
     Previous = commands[index];
     Now      = now;
     Index    = index;
 }
Пример #9
0
        private DeleteCommandMutation GetDeleteMutation(int indexToDelete, ICommandsList commands)
        {
            var random = new DeleteRandom();

            random.Invoke(indexToDelete);
            return(new DeleteCommandMutation(random, commands));
        }
Пример #10
0
        private ReplaceCommandMutation GetMutationForNewInt(ICommandsList commands, int replaceIndex, NewInt command)
        {
            var random = new ReplaceRandom();

            random.TuneNewInt(replaceIndex, command.Name);
            return(new ReplaceCommandMutation(random, commands));
        }
Пример #11
0
 public DeleteCommandMutation(Random random, ICommandsList commands)
 {
     _random           = random;
     _commands         = commands;
     _marks            = new bool[commands.Count];
     _removed          = new Stack <RemoveCommand>();
     _commandsToRemove = new List <RemoveCommand>();
 }
Пример #12
0
        private AddCommandMutation GetMutationForSetValue(ICommandsList commands, SetValue command, int indexToAdd)
        {
            var random           = new AddRandom();
            var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);

            random.TuneSetValue(declarationIndex, command.Value, indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Пример #13
0
        private AddCommandMutation GetMutationForConditionBlock(ICommandsList commands, Condition command, int ifIndex, int endIfIndex)
        {
            var random           = new AddRandom();
            var declarationIndex = GetDeclarationIndexOfVariable(command.ConditionName, commands);

            random.TuneConditionBlock(declarationIndex, ifIndex, endIfIndex);
            return(new AddCommandMutation(random, commands));
        }
Пример #14
0
        private AddCommandMutation GetMutationForPrint(ICommandsList commands, Print command, int indexToAdd)
        {
            var random           = new AddRandom();
            var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands);

            random.TunePrint(declarationIndex, indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Пример #15
0
 public DeleteCommandMutation(Random random, ICommandsList commands)
 {
     _random = random;
     _commands = commands;
     _marks = new bool[commands.Count];
     _removed = new Stack<RemoveCommand>();
     _commandsToRemove = new List<RemoveCommand>();
 }
Пример #16
0
        private ReplaceCommandMutation GetMutationForPrint(ICommandsList commands, int replaceIndex, Print command)
        {
            var random           = new ReplaceRandom();
            var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands);

            random.TunePrint(replaceIndex, declarationIndex);
            return(new ReplaceCommandMutation(random, commands));
        }
Пример #17
0
        private ReplaceCommandMutation GetMutationForSetValue(ICommandsList commands, int replaceIndex, SetValue command)
        {
            var random           = new ReplaceRandom();
            var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);

            random.TuneSetValue(replaceIndex, declarationIndex, command.Value);
            return(new ReplaceCommandMutation(random, commands));
        }
Пример #18
0
        private AddCommandMutation GetMutationForGetRandom(ICommandsList commands, GetRandom command, int indexToAdd)
        {
            var random = new AddRandom();
            var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
            var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.MaxValueName, commands);

            random.TuneGetRandom(targetDeclarationIndex, sourceDeclarationIndex, indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Пример #19
0
        private AddCommandMutation GetMutationForGetState(ICommandsList commands, GetState command, int indexToAdd)
        {
            var random = new AddRandom();
            var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
            var direction = command.Direction;

            random.TuneGetState(targetDeclarationIndex, direction, indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Пример #20
0
        private ReplaceCommandMutation GetMutationForGetRandom(ICommandsList commands, int replaceIndex, GetRandom command)
        {
            var random = new ReplaceRandom();
            var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
            var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.MaxValueName, commands);

            random.TuneGetRandom(replaceIndex, targetDeclarationIndex, sourceDeclarationIndex);
            return(new ReplaceCommandMutation(random, commands));
        }
Пример #21
0
        private ReplaceCommandMutation GetMutationForGetState(ICommandsList commands, int replaceIndex, GetState command)
        {
            var random           = new ReplaceRandom();
            var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
            var direction        = command.Direction;

            random.TuneGetState(replaceIndex, declarationIndex, direction);
            return(new ReplaceCommandMutation(random, commands));
        }
Пример #22
0
        private ReplaceCommandMutation GetMutationForPlus(ICommandsList commands, int replaceIndex, Plus command)
        {
            var random = new ReplaceRandom();
            var targetDeclarationIndex       = GetDeclarationIndexOfVariable(command.TargetName, commands);
            var firstSourceDeclarationIndex  = GetDeclarationIndexOfVariable(command.FirstSource, commands);
            var secondSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SecondSource, commands);

            random.TunePlus(replaceIndex, targetDeclarationIndex, firstSourceDeclarationIndex, secondSourceDeclarationIndex);
            return(new ReplaceCommandMutation(random, commands));
        }
Пример #23
0
        private bool AreCollectionsEquals(ICommandsList x, ICommandsList y)
        {
            if (x.Count != y.Count)
            {
                return(false);
            }
            var comparer = new CommandsEqualityComparer();

            return(!x.Where((t, i) => !comparer.IsEqual(t, y[i])).Any());
        }
Пример #24
0
        private AddCommandMutation GetMutationForPlus(ICommandsList commands, Plus command, int indexToAdd)
        {
            var random = new AddRandom();
            var targetDeclarationIndex       = GetDeclarationIndexOfVariable(command.TargetName, commands);
            var firstSourceDeclarationIndex  = GetDeclarationIndexOfVariable(command.FirstSource, commands);
            var secondSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SecondSource, commands);

            random.TunePlus(targetDeclarationIndex, firstSourceDeclarationIndex, secondSourceDeclarationIndex, indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Пример #25
0
 public Mutator(Random random, ICommandsList commands)
 {
     _random    = random;
     _commands  = commands;
     _mutations = new List <IMutation>
     {
         new AddCommandMutation(_random, _commands),
         new DeleteCommandMutation(_random, _commands),
         new DublicateCommandMutation(_random, _commands),
         new ReplaceCommandMutation(_random, _commands),
         new SwapCommandMutation(_random, _commands)
     };
 }
Пример #26
0
        private int GetDeclarationIndexOfVariable(string variable, ICommandsList commands)
        {
            int count = 0;

            foreach (NewInt command in commands.OfType <NewInt>())
            {
                if (command.Name == variable)
                {
                    return(count);
                }
                count++;
            }
            return(-1);
        }
Пример #27
0
 public ReplaceCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random   = random;
     _creator  = new CommandsCreator(random, commands);
     _handlers = new List <Func <int, ICommand> >
     {
         _creator.CreateCloseCondition,
         _creator.CreateCloneValue,
         _creator.CreateCondition,
         _creator.CreateGetRandom,
         _creator.CreateGetState,
         _creator.CreateMinus,
         _creator.CreateNewInt,
         _creator.CreatePlus,
         _creator.CreatePrint,
         _creator.CreateSetValue,
         _creator.CreateStop
     };
 }
Пример #28
0
 public ReplaceCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random = random;
     _creator = new CommandsCreator(random, commands);
     _handlers = new List<Func<int, ICommand>>
     {
         _creator.CreateCloseCondition,
         _creator.CreateCloneValue,
         _creator.CreateCondition,
         _creator.CreateGetRandom,
         _creator.CreateGetState,
         _creator.CreateMinus,
         _creator.CreateNewInt,
         _creator.CreatePlus,
         _creator.CreatePrint,
         _creator.CreateSetValue,
         _creator.CreateStop
     };
 }
Пример #29
0
 public AddCommandMutation(Random random, ICommandsList commands)
 {
     _random   = random;
     _commands = commands;
     _creator  = new CommandsCreator(random, commands);
     _added    = new Stack <AddCommand>();
     _handlers = new List <Action <int> >
     {
         AddNewInt,
         AddCloneValue,
         AddConditionBlock,
         AddGetRandom,
         AddGetState,
         AddMinus,
         AddPlus,
         AddPrint,
         AddSetValue,
         AddStop
     };
 }
Пример #30
0
 private bool AreCollectionsEquals(ICommandsList x, ICommandsList y)
 {
     if (x.Count != y.Count) return false;
     var comparer = new CommandsEqualityComparer();
     return !x.Where((t, i) => !comparer.IsEqual(t, y[i])).Any();
 }
Пример #31
0
 public CommandsCreator(Random random, ICommandsList commands)
 {
     _random   = random;
     _commands = commands;
 }
Пример #32
0
 private ReplaceCommandMutation GetMutationForPrint(ICommandsList commands, int replaceIndex, Print command)
 {
     var random = new ReplaceRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands);
     random.TunePrint(replaceIndex, declarationIndex);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #33
0
 public RemoveCommand(ICommandsList commands, int index)
 {
     Commands = commands;
     Command = commands[index];
     Index = index;
 }
Пример #34
0
 private AddCommandMutation GetMutationForSetValue(ICommandsList commands, SetValue command, int indexToAdd)
 {
     var random = new AddRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     random.TuneSetValue(declarationIndex, command.Value, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Пример #35
0
 private AddCommandMutation GetMutationForPlus(ICommandsList commands, Plus command, int indexToAdd)
 {
     var random = new AddRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var firstSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.FirstSource, commands);
     var secondSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SecondSource, commands);
     random.TunePlus(targetDeclarationIndex, firstSourceDeclarationIndex, secondSourceDeclarationIndex, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Пример #36
0
 private ReplaceCommandMutation GetMutationForNewInt(ICommandsList commands, int replaceIndex, NewInt command)
 {
     var random = new ReplaceRandom();
     random.TuneNewInt(replaceIndex, command.Name);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #37
0
 private ReplaceCommandMutation GetMutationForStop(ICommandsList commands, int replaceIndex)
 {
     var random = new ReplaceRandom();
     random.TuneStop(replaceIndex);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #38
0
 public DublicateCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random   = random;
 }
Пример #39
0
 public SwapCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random = random;
 }
Пример #40
0
 private ReplaceCommandMutation GetMutationForGetState(ICommandsList commands, int replaceIndex, GetState command)
 {
     var random = new ReplaceRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var direction = command.Direction;
     random.TuneGetState(replaceIndex, declarationIndex, direction);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #41
0
 private ReplaceCommandMutation GetMutationForSetValue(ICommandsList commands, int replaceIndex, SetValue command)
 {
     var random = new ReplaceRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     random.TuneSetValue(replaceIndex, declarationIndex,command.Value);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #42
0
 public AddCommand(ICommandsList commands, ICommand command, int index)
 {
     Commands = commands;
     Command  = command;
     Index    = index;
 }
Пример #43
0
 private AddCommandMutation GetMutationForConditionBlock(ICommandsList commands, Condition command, int ifIndex, int endIfIndex)
 {
     var random = new AddRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.ConditionName, commands);
     random.TuneConditionBlock(declarationIndex, ifIndex, endIfIndex);
     return new AddCommandMutation(random, commands);
 }
Пример #44
0
 private AddCommandMutation GetMutationForGetState(ICommandsList commands, GetState command, int indexToAdd)
 {
     var random = new AddRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var direction = command.Direction;
     random.TuneGetState(targetDeclarationIndex, direction, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Пример #45
0
 private SwapCommandMutation GetSwapMutation(ICommandsList commands, int swapfirst, int swapsecond)
 {
     var random = new SwapRandom();
     random.Invoke(swapfirst, swapsecond);
     return new SwapCommandMutation(random, commands);
 }
Пример #46
0
 private int GetDeclarationIndexOfVariable(string variable, ICommandsList commands)
 {
     int count = 0;
     foreach (NewInt command in commands.OfType<NewInt>())
     {
         if (command.Name == variable) return count;
         count++;
     }
     return -1;
 }
Пример #47
0
 private ReplaceCommandMutation GetMutationForGetRandom(ICommandsList commands, int replaceIndex, GetRandom command)
 {
     var random = new ReplaceRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.MaxValueName, commands);
     random.TuneGetRandom(replaceIndex, targetDeclarationIndex, sourceDeclarationIndex);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #48
0
 private AddCommandMutation GetMutationForGetRandom(ICommandsList commands, GetRandom command, int indexToAdd)
 {
     var random = new AddRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.MaxValueName, commands);
     random.TuneGetRandom(targetDeclarationIndex, sourceDeclarationIndex, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Пример #49
0
 public CommandsListWithLogger(ICommandsList commands, ILogger logger)
 {
     _commands = commands;
     _logger = logger;
 }
Пример #50
0
 private AddCommandMutation GetMutationForNewInt(ICommandsList commands, NewInt command, int indexToAdd)
 {
     var random = new AddRandom();
     random.TuneNewInt(command.Name, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Пример #51
0
 private DublicateCommandMutation GetDublicateMutation(ICommandsList commands, int dublicateFrom, int dublicateTo)
 {
     var random=new DublicateRandom();
     random.Invoke(dublicateFrom, dublicateTo);
     return new DublicateCommandMutation(random, commands);
 }
Пример #52
0
 private AddCommandMutation GetMutationForPrint(ICommandsList commands, Print command, int indexToAdd)
 {
     var random = new AddRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands);
     random.TunePrint(declarationIndex, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Пример #53
0
 public CommandsListWithLogger(ICommandsList commands, ILogger logger)
 {
     _commands = commands;
     _logger   = logger;
 }
Пример #54
0
 private AddCommandMutation GetMutationForStop(ICommandsList commands, int indexToAdd)
 {
     var random = new AddRandom();
     random.TuneStop(indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Пример #55
0
 public DublicateCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random = random;
 }
Пример #56
0
 public ReplaceCommand(ICommandsList commands, ICommand now, int index)
 {
     Commands = commands;
     Previous = commands[index];
     Now = now;
     Index = index;
 }
Пример #57
0
 private ReplaceCommandMutation GetMutationForPlus(ICommandsList commands, int replaceIndex, Plus command)
 {
     var random = new ReplaceRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var firstSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.FirstSource, commands);
     var secondSourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SecondSource, commands);
     random.TunePlus(replaceIndex, targetDeclarationIndex, firstSourceDeclarationIndex, secondSourceDeclarationIndex);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #58
0
 public SwapCommand(ICommandsList commands, int first, int second)
 {
     Commands = commands;
     First = first;
     Second = second;
 }
Пример #59
0
 private DeleteCommandMutation GetDeleteMutation(int indexToDelete, ICommandsList commands)
 {
     var random = new DeleteRandom();
     random.Invoke(indexToDelete);
     return new DeleteCommandMutation(random, commands);
 }