public Creature(Executor executor, ICommand[] commandsForGetDirection, ICommand[] commandsForGetAction) { _executor = executor; CommandsForGetDirection = commandsForGetDirection; CommandsForGetAction = commandsForGetAction; }
public Creature(Point position, Executor executor, ICommand[] commands, Random random, int generation) { _position = position; _executor = executor; _commands = commands; _random = random; Generation = generation; }
public override BaseCreature MakeChild(BaseCreature parent) { var parentAsCreature = parent as Creature; if (parentAsCreature == null) throw new ArgumentException(); var childsDirections = Mutate(parentAsCreature.CommandsForGetDirection); var childsActions = Mutate(parentAsCreature.CommandsForGetAction); var executor = new Executor(); var child = new Creature(executor, childsDirections, childsActions); return child; }
protected void Check(string commands, IExecutorToolset executorToolset, params int[] values) { var parsedCommands = new Parser().ProcessCommands(commands).ToArray(); var output = new Executor().Execute(parsedCommands, executorToolset) .Replace("\r\n", "\n") .Split('\n') .Where(item => !string.IsNullOrEmpty(item)) .Select(int.Parse) .ToList(); Assert.AreEqual(values.Count(), output.Count()); for (var i = 0; i < values.Count(); i++) { Assert.AreEqual(values[i], output[i]); } }
public override BaseCreature CreateAbstractCreature() { var executor = new Executor(); return new Creature(executor, _commandsForGetDirection, _commandsForGetAction); }
public void FillStartMatrixRandomly() { var random = new Random(); //var i = random.Next(N); //var j = random.Next(M); var executor = new Executor(); var commands = new SeedGenerator().StartAlgorithm; //Cells[20, 20] = new Creature(new Point(20, 20), executor, commands, random); for (int i = 0; i < Length; i++) { for (int j = 0; j < Width; j++) { Cells[i, j] = random.Next(100) % 4 == 0 ? new Creature(new Point(i, j), executor, commands, random, 1) : null; } } CanBeReached(); }