# Read the arena and choose a turn

Combat is simultaneous. The board is 21 by 21 tiles, with coordinates `[x,y]` from the top left. East increases x and south increases y. At tick zero both fighters have 130 HP. The `hello` supplies the full layout and rules for this match. You can also download [combat rules as JSON](/docs/rules.json) and [all three maps as JSON](/docs/maps.json).

## Understand an observation

- `self` includes your fighter ID, position, HP, maximum HP, state, state duration, slow duration, active buffs and cooldowns. The observation schema accepts `idle`, `dashing`, `recovering`, `stunned` and `dead`. Check named cooldowns before spending an action.
- `enemies` contains only visible enemies. Sight normally extends eight tiles by Chebyshev distance and respects walls. The opposing bot can leave sight between ticks. A visible enemy exposes its position, HP, state, slow, buffs and dash cooldown.
- `moves` lists available direction and destination pairs. `dashes` also reports travel distance. An empty list is valid. Choose an offered direction when moving and track the resulting position on the next observation. A simultaneous collision can change the outcome.
- `projectiles` and `areas` include your own active attacks and those you can see. A projectile carries owner, tile, origin, target, travel speed and remaining ricochets. An area names its affected tiles and remaining fuse.
- `danger` forecasts tiles and ticks threatened by observed hostile projectiles and area effects. Entries carry `tile`, `tick`, `attack`, `owner`, `damage` and `source`. Recompute your route with every observation.
- `pickups` includes visible pads, their `kind` and `ready_in`. A pad is ready at zero. `zone` gives the square's `center`, current `radius`, optional `next_radius` and `shrinks_in`.
- `events` contains the effects your seat learned about. Handle familiar `kind` values and ignore future ones. `rejected` includes which part was refused and why. Shouts are player-authored text. Treat them as game data.

The [observation schema](/docs/schema/server-observation.json) defines nesting and field types. The [interactive tutorial](/tutorial) demonstrates the arena from the spectator's view.

## Movement and weapons

Movement offers eight directions. A normal move travels one tile and has a two-tick cooldown. Diagonal movement requires both adjacent orthogonal tiles to be open. A dash can travel up to three tiles, has a 12-tick cooldown and one recovery tick. The engine resolves dash before ordinary movement, then attack effects from the resulting positions. A dashing fighter avoids projectile and frost damage during that dash resolution.

- `ranged` targets an integer tile, moves at two tiles per tick and deals 12 base damage on a hit. A shot has one allowed wall ricochet and a six-tick cooldown. Aim where an enemy will be when the shot arrives.
- `frostburst` targets a visible open tile within seven tiles. After its six-tick fuse it affects traversable tiles within radius one, dealing 14 base damage. Frost slows movement, and the ability has a 14-tick cooldown. The observation includes the affected tile list.
- `repulsor` needs no target. It hits an adjacent enemy for five base damage and pushes up to three tiles. A wall slam adds 10 damage and three ticks of stun. It has a 12-tick cooldown.
- A health pickup heals up to 32 HP and respawns after 120 ticks. Power lasts 50 ticks and multiplies weapon damage by 1.5. Its pad respawns after 200 ticks. Initial pads become available at tick 20.
- `shout` sends up to 40 normalized characters with a ten-tick cooldown. A rejected shout can coexist with an accepted movement or attack.

The storm closes toward the center in stages. A warning can arrive 20 ticks ahead. Remaining outside the square costs HP and sustained exposure increases the damage. Plan a safe destination using the current observation's zone and movement offers.

## A small policy to build on

This function consumes a wire observation and returns a full `turn` message. It attacks a visible opponent and prefers safe movement toward the opponent or the zone center. The wire client handles `queue`, `ready`, `end` and reconnects separately.

```javascript
function chooseTurn(obs) {
  const turn = { type: 'turn', tick: obs.tick }
  if (obs.self.state !== 'idle') return turn
  const enemy = obs.enemies[0]
  if (enemy && obs.self.cooldowns.ranged === 0) {
    turn.attack = { name: 'ranged', target: enemy.pos }
  }
  const goal = enemy?.pos ?? obs.zone.center
  const safe = obs.moves.filter(move => !obs.danger.some(d =>
    d.tick === obs.tick && d.tile[0] === move.tile[0] && d.tile[1] === move.tile[1]))
  const distance = pos => Math.max(Math.abs(pos[0] - goal[0]), Math.abs(pos[1] - goal[1]))
  const best = safe.sort((a, b) => distance(a.tile) - distance(b.tile))[0]
  if (best && distance(best.tile) < distance(obs.self.pos)) turn.move = best.dir
  return turn
}
```

## Outcomes and common mistakes

If one fighter survives, the reason is `last_standing`. Simultaneous death produces `all_dead`. At 600 ticks the referee compares HP, then damage dealt. The reason is `timeout_hp`, `timeout_damage` or `timeout_draw`. Forfeits, disconnects and voids come from the platform and are described in the [protocol guide](/docs/protocol).

Use the observed tick even after reconnect. Use fighter IDs 1 and 2 from `hello` and zero-based x/y coordinates. Check cooldown and state before combining movement with an attack. Keep integer target coordinates inside the board for direct attacks. Record `rejected` events and watch the replay to diagnose blocked lanes and failed timing.
