Creativity Task - Tank War

Introduction

There is a big argument between Stofl and his mice colleagues about a particular cheesy piece of cheese they found. They don’t find another way but to play a game of tank war to determine who will receive the cheese.

Tank War

Tank War is played on a straight line of a particular length and there are up to 8 players playing against each other. Each player occupies a position on the line and has different weapons and a number of moving points.

A battle is played in turns. In each turn all the players act simultaneously according to the following scheme:

  • The players fire a missile at a position on the line (within the range of the selected weapon). If a player uses a weapon different from the one used in his previous turn, this change costs him one moving point.
  • They move a number of steps to the left or to the right, but no more than they have moving points left. Every step of a player decreases the number of his moving points by one.
  • All the weapons hit their intended target and impact on the players nearby. The damage points of the players within the impact radius of the weapon increase by the damage points of the weapon used.
  • All players with more than P damage points points lose and leave the game.

Note that the line can be interpreted as connected at the ends. That is, you can move from the left boundary leftwards and you appear at the right end. If you fire a missile over the boundary, it enters the line again on the other side.

The different weapons are specified by three parameters:

  • The range describes the maximum distance you can reach with that weapon.
  • The impact radius means how close you have to be to the target to hit it. If you fire a missile with an impact radius of 5 to the position 10, you will hit players in the range from position 5 to position 15 inclusive.
  • The damage points correspond to the strength of a weapon and indicate the amount of damage points added to the target in case of a hit.

For every weapon, you have an unlimited number of missiles to fire. If you choose to change your weapon, it costs you one moving point.

Server interaction

At the beginning of a battle, you get information about the world and the different weapons from the standard input. First, you read three integers L, P, W, where L is the length of the world, P is the maximal damage one can have before leaving the game and W is the number of weapons you have. W lines follow, each of which contains the description of a weapon by three integers: its range, impact radius and damage points. The weapons are numbered from 1 to W.

Prior to every turn you have to read information about the game state from the standard input. The first line contains a single integer N, the number of players remaining in the battle. The second line contains three integers: your position, moving points and damage points (0 at the beginning of the battle). The next 2 (N-1) lines contain the same information about all the other players still in the game. The description of the i-th player consists of two lines:

The first of these contains the name of that player (no more than 20 lower-case letters). The second line contains three integers: his position, moving points and damage points (0 at the beginning of the game).

After reading the input you have to output your move by three integers (see remarks):

  • an integer indicating where you want to move. If it is positive, you will move that many steps to the right, If it is negative, you will move that many steps to the left. If it is zero, you will stay where you are.
  • the number of the weapon you want to use in this turn, and
  • the position you aim at. Remember that this must be within the range of your weapon.

Note: If your move is illegal or your program does not respond as it should, your player will stay at his position and not fire a missile in that turn.

Your program can safely exit as soon as N is smaller than 2.

Constraints

  • 2 ≤ N ≤ 8
  • 1 ≤ W ≤ 10
  • 2 ≤ L ≤ 1000
  • 1≤ P ≤ 1000

For every weapon:

  • 1≤ damage points ≤ 1000
  • 1 ≤ range ≤ 1000
  • 0 ≤ impact range ≤ 1000

0 ≤ moving points of the players at beginning ≤ 10 000

Remarks

  • Please note that the first line of the server interaction protocol has changed on Sat. 3rd of October.
  • Positions are numbered from 0 to L-1.
  • Remember to flush your output ( In C with: fflush(stdout) / In C++ with: cout.flush() ) and always append a newline after each move you output. (The reason for this is that otherwise your move won't reach our server because of buffering issues)
  • The weapon you select in the first round will not cost you a moving point, no matter which one you choose.

Submission