Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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;
                    }
                }
            }
        }
Exemplo n.º 3
0
 public int DistanceTo(CellSquare point)
 {
     return(Math.Abs(X - point.X) + Math.Abs(Y - point.Y));
 }
Exemplo n.º 4
0
 public bool Equals(CellSquare other) => X == other.X && Y == other.Y;