Exemplo n.º 1
0
        private static bool Output(long status)
        {
            var previousPosition  = droidPosition;
            var attemptedPosition = Compass.PositionAfterMovement(droidPosition, Attempt);

            if (status == 0)
            {
                // The repair droid hit a wall. Its position has not changed.
                area.Set(attemptedPosition, Day15Cell.Wall);
                Day15Debug.Set(attemptedPosition, Day15Cell.Wall);
                Day15Debug.WriteLine("BLOCKED");
            }
            else
            {
                // The repair droid has moved one step in the requested direction.
                Day15Debug.WriteLine("OK");
                droidPosition = attemptedPosition;
                if (!Backtracking)
                {
                    area.Set(attemptedPosition, Day15Cell.Open);
                    Day15Debug.Set(attemptedPosition, Day15Cell.Open);
                    if (status == 2)
                    {
                        oxygenSystemPosition = attemptedPosition;
                    }
                    EnteredFrom[attemptedPosition] = Attempt;
                    Visited.Add(attemptedPosition);
                    Attempts.Push(Compass.AllDirections);
                }
            }

            return((Attempts.Count() > 1) || (Attempts.Peek().Count > 0));
        }