Ejemplo n.º 1
0
 public DublicateCommand(ICommandsList commands, int from, int to)
 {
     Commands = commands;
     Command  = commands[from];
     From     = from;
     To       = to;
 }
Ejemplo n.º 2
0
        private AddCommandMutation GetMutationForStop(ICommandsList commands, int indexToAdd)
        {
            var random = new AddRandom();

            random.TuneStop(indexToAdd);
            return(new AddCommandMutation(random, commands));
        }
Ejemplo n.º 3
0
        private ReplaceCommandMutation GetMutationForStop(ICommandsList commands, int replaceIndex)
        {
            var random = new ReplaceRandom();

            random.TuneStop(replaceIndex);
            return(new ReplaceCommandMutation(random, commands));
        }
Ejemplo n.º 4
0
 public DublicateCommand(ICommandsList commands, int from, int to)
 {
     Commands = commands;
     Command = commands[from];
     From = from;
     To = to;
 }
Ejemplo n.º 5
0
        private DublicateCommandMutation GetDublicateMutation(ICommandsList commands, int dublicateFrom, int dublicateTo)
        {
            var random = new DublicateRandom();

            random.Invoke(dublicateFrom, dublicateTo);
            return(new DublicateCommandMutation(random, commands));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 7
0
        private SwapCommandMutation GetSwapMutation(ICommandsList commands, int swapfirst, int swapsecond)
        {
            var random = new SwapRandom();

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

            random.Invoke(indexToDelete);
            return(new DeleteCommandMutation(random, commands));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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>();
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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>();
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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)
     };
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
     };
 }
Ejemplo n.º 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
     };
 }
Ejemplo n.º 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
     };
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 31
0
 public CommandsCreator(Random random, ICommandsList commands)
 {
     _random   = random;
     _commands = commands;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 33
0
 public RemoveCommand(ICommandsList commands, int index)
 {
     Commands = commands;
     Command = commands[index];
     Index = index;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 37
0
 private ReplaceCommandMutation GetMutationForStop(ICommandsList commands, int replaceIndex)
 {
     var random = new ReplaceRandom();
     random.TuneStop(replaceIndex);
     return new ReplaceCommandMutation(random, commands);
 }
Ejemplo n.º 38
0
 public DublicateCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random   = random;
 }
Ejemplo n.º 39
0
 public SwapCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random = random;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 42
0
 public AddCommand(ICommandsList commands, ICommand command, int index)
 {
     Commands = commands;
     Command  = command;
     Index    = index;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 45
0
 private SwapCommandMutation GetSwapMutation(ICommandsList commands, int swapfirst, int swapsecond)
 {
     var random = new SwapRandom();
     random.Invoke(swapfirst, swapsecond);
     return new SwapCommandMutation(random, commands);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 49
0
 public CommandsListWithLogger(ICommandsList commands, ILogger logger)
 {
     _commands = commands;
     _logger = logger;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 51
0
 private DublicateCommandMutation GetDublicateMutation(ICommandsList commands, int dublicateFrom, int dublicateTo)
 {
     var random=new DublicateRandom();
     random.Invoke(dublicateFrom, dublicateTo);
     return new DublicateCommandMutation(random, commands);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 53
0
 public CommandsListWithLogger(ICommandsList commands, ILogger logger)
 {
     _commands = commands;
     _logger   = logger;
 }
Ejemplo n.º 54
0
 private AddCommandMutation GetMutationForStop(ICommandsList commands, int indexToAdd)
 {
     var random = new AddRandom();
     random.TuneStop(indexToAdd);
     return new AddCommandMutation(random, commands);
 }
Ejemplo n.º 55
0
 public DublicateCommandMutation(Random random, ICommandsList commands)
 {
     _commands = commands;
     _random = random;
 }
Ejemplo n.º 56
0
 public ReplaceCommand(ICommandsList commands, ICommand now, int index)
 {
     Commands = commands;
     Previous = commands[index];
     Now = now;
     Index = index;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 58
0
 public SwapCommand(ICommandsList commands, int first, int second)
 {
     Commands = commands;
     First = first;
     Second = second;
 }
Ejemplo n.º 59
0
 private DeleteCommandMutation GetDeleteMutation(int indexToDelete, ICommandsList commands)
 {
     var random = new DeleteRandom();
     random.Invoke(indexToDelete);
     return new DeleteCommandMutation(random, commands);
 }