static void Main(String[] args) { var collection = new InputCollection(Console.ReadLine()); var rand = new Random(); while (true) { var output = string.Empty; // Read information from standard input collection.ParseInput(); Console.Error.WriteLine("Control Room: {0}, Beam Location: {1}", collection.ControlRoom == null ? "none" : "found", collection.BeamLocation == null ? "none" : "found"); Console.Error.WriteLine("Traveled: {0}, Travelable: {1}", collection.TraveledPoints.Count, collection.TravelablePoints.Count); Console.Error.WriteLine("Kirk: {0}, {1}", collection.Kirk.X, collection.Kirk.Y); // Compute logic here if (collection.ControlRoom != null && !collection.ReachedControlRoom && collection.IsDistanceSafe()) { output = collection.GetDirectionToTarget(collection.ControlRoom); Console.Error.WriteLine("Going for Control Room: {0}, {1}", collection.ControlRoom.X, collection.ControlRoom.Y); } else if (collection.ReachedControlRoom) { output = collection.GetDirectionToTarget(collection.BeamLocation); Console.Error.WriteLine("Going for Beam Location: {0}, {1}", collection.BeamLocation.X, collection.BeamLocation.Y); } else { var validMoves = collection.ValidMoves(collection.Kirk); var nearestUnexplored = collection.GetNearestUnexploredPoint(); if (nearestUnexplored != null) { output = collection.GetDirectionToTarget(nearestUnexplored); } else { var randm = rand.Next(validMoves.Count); output = collection.GetDirection(collection.Kirk, validMoves[randm]); } } // Console.Error.WriteLine("Debug messages..."); // Write action to standard output Console.WriteLine(output); } }