You operate on a 10x10 square map.
At each turn, your program receives the map of the forest and the state of each square.
Based on this data, your program must determine which forest square to send water to in order to put out the fire.
Unfortunately, under certain circumstances, as described below, fires spread to neighbouring squares.
To win you must put out all the fires, while limiting the number of squares burned to a maximum given to you in the variable
maxBurnedForest.
The map
Each of the 10 lines of the map is given to you by a string. Each character represents a cell of the map.
. represents an empty square with no forest. It cannot burn.
^ represents a forest square.
* represents a burned forest square. It can no longer catch fire.
1,
2 or
3 represents a forest square on fire. The value corresponds to the development level of the fire.
The spread of fire
Fire on a square can have 3 levels of development and, unless fought, evolves as such:
- fires grow by one level per turn,
- except for level 3 fires which, on the next turn, turn into burned forest squares and spread the fire to their 4 neighbouring squares (N/S/E/W) if
- the neighbouring square is a forest square, not burned,
- there is not already a fire on this square.
The fire on these neighbouring squares starts at level 1.
Fighting fire
Once per turn you can extinguish the fire in a square by spraying it with water.
The fire in this square is extinguished immediately and does not spread to neighbouring squares.
To determine the box for which you want to fight the fire, you simply write its
x and
y coordinates (or column and row) on the standard output.
Sequence of actions
In each turn, the game follows the following actions, in this order
- Extinguish the fire on the square determined by your program.
- Evolution of the remaining fires (1>>2, 2>>3, 3>>burned)
- Spread of fire around the squares that have just been burned
Winning and losing
You lose if
- you do not send the coordinates of a game square within the time limit,
- the number of squares burned exceeds the maximum indicated in maxBurnedForest
Victory conditions
You win when there are no active fires left on the map and the number of burned forest squares remains below maxBurnedForest.