public static void ApplyTurn(GameState state, string cmds) { //Backup var backup = new Backup(state); string pat = @"o\s(\d+)\s(\d+)\s(\w)"; Regex r = new Regex(pat, RegexOptions.IgnoreCase); Match m = r.Match(cmds); while (m.Success) { int row = int.Parse(m.Groups[1].Captures[0].Value); int col = int.Parse(m.Groups[2].Captures[0].Value); var ant = new Ant(row, col, 0); var dir = DirectionExtensions.FromChar(m.Groups[3].Captures[0].Value[0]); MoveAnt(backup, state, ant, dir); m = m.NextMatch(); } backup.Restore(state); }
public WirePathStep(string inputString) { this.direction = DirectionExtensions.FromChar(inputString[0]); this.stepLength = int.Parse(inputString.Substring(1, inputString.Length - 1)); }