Ejemplo n.º 1
0
        public Movement GetMovement(Creature creature)
        {
            ProcessingCreature processingCreature = new ProcessingCreature(creature, TotalCommands, _field);

            while (processingCreature.NotProcessed())
            {
                var dnaNode = processingCreature.ProcessingIndex >= processingCreature.Dna.Length
                    ? DnaNode.Create <MoveProcessor>(0)
                    : processingCreature.Dna[processingCreature.ProcessingIndex];
                var command = dnaNode.Processor.Process(dnaNode.LocalCommand, processingCreature);
                if (command != null)
                {
                    return(command.Movement);
                }
            }
            // Infinitive loop
            return(MoveProcessor.NullMovement(processingCreature.Direction));
        }