Example #1
0
        public static AppleField ReadFieldFromStrings(string source)
        {
            var field = new AppleField();
            var lines = Regex.Split(source, "\r\n|\r|\n");

            int height = lines.Length;
            int width = width = lines.Max(x => x.Length);

            field.FieldHeight = height;
            field.FieldWidth = width;
            field._field = new bool[width, height];
            field.FoodCount = 0;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    field._field[i, j] = (lines[j][i] == '*');

                    if (field._field[i, j])
                        field.FoodCount++;
                }
            }

            return field;
        }
Example #2
0
        public static AppleField ReadFieldFromStrings(string source)
        {
            var field = new AppleField();
            var lines = Regex.Split(source, "\r\n|\r|\n");

            int height = lines.Length;
            int width  = width = lines.Max(x => x.Length);

            field.FieldHeight = height;
            field.FieldWidth  = width;
            field._field      = new bool[width, height];
            field.FoodCount   = 0;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    field._field[i, j] = (lines[j][i] == '*');

                    if (field._field[i, j])
                    {
                        field.FoodCount++;
                    }
                }
            }

            return(field);
        }
Example #3
0
        public void Restart()
        {
            CurrentDirection = Direction.Right;
            CurrentCell      = new Cell(0, 0);

            _currentState = Ant.InitialState;
            _currentField = _originalField.Clone();
        }
Example #4
0
 public AntMover(FiniteAutomaton automation, AppleField field)
 {
     Ant = automation;
     _originalField = field;
     Restart();
 }
Example #5
0
        public void Restart()
        {
            CurrentDirection = Direction.Right;
            CurrentCell = new Cell(0, 0);

            _currentState = Ant.InitialState;
            _currentField = _originalField.Clone();
        }
Example #6
0
 public AntMover(FiniteAutomaton automation, AppleField field)
 {
     Ant            = automation;
     _originalField = field;
     Restart();
 }