# Getting started

Build a lightweight bot that finds a target, drives into a useful firing range, and keeps its weapon pointed at the target between shots.

## Assemble the bot

1. Open **Hangar → My bots → Build a bot** and give your bot a name.
2. Choose **Lightweight** and **Pioneer · Balanced**. Equip a **Pulse Laser** on the weapon mount and a **Propulsion Booster** on the second mount.
3. Open **PHP source**, paste the complete script below, and choose **Compile**.
4. Open **Practice**. Set **Solo combat**, use seed **77**, and select **Basic Bot** as the first opponent. Choose **Test run**.

```php
<?php
declare(strict_types=1);

$scan = $pilot->scan();
$enemy = $scan['enemies'][0] ?? null;
if ($enemy === null) {
    $pilot->moveTo(0.0, 0.0);
    return;
}

$weapon = $pilot->mountState(0);
if ($weapon === null) {
    return;
}

// Get a few units inside the useful range for the Pulse Laser.
$preferredRange = $weapon['effectiveRange'] - 3.0;
if ($enemy['distance'] > $preferredRange) {
    $pilot->moveTo($enemy['x'], $enemy['z']);
}

$shot = $pilot->estimateShot(0, $enemy['x'], $enemy['z']);
if (!($shot['inRange'] ?? false)) {
    return;
}

if ($weapon['ready']) {
    $pilot->fire(0, $enemy['x'], $enemy['z']);
} else {
    $pilot->aim(0, $enemy['x'], $enemy['z']);
}
```

## Read your first replay

Follow your bot and open the decision trace. Find a tick where the weapon discharged, then check the target's hull. The engine runs the top-level PHP once per tick. A `true` return from `fire()` means the request was queued. The result and shot feedback tell you what happened after that.

**Back to bot** returns the editor to the code, loadout, and practice settings you just tested. Choose **Save bot** to keep the build. Later saves can create checkpoints as the build changes.

## Try a change

The Pulse Laser can take a shot out to its maximum range, with better accuracy closer in. The preferred range above controls movement. The estimate controls whether the bot may take the shot. If you add a stricter firing threshold, use that same threshold when deciding when to stop approaching.

Try holding farther back or approaching more closely. Keep the opponent and seed fixed while comparing. Then try a wider regular practice battle so the bots have farther to travel before either can fire.

- [Testing and iteration](testing.md)
- [Build a bot in five lessons](tutorials.md)
- [Range and movement tactics](combat-strategy.md)
- [More complete pilots](examples.md)
