Tron Racers Java Advanced Exam - 24 February 2019
Здравейте!Може ли помощ за кода ми.Дава ми само 70.Мерси предварително!
https://pastebin.com/h9WnyBBL
02. Tron Racers
The new TRON tournament has started and you have to keep track of the players on the field.
You will be given an integer n for the size of the matrix. On the next n lines, you will receive the rows of the matrix. The game starts with two players (first player is marked with "f" and the second player is marked with "s") in random positions and all of the empty slots will be filled with "*".
Each turn you will be given commands respectively for each player’s movement. The first command is for the first player and the second is for the second player. After a player moves, he leaves a trail on the field. The symbol that marks the trail is the same as the player's symbol. If a player goes out of the matrix, he comes in from the other side. If a player steps on the other player's trail, he dies. When a player dies in the field, you should write "x" in the position where he died.
When only one of the players is left alive on the field the game ends.
Input
- On the first line, you are given the integer N – the size of the square matrix.
- The next N lines holds the values for every row.
- On each of the next lines you will get two commands in the format up, down, left or right.
Output
- In the end print the matrix.
Constraints
- The size of the matrix will be between [2…20].
- There will always be exactly two players.
- The players will always be indicated with "f" for the first one and "s" for the second one.
- There will always be enough commands to finish the game with one player alive.
- There will not be commands where a player goes back and steps on his trail from the previous turn.
Examples
Input |
Output |
Comments |
5 ***f* **s** ***** ***** ***** down down right down down right down down down left left left |
***f* **sff **s*f **ssf **sxf |
The first command is down down so f moves down and s moves down. After each turn the field is: 1 2 3 4 5 6 ***f* ***f* ***f* ***f* ***f* ***f* **sf* **sff **sff **sff **sff **sff **s** **s** **s*f **s*f **s*f **s*f ***** **s** **ss* **ssf **ssf **ssf ***** ***** ***** ***s* **ssf **sxf On turn 6 f crashes into s's trail and f dies. As there is only one player left alive s is the only one left he is the winner. |
4 *f** **** **s* **** down up down right right right |
*f** *fss *fx* **** |
Here in the third turn f crashes into s's trail so again we don't need to print s's third position because he has won. |