public DublicateCommand(ICommandsList commands, int from, int to) { Commands = commands; Command = commands[from]; From = from; To = to; }
private AddCommandMutation GetMutationForStop(ICommandsList commands, int indexToAdd) { var random = new AddRandom(); random.TuneStop(indexToAdd); return(new AddCommandMutation(random, commands)); }
private ReplaceCommandMutation GetMutationForStop(ICommandsList commands, int replaceIndex) { var random = new ReplaceRandom(); random.TuneStop(replaceIndex); return(new ReplaceCommandMutation(random, commands)); }
private DublicateCommandMutation GetDublicateMutation(ICommandsList commands, int dublicateFrom, int dublicateTo) { var random = new DublicateRandom(); random.Invoke(dublicateFrom, dublicateTo); return(new DublicateCommandMutation(random, commands)); }
private AddCommandMutation GetMutationForNewInt(ICommandsList commands, NewInt command, int indexToAdd) { var random = new AddRandom(); random.TuneNewInt(command.Name, indexToAdd); return(new AddCommandMutation(random, commands)); }
private SwapCommandMutation GetSwapMutation(ICommandsList commands, int swapfirst, int swapsecond) { var random = new SwapRandom(); random.Invoke(swapfirst, swapsecond); return(new SwapCommandMutation(random, commands)); }
public ReplaceCommand(ICommandsList commands, ICommand now, int index) { Commands = commands; Previous = commands[index]; Now = now; Index = index; }
private DeleteCommandMutation GetDeleteMutation(int indexToDelete, ICommandsList commands) { var random = new DeleteRandom(); random.Invoke(indexToDelete); return(new DeleteCommandMutation(random, commands)); }
private ReplaceCommandMutation GetMutationForNewInt(ICommandsList commands, int replaceIndex, NewInt command) { var random = new ReplaceRandom(); random.TuneNewInt(replaceIndex, command.Name); return(new ReplaceCommandMutation(random, commands)); }
public DeleteCommandMutation(Random random, ICommandsList commands) { _random = random; _commands = commands; _marks = new bool[commands.Count]; _removed = new Stack <RemoveCommand>(); _commandsToRemove = new List <RemoveCommand>(); }
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)); }
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)); }
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)); }
public DeleteCommandMutation(Random random, ICommandsList commands) { _random = random; _commands = commands; _marks = new bool[commands.Count]; _removed = new Stack<RemoveCommand>(); _commandsToRemove = new List<RemoveCommand>(); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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()); }
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)); }
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) }; }
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); }
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 }; }
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 }; }
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 }; }
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(); }
public CommandsCreator(Random random, ICommandsList commands) { _random = random; _commands = commands; }
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); }
public RemoveCommand(ICommandsList commands, int index) { Commands = commands; Command = commands[index]; Index = index; }
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); }
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); }
private ReplaceCommandMutation GetMutationForNewInt(ICommandsList commands, int replaceIndex, NewInt command) { var random = new ReplaceRandom(); random.TuneNewInt(replaceIndex, command.Name); return new ReplaceCommandMutation(random, commands); }
private ReplaceCommandMutation GetMutationForStop(ICommandsList commands, int replaceIndex) { var random = new ReplaceRandom(); random.TuneStop(replaceIndex); return new ReplaceCommandMutation(random, commands); }
public DublicateCommandMutation(Random random, ICommandsList commands) { _commands = commands; _random = random; }
public SwapCommandMutation(Random random, ICommandsList commands) { _commands = commands; _random = random; }
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); }
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); }
public AddCommand(ICommandsList commands, ICommand command, int index) { Commands = commands; Command = command; Index = index; }
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); }
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); }
private SwapCommandMutation GetSwapMutation(ICommandsList commands, int swapfirst, int swapsecond) { var random = new SwapRandom(); random.Invoke(swapfirst, swapsecond); return new SwapCommandMutation(random, commands); }
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; }
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); }
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); }
public CommandsListWithLogger(ICommandsList commands, ILogger logger) { _commands = commands; _logger = logger; }
private AddCommandMutation GetMutationForNewInt(ICommandsList commands, NewInt command, int indexToAdd) { var random = new AddRandom(); random.TuneNewInt(command.Name, indexToAdd); return new AddCommandMutation(random, commands); }
private DublicateCommandMutation GetDublicateMutation(ICommandsList commands, int dublicateFrom, int dublicateTo) { var random=new DublicateRandom(); random.Invoke(dublicateFrom, dublicateTo); return new DublicateCommandMutation(random, commands); }
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); }
private AddCommandMutation GetMutationForStop(ICommandsList commands, int indexToAdd) { var random = new AddRandom(); random.TuneStop(indexToAdd); return new AddCommandMutation(random, commands); }
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); }
public SwapCommand(ICommandsList commands, int first, int second) { Commands = commands; First = first; Second = second; }
private DeleteCommandMutation GetDeleteMutation(int indexToDelete, ICommandsList commands) { var random = new DeleteRandom(); random.Invoke(indexToDelete); return new DeleteCommandMutation(random, commands); }