static void Main(string[] args) { string[] inputs; inputs = Console.ReadLine().Split(' '); int W = int.Parse(inputs[0]); // number of columns. int H = int.Parse(inputs[1]); // number of rows. var map = new List<int[]>(); for (int i = 0; i < H; i++) { string LINE = Console.ReadLine(); // represents a line in the grid and contains W integers. Each integer represents one room of a given type. map.Add(LINE.Split(' ').Select(x => int.Parse(x)).ToArray()); } int EX = int.Parse(Console.ReadLine()); // the coordinate along the X axis of the exit (not useful for this first mission, but must be read). var exit = new Point(EX, H-1, Direction.TOP); var dfs = new DFS(map); // game loop while (true) { inputs = Console.ReadLine().Split(' '); int XI = int.Parse(inputs[0]); int YI = int.Parse(inputs[1]); string POSI = inputs[2]; var indy = new Point(XI, YI, directionOf(POSI)); int R = int.Parse(Console.ReadLine()); // the number of rocks currently in the grid. var rocks = new Point[R]; for (int i = 0; i < R; i++) { inputs = Console.ReadLine().Split(' '); int XR = int.Parse(inputs[0]); int YR = int.Parse(inputs[1]); string POSR = inputs[2]; rocks[i] = new Point(XR, YR, directionOf(POSR)); } //TODO: Add rocks to DFS Console.Error.WriteLine("Indy is at " + indy + " from the " + indy.Position + " which is tile #" + dfs.RoomTypeAt(indy)); var path = dfs.To(indy, exit, rocks); Console.WriteLine(path); if (path != "WAIT") { var s = path.Split(' '); var pos = new Point(int.Parse(s[0]), int.Parse(s[1]), directionOf(s[2])); var oldType = dfs.RoomTypeAt(pos); dfs.Rotate(pos, 4 - (int)pos.Position); Console.Error.WriteLine("Storing change of tile at " + pos + " from a #" + oldType + " to a #" + dfs.RoomTypeAt(pos)); } else { Console.Error.WriteLine("Indy waited"); } } }