I. 364. We are controlling a robot on an \(\displaystyle n\times n\) grid. The robot can move in four directions along empty grid cells. The robot cannot pass through the four walls surrounding the board, and there are also some obstacles inside blocking its way. To control the robot, we use the letters F, L, J and B (= up, down, right, left): when pressing any of these keys, the robot starts moving in a straight line in the given direction until it touches an obstacle or a wall. The example shows a grid with \(\displaystyle n=10\) and with some obstacles (``X'').
Your program i364 should solve the following tasks.
1. Read the board description from the text file palya.txt. The first line of the file contains the value of \(\displaystyle 1\le n\le 20\), the next line describes the number of obstacles, then each successive line contains the (column and row) coordinates (separated by a space) of the obstacles.
2. You should draw a map of the board by using X characters to denote the corners and inner obstacles, and the last digits of the column and row coordinates to denote the walls on each side.
3. Prompt the user to enter a column/row pair, then check if the corresponding grid cell is empty. The output should be a message such as ``The cell (3,5) is empty.''
4. Choose a free cell randomly and store its location for later use. A message such as ``The starting cell of the robot is (6,4).'' should be displayed.
5. Determine the coordinates of the cells that can be reached in one step (that is, in a straight line) by using the given starting cell. By using the previous example, the output would be ``The cells (6,3), (6,7), (3,4) and (10,4) can be reached in one step.''
6. Prompt the user to enter a character string encoding commands to the robot. Apart from the lowercase and uppercase characters denoting valid directions, all other characters should be ignored. The following data should be written in the text file mozgas.txt: the starting cell coordinates, and the coordinates of the cells the robot stops at when executing the movement commands. The robot should start from the cell chosen in Task 4 above. A sample user input can be ``FFjLeBF'' for example.
7. The previous user input should be corrected and simplified as follows: the modified version should contain only uppercase letters encoding valid directions, but directions that do not change the robot position on the given board should also be ignored. The modified string for the previous example thus becomes ``The modified string of directions is FJLBF''.
The table in the example contains a sample input (``Példa bemenet'') and output (``Példa kimenet'').
The source code (i364.pas, i364.cpp, ...) without the .exe or any other auxiliary files generated by the compiler but with a short documentation (i364.txt, i364.pdf, ...), also describing which developer environment to use for compiling the source, should be submitted in a compressed file i364.zip.
Deadline expired on 10 February 2015.