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; }
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); }
public void Restart() { CurrentDirection = Direction.Right; CurrentCell = new Cell(0, 0); _currentState = Ant.InitialState; _currentField = _originalField.Clone(); }
public AntMover(FiniteAutomaton automation, AppleField field) { Ant = automation; _originalField = field; Restart(); }
public void Restart() { CurrentDirection = Direction.Right; CurrentCell = new Cell(0, 0); _currentState = Ant.InitialState; _currentField = _originalField.Clone(); }
public AntMover(FiniteAutomaton automation, AppleField field) { Ant = automation; _originalField = field; Restart(); }