Inheritance: ICommandVisitor
Ejemplo n.º 1
0
 public Creature(Executor executor, ICommand[] commandsForGetDirection, 
     ICommand[] commandsForGetAction)
 {
     _executor = executor;
     CommandsForGetDirection = commandsForGetDirection;
     CommandsForGetAction = commandsForGetAction;
 }
Ejemplo n.º 2
0
 public Creature(Point position, Executor executor, ICommand[] commands, Random random, int generation)
 {
     _position = position;
     _executor = executor;
     _commands = commands;
     _random = random;
     Generation = generation;
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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]);
            }
        }
Ejemplo n.º 5
0
 public override BaseCreature CreateAbstractCreature()
 {
     var executor = new Executor();
     return new Creature(executor, _commandsForGetDirection, _commandsForGetAction);
 }
Ejemplo n.º 6
0
        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();
        }