public IEnumerable <CellMove> Walk(CellSquare from, Step current) { var step = current.Next(); var cursor = from; for (var index = 0; index < Times; index++) { cursor = cursor.MoveLeft(); yield return(new CellMove(step, cursor, index == 0, index + 1 == Times)); step = step.Next(); } }
public IEnumerable <CellMove> Walk(CellSquare from) { var step = new Step(0); var cursor = from; foreach (var instruction in Instructions) { foreach (var move in instruction.Walk(cursor, step)) { yield return(move); if (move.LastInstructionMove) { cursor = move.Square; step = move.Step; } } } }
public int DistanceTo(CellSquare point) { return(Math.Abs(X - point.X) + Math.Abs(Y - point.Y)); }
public bool Equals(CellSquare other) => X == other.X && Y == other.Y;