You are given a square board containing N by N cells. On the board you have destructible walls, non-destructible walls, open spaces and power-ups. You control a character called the Xplosion man who can move around, collect power-ups and plant bombs. The Xplosion man can move through cells with planted bombs without any effect on them, but cannot move through either type of walls. A planted bomb will explode after T turns and it will destroy objects lying in a range R in the same row or column as the exploding bomb. The effects of the explosions on different types of objects are as follows:
- Open space : No effect.
- Non-destructible wall : The wall remains, and the explosion does not propagate beyond the wall.
- Destructible wall : The wall is destroyed, and the explosion does not propagate beyond the wall. The destroyed wall will prevent any other explosion during the same turn from propagating beyond it.
- Power-up : The power-up is destroyed, and the explosion propagates to cells beyond it.
- Planted bomb : The bomb explodes and the effects of the new explosion are handled recursively.
- Xplosion man : No effect.
You earn points by destroying destructible walls. After each bomb explodes, your score increases by the square of the number of walls destroyed with all explosions triggered by it. Your task is to maximize the sum of the scores gained during individual explosions.
Your code should implement the method makeMoves(String board, int T, int B, int R). Your makeMoves method will be called once and should return a String containing the actions of the Xplosion man. You are allowed to make a maximum of N*N*10 actions.
- board gives the board containing N by N cells. Each element of board describes one row of the board. '.' denotes an empty space. '#' denotes a non-destructible wall. '+' denotes a destructible wall. 'T', 'B' and 'R' denote time, bomb and range power-ups respectively.
- T gives the initial time that a planted bomb takes before it explodes. Collecting K-th time power-up will increase the time between bomb planting and bomb explosion by K (each next power-up is more powerful).
- B gives the initial number of bombs that you have available to plant. Collecting each bomb power-up will increase your amount of bombs by one. Once a bomb has exploded, it will be available to be planted again.
- R gives the initial range of the explosion that a bomb will cause. Collecting K-th range power-up will increase the range of explosions for bombs planted in future by K (each next power-up is more powerful). Once you planted a bomb, the range for that specific bomb will remain fixed even if you collected a range power-up before it exploded.
You must return the list of actions that the Xplosion man will perform. Each character of your return describes one action. ROW is the zero based row and COL the zero based column of the board. The top left corner of the board corresponds to row and column zero. The Xplosion man always starts at location (1,1). The possible actions are:
- U : Up, moves to location (ROW-1, COL).
- D : Down, moves to location (ROW+1, COL).
- L : Left, moves to location (ROW, COL-1).
- R : Right, moves to location (ROW, COL+1).
- B : Plants a bomb at your current location (ROW, COL) if there is no bomb there yet.
- T : Set the bomb timer of the planted bomb with the lowest bomb timer to 1. This bomb will explode in the next turn. If there is more than one bomb with the same lowest timer value, the one in the lowest row will be chosen. If there is still a tie, the one with the lowest column will be chosen. Only one bomb is affected.
- If you attempt any invalid action, it will simply be ignored and the simulation will continue.
The sequence of events for each action follows:
- Decrease bomb timers for all planted bombs by one, following a row column major order.
- Once a bomb timer reaches zero, the bomb explodes.
- A bomb explosion might trigger more explosions which will be handled first before moving on to decreasing the timer of the next bomb.
- Your action will be processed and the board updated accordingly.
This sequence is repeated until there are no destructible walls left or when you don't have any actions left to perform. The simulation stops immediately after that, and any bombs left on the board after that don't explode.
For each test case we will calculate your raw and normalized scores. If you were not able to produce a valid return value, then your raw score is -1 and the normalized score is 0. Otherwise, the raw score is equal to the sum of scores over all explosions. The normalized score for each test is 1,000,000.0 * YOUR / BEST, where BEST is the highest score currently obtained on this test case (considering only the last submission from each competitor). Finally, your total score is equal to the arithmetic average of normalized scores on all test cases.
You can see your raw scores on each example test case by making an example submit. You can also see total scores of all competitors on provisional test set in the match standings. No other information about scores is available during the match.
Test Case Generation
Please look at the visualizer source code for the exact details of test case generation. Each test case is generated as follows:
- The board size N is randomly selected between 21 and 61 (inclusive).
- The number of power-ups is randomly selected between 5 and 50. All types of power-ups are equally likely to be selected.
- The fill ratio P is chosen between 0.6 and 0.9. This determines the number of destructible walls on the board.
- The initial values of T, B and R is independently randomly selected between 1 and 5.
- All values are chosen uniformly and independently, at random. Ranges are inclusive.
An offline tester/visualizer is available here.
You can use it to test/debug your solution locally.
You can also check its source code for exact implementation of test case generation, simulation and score calculation.