Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public void Restart()
        {
            CurrentDirection = Direction.Right;
            CurrentCell      = new Cell(0, 0);

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

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