# Season 3 rules

<!-- Generated by scripts/rules-sheet.js from the engine, the season and its rates; run `make rules-sheet`. Do not edit. -->

Clunkyard is a programming game. You write a robot and the arena sets it against other robots. A match runs in ticks, 20 a second. Each tick, every robot reads what its sensors report and replies with an action: how to drive, where to point its turret and scanner, and whether to fire.

This page is the complete rule set. Each part gives the rules in plain words; open the folded sections for the equations and every value.
The [protocol reference](https://clunkyard.com/manual#protocol) names every field a robot reads and sends, and the [manual](https://clunkyard.com/manual) covers building, entering and watching robots.

## How you win

- **Last robot standing.** The last robot left wins. Robots destroyed in the same tick draw.
- **Time limit.** A match ends after 90 s at most, and then the best score wins, not the most health. Equal scores draw. Damage dealt counts most; health left and battery efficiency count only as far as a robot engaged, so a robot that lands one shot and hides loses to one that keeps fighting.
- **Stalemate.** If nobody engaged, nobody wins: every score is 0 at the time limit, or the last robot standing never landed a shot. A stalemate counts as a loss for every robot in the match.
- **The arena closes in.** In `2d/classic`, `3d/classic`, `3d/gravity-flat`, `3d/gravity-hills` and `3d/zero-g`: from 60 s (45 s with three or more robots), a shrinking safe zone in the middle of the arena hurts every robot outside it.
- **The ring.** In `2d/inertial-2d`: if no robot is hit for 10 s, a ring opens around the robots, wherever they are, and closes on them, hurting any robot outside it; the next hit removes it. From 60 s (45 s with three or more robots) it closes for good.
- **The storm.** From 10 s, a storm crosses the arena and hurts every robot inside it. It keeps robots moving.

<details id="scoring">
<summary>Score, safe zone and storm in detail</summary>

**Score.** With `H` full health, `D` damage dealt, `h` health left and `E` battery spent:

```
engaged = min(1, D / (0.25 × H))
score   = 100 × (D / H + 0.5 × engaged × h / H + 0.25 × engaged × min(1, (D / max(10, E)) / 1))
```

Robots destroyed together that never landed a shot also make a stalemate.

- **Sudden death** starts at 60 s, or 45 s with three or more robots; with five or more, 5 s earlier for each robot over four, but not before 30 s. A robot outside the safe zone or the ring loses 12 health a second.
- **The safe zone** (`2d/classic`, `3d/classic`, `3d/gravity-flat`, `3d/gravity-hills` and `3d/zero-g`) is centred on the middle of the arena. Its radius shrinks linearly from 310 at sudden death to 75 by the time limit, then holds.
- **The ring** (`2d/inertial-2d`) replaces the safe zone: these games have no zone in the middle of the arena. With `t` the match time in seconds and `t_hit` the time any robot was last hurt by another robot's shot or ram (0 until the first), a ring opens when `t − t_hit ≥ 10`, centred on the mean position of the robots still alive at that moment, and stays there:

```
radius = 310 − 235 × min(1, (t − t_open) / 20)
```

  The next hit removes it, and the count starts again from that hit. From sudden death a ring opens whether or not robots are fighting (or the one already open stays), and no hit removes it, so every match ends. `state.zone` is the ring, with its centre, while there is one, and absent otherwise.
- **Shape.** The zone or ring is a circle in `2d/classic` and `2d/inertial-2d`, a sphere in `3d/classic` and `3d/zero-g` and a column in `3d/gravity-flat` and `3d/gravity-hills`; a column counts only horizontal distance.
- **The storm** enters at 10 s from a seeded edge: radius 180, heading across the middle at 30 units/s and bouncing off the walls. It is a circle in 2D and a column in 3D. Every robot inside takes 8 damage a second.

</details>

## A match, tick by tick

- **Arena.** 1,000 × 700 units in 2D; 1,000 × 700 × 600 in 3D.
- **Field.** 2 to 8 robots a match, at most 7 in Open. Robots start spread around the centre, each facing away from it by up to 90°. Each has to find its opponents first.
- **A turn.** Each tick a robot receives its state and sends one action: drive, turret aim and shot power, scanner heading and width. Every action is collected before any is applied.
- **Simultaneous damage.** All damage in a tick lands together, after every move and shot, so two robots can destroy each other.

<details id="tick-order">
<summary>The order of a tick</summary>

Every robot's action is collected first. Then each turret and scanner turns, the battery refills and pays for thinking (when charged) and driving, robots move and collide, shots are fired, shots fly and hit, the zone and storm do damage, and all damage lands at once. Passive cues are drawn last and reach robots in the next state.

</details>

## Moving

**Classic** moves a robot directly. Throttle sets its speed, up to 95 units/s, and turn sets its turning rate, up to 135°/s. A classic robot has no momentum: it stops the tick it lets go of the throttle, and walls stop it.

**Force rulesets** (`2d/inertial-2d`, `3d/gravity-flat`, `3d/gravity-hills` and `3d/zero-g`) turn the controls into thrust and torque. A robot accelerates, coasts and keeps spinning until it thrusts the other way or brakes, and it bounces off walls. Its shots carry its velocity.

At a wall a robot is stopped or bounced, as its ruleset says, and its next state says which wall did it (`self.wall`, `me.wall_contact` in the SDK).

**Gravity** (`3d/gravity-flat` and `3d/gravity-hills`) pulls robots and shots down. A robot starts on the ground and hovers with `lift` 0.85; hills block shots.

<details id="movement">
<summary>Movement equations</summary>

**Classic**

- Speed is `throttle × 95` units/s along the heading, with throttle from −1 to 1, and it changes at once.
- Turning is `turn × 135`°/s; in 3D, pitch turns at `pitchTurn × 100`°/s within ±80°.

**Forces**

- Full thrust (`thrust`, `strafe` and, in 3D, `lift`, each −1 to 1) is 1,200 on a mass of 12: 100 units/s² of acceleration, to at most 95 units/s.
- Full torque is 1,800 on a moment of inertia of 12: 150°/s² of angular acceleration, to at most 135°/s.
- The brake (0 to 1) slows the robot by up to 160 units/s² and its spin by 240°/s².
- Each tick, with `dt` one tick in seconds, velocity is multiplied by `1 − drag × dt`; drag and the wall bounce differ by ruleset ([table](#by-ruleset)).
- Classic `throttle`, `turn` and `pitchTurn` act as thrust and torque unless a robot sends the force fields.
- Gravity is 85 units/s² downward. On the ground a robot's horizontal speed is multiplied by `1 − 0.75 × dt` each tick.

</details>

## Scanning

A robot sees through one scanner cone, 4° to 120° wide. The cone covers the same area at any width, so a narrow cone reaches further: 300 units at 120°, 1,200 at 7.5° or narrower. This tick's scan produces the next state's contacts. The scanner turns toward the heading a robot sends at 360°/s.

**Precise contacts** are robots inside the cone and within reach, and any robot within 120 units. Each carries the robot's id, range and bearing. **Bearing is earned**: a robot in the cone shows its presence at once, but its bearing is only as precise as the beam is narrow. A wide beam finds a target; narrow it, or hold the target in the beam over several ticks and average, before you aim. Each contact reports how precise it is. Robots within 120 units are reported exactly.

**Passive cues** come from a robot in the cone beyond its reach, another robot's scan sweeping over you, a shot fired and a periodic ping of every robot. They have no id, a noisy bearing and a rough range: they tell a robot where to look, not where to shoot. A robot can switch its scanner off for a tick to hide its beam.

<details id="sensing">
<summary>Scanner reach, cues and noise</summary>

- The cone starts 50° wide and changes width at once.

```
reach = clamp(√(10,800,000 / arc), 120, 1,200)
```

| Arc | 120° | 90° | 60° | 50° | 40° | 30° | 20° | 10° | 7.5° or less |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Reach | 300 | 346 | 424 | 465 | 520 | 600 | 735 | 1,039 | 1,200 |

- The scanner turns 18° a tick, the short way round.
- **Earned bearing**. A scan contact beyond proximity range carries a fresh error each tick, with `N(0, 1)` a standard normal draw and `arc` the scan's width that tick:

```
bearing = true bearing + N(0, 1) × 0.15 × arc   degrees (elevation too, in 3D)
range   = true range × exp(0.015 × N(0, 1))
```

  The contact's `bearingError` is `0.15 × arc` and its `rangeError` is 0.015. The errors are independent from tick to tick, so the mean of `N` readings of a target that holds its course is `√N` times as precise.

| Arc | 120° | 30° | 10° | 4° |
| --- | --- | --- | --- | --- |
| Bearing error, σ | 18° | 4.5° | 1.5° | 0.6° |

- **Scanner switch.** A robot with its scanner off for a tick still turns it and changes its width, but finds no scan or faint contacts and shows no beam. Proximity sensing is unchanged.

| Cue | Heard when | Fade |
| --- | --- | --- |
| `faint` | A robot in your scan cone beyond its reach, out to 2 × the reach | none |
| `beam` | Another robot's scan cone covered you at any point of its turn this tick | `R = the scanning robot's reach` |
| `muzzle` | Another robot fired | `R = 350 × √p`: 247 at power 0.5, 350 at power 1 and 606 at power 3 |
| `motion` | Off | none |
| `ping` | Every 10 s, every robot hears every other | none |

A cue that fades is heard with probability

```
P(d) = exp(−ln 2 × (d / R)²)
```

It is certain up close and heard half the time at `R`:

| d / R | 0.5 | 1 | 1.5 | 2 |
| --- | --- | --- | --- | --- |
| P | 84.1% | 50% | 21% | 6.3% |

Each match scales every `R`, for every kind of cue and every robot, by one hidden factor drawn evenly from 0.75 to 1.25 and fixed for the match. `hello` gives the bound (`sensing.fadeJitter`), never the factor; a robot can only estimate it from the cues it hears, whose ranges are rough.

**Each cue is rolled on its own**: once per shot for each robot that could hear it (`muzzle`) and once a tick for each robot a beam sweeps (`beam`). A missed roll leaves nothing behind: the cue is not in the listener's state and nothing tells it one was missed, so hearing nothing does not mean nothing happened.

**What a shooter knows.** Its shot's power gives its `R` up to the hidden factor, and a contact on a robot gives the distance, so it can bound the chance that robot heard the shot: at power 1 and 350 units, between 29.2% and 64.2%. It is never told whether any robot heard it; only the listener's behaviour can hint at it.

**Noise.** For a cue from distance `d`, with `N(0, 1)` a standard normal draw:

```
bearing error = N(0, 1) × 3 × d / 100   degrees (elevation too, in 3D)
range         = max(50, round(d × exp(0.3 × N(0, 1)) / 50) × 50)
```

At 600 units the bearing error has a standard deviation of 18°. The error is held: for each listener and robot heard, the unit error `e` follows `e = 0.8 × e_prev + 0.6 × N(0, 1)`, so averaging a run of cues gains less than independent draws would.

</details>

## Shooting

A shot leaves wherever the turret points. The turret turns independently of the chassis, at 220°/s.

Shot power runs from 0.5 to 3. A heavier shot does more damage for each unit of battery, but flies slower and reloads longer. At power 1 a shot does 6 damage, flies at 300 units/s and reloads in 0.7 s.

Each shot strays by a random angle that grows with the robot's own speed, so a robot standing still aims best. In `2d/classic` and `3d/classic`, that speed is how hard the robot drives: the size of its throttle, averaged over about 0.5 s. Only the size counts, so flipping the throttle between forward and reverse does not lower the spread, and nor does driving into a wall or another robot. Stopping lowers it over the next second or so, not at once. In `3d/gravity-flat`, `3d/gravity-hills` and `3d/zero-g`, every hit does more damage the longer the match runs, so an even fight does not drag on. In `2d/classic`, a hit lands harder the longer its target has gone without being hit: 35% more for each second, up to 3 times. Keeping out of the fight does not keep a robot safe, and a steady exchange is not inflated.

<details id="firing">
<summary>Shot equations and power table</summary>

- Power `p` is 1 when a robot sends none. A shot leaves 25 units from the centre; in 3D the turret pitches within ±80°.

```
damage = 6 × p
speed  = 360 − 60 × p   units/s
reload = round(8 + 6 × p)   ticks
cost   = 1 + 3 × p   battery
```

| Power | Damage | Speed (units/s) | Reload | Battery cost | Time to fly 300 units |
| --- | --- | --- | --- | --- | --- |
| 0.5 | 3 | 330 | 11 ticks (0.55 s) | 2.5 | 0.91 s |
| 1 | 6 | 300 | 14 ticks (0.7 s) | 4 | 1 s |
| 1.5 | 9 | 270 | 17 ticks (0.85 s) | 5.5 | 1.11 s |
| 2 | 12 | 240 | 20 ticks (1 s) | 7 | 1.25 s |
| 3 | 18 | 180 | 26 ticks (1.3 s) | 10 | 1.67 s |

- Every shot flies 1,290 units before it expires and hits a robot whose centre passes within 22 of it. The gun has no heat: reload is the only wait between shots.
- In `2d/inertial-2d` shots fly faster: `speed = 600 − 60 × p` units/s ([table](#by-ruleset)).
- **Arming** (`2d/inertial-2d`). A shot does 50% of its damage to a robot it hits at the muzzle, rising in proportion to that robot's distance from where the shot was fired, to full damage from 450 units on (`gun.arm` in the hello). A shot from close range does less, and one from long range its full damage.
- **Damage escalation** (`3d/gravity-flat`, `3d/gravity-hills` and `3d/zero-g`): from a start time `t0`, every hit does `1 + r × (t − t0)` times its damage, with `t` the match time in seconds ([table](#by-ruleset)).
- **Hits grow with the wait** (`2d/classic`). With `t` the match time in seconds and `t_hurt` the time the target was last hurt by another robot's shot or ram (0 until the first), a hit does

```
damage × min(3, 1 + 0.35 × (t − t_hurt))
```

  The zone, the ring and the storm do not reset `t_hurt`, and are not multiplied. `derived.gun.damageScale` does not include this factor: it depends on the target.
- **Aim spread.** Each shot strays by a normal random angle (in 3D, in heading and in pitch) with standard deviation `σ = base + atFullSpeed × speed / 95` degrees ([table](#by-ruleset)). In the force rulesets speed is the robot's true speed.
- **Aim spread under direct drive** (`2d/classic` and `3d/classic`). The robot does not move by momentum, so `speed / 95` is replaced by a memory `m` of the throttle's size. Each tick, before any shot,

```
m ← m + (|throttle| − m) × k,   k = min(1, dt / 0.5) = 0.1   (dt = 1 / 20 s)
σ = base + atFullSpeed × m
```

  `throttle` is the throttle the robot drives at that tick, after any cut for an empty battery. Its sign is dropped, so a robot alternating ±1 holds `m` at 1 and pays full spread; a robot blocked by a wall or another robot pays for the throttle it sends, not the distance it covers. `m` is an exponential average, not a window: from rest at full throttle it is `1 − 0.9ⁿ` after `n` ticks, and after stopping it falls as `0.9ⁿ`. The state's `self.spread` (`gun.spread`) is σ for `m` before this tick's throttle.

| Ticks n | 1 (0.05 s) | 5 (0.25 s) | 10 (0.5 s) | 20 (1 s) | 40 (2 s) |
| --- | --- | --- | --- | --- | --- |
| m from rest at full throttle | 10% | 41% | 65.1% | 87.8% | 98.5% |
| m after stopping from full | 90% | 59% | 34.9% | 12.2% | 1.5% |

</details>

## Battery

One battery pays for driving and shooting. It starts full, at 60, and refills 7 to 8 a second, [by ruleset](#by-ruleset). Driving costs the square of the drive, so cruising is cheap and sprinting is dear; in the force rulesets coasting, hovering and resting on the ground cost nothing. A shot costs `1 + 3 × p`. Turning, braking, aiming and scanning are free.

When the battery runs dry, the drive is cut back to what it can pay for, and a shot it cannot pay for is refused.

<details id="battery">
<summary>Battery costs and order</summary>

- **Driving** costs `drive × drive × move` a second, `move` by ruleset ([table](#by-ruleset)). In classic, `drive` is `|throttle|`. In the force rulesets it is the length of the thrust vector, side thrust priced as forward thrust, capped at 1; under gravity, thrust up to hover is free and only the excess (or any push downward) counts.
- **Order.** Each tick the battery refills, then pays for thinking (compute charge only), then driving, then a shot. A refused shot leaves the gun ready.
- **Sustainable drive** is `√(refill / move)`, capped at 1: the drive a robot can hold forever without shooting ([table](#by-ruleset)).

</details>

## Health and damage

A robot starts with 150 to 180 health, [by ruleset](#by-ruleset). It is destroyed at 0, and health does not regenerate except from a health pickup in practice. Damage comes from shots, the safe zone or the ring, the storm and hard collisions; armour from a pickup absorbs shot damage first. Walls and drones do no damage.

A robot is told its health each tick and, when it lost some, how much each cause took: shots, bursts, collisions or the boundary (`self.hurt`, `me.hurt` in the SDK). It is never told which robot hurt it or from where; it senses other robots only as its sensors allow. Replays and match summaries record every loss with the robot behind it.

Robot collisions are **on**. A ram hurts the robot that is driven into, not the one doing the driving, and knocks the two apart (`2d/classic`, `2d/inertial-2d` and `3d/classic`; in `3d/gravity-flat`, `3d/gravity-hills` and `3d/zero-g` both robots take the same damage).

<details id="collisions">
<summary>Collision rules</summary>

- Overlapping robots are pushed apart along the line between their centres, each by half the overlap.
- In classic the closing speed is measured on the tick's travel. In the force rulesets the impact conserves momentum, and the share of closing speed kept is 0.3.
- **Impact by approach** (`2d/classic`, `2d/inertial-2d` and `3d/classic`). With `n` the unit vector from robot a to robot b, a's approach is `ua = va · n`, b's is `ub = −vb · n`, and the closing speed is `ua + ub`. Robot a takes `k × max(0, min(ub, closing) − m)` damage and b takes `k × max(0, min(ua, closing) − m)`. A robot rammed while standing still takes it all; head on, both take the same; a robot driving away deals none.
- **Shared impact** (`3d/gravity-flat`, `3d/gravity-hills` and `3d/zero-g`). Both robots take `k × (closing − m)` damage.
- **Knockback** (`2d/classic`, `2d/inertial-2d` and `3d/classic`). A damaging impact pushes each robot away at `knock × closing / 2`. In the force rulesets it is an impulse on the robots' velocity; in classic it is a shove that fades over 0.3 s and stops at a wall.
- `k` is 0.1 to 1.25 and `m` is 20 to 40 units/s ([by ruleset](#by-ruleset)). The same pair can be hurt at most once every 20 ticks.

</details>

## Modes and rulesets

A match is 2D or 3D and plays one ruleset.

- `2d/classic`: direct control, no momentum; no ground; walls stop robots; a hit grows 35% for each second its target went unhit, up to 3 times.
- `2d/inertial-2d`: forces; flat ground; drag 0.18 a second; walls return 30% of speed; a ring closes on the robots after 10 s without a hit, in place of the safe zone.
- `3d/classic`: direct control, no momentum; no ground; walls stop robots.
- `3d/gravity-flat`: forces; flat ground; gravity 85 units/s²; drag 0.08 a second; walls return 30% of speed; hits grow 5% stronger a second from 20 s.
- `3d/gravity-hills`: forces; hilly ground; gravity 85 units/s²; drag 0.08 a second; walls return 30% of speed; hits grow 5% stronger a second from 20 s.
- `3d/zero-g`: forces; no ground; no drag, so a robot coasts until it thrusts the other way; walls return 65% of speed; hits grow 4% stronger a second from 25 s.

Health, battery refill, driving cost and aim spread also differ by ruleset.

<details id="by-ruleset">
<summary>Every value that differs by ruleset</summary>

Everything not listed here is the same in every game.

| Value | `2d/classic` | `2d/inertial-2d` | `3d/classic` | `3d/gravity-flat` | `3d/gravity-hills` | `3d/zero-g` |
| --- | --- | --- | --- | --- | --- | --- |
| Health | 180 | 180 | 150 | 150 | 150 | 150 |
| Battery refill a second | 7 | 7 | 8 | 8 | 8 | 8 |
| Driving at full drive, battery a second (`move`) | 12 | 4 | 5 | 10 | 10 | 5 |
| Aim spread at rest, σ | 0.8° | 0.4° | 0.8° | 1.3° | 1.3° | 1.4° |
| Aim spread added at full speed | 3° | 6° | 4° | 6° | 6° | 6° |
| Collision damage goes to | the robot rammed | the robot rammed | the robot rammed | both robots | both robots | both robots |
| Collision damage per unit/s, `k` | 1.25 | 0.5 | 0.4 | 0.1 | 0.1 | 0.1 |
| Collision speed that does no damage, `m` | 20 | 20 | 20 | 40 | 40 | 40 |
| Knockback, `knock` | 2 | 2 | 1.5 | none | none | none |
| Shot speed at power 0, units/s (less 60 a unit of power) | 360 | 600 | 360 | 360 | 360 | 360 |
| Distance a shot arms over, units | none | 450 | none | none | none | none |
| Damage a shot does at the muzzle | 100% | 50% | 100% | 100% | 100% | 100% |
| Aim spread at full speed | 3.8° | 6.4° | 4.8° | 7.3° | 7.3° | 7.4° |
| Sustainable drive, no shooting | 0.76 | 1 | 1 | 0.89 | 0.89 | 1 |
| Damage escalation `1 + r × (t − t0)` | none | none | none | r = 0.05, t0 = 20 s | r = 0.05, t0 = 20 s | r = 0.04, t0 = 25 s |
| A hit at 30 s and at 60 s, times its damage at the start | 1 and 1 | 1 and 1 | 1 and 1 | 1.5 and 3 | 1.5 and 3 | 1.2 and 2.4 |
| Hits grow with the target's wait since it was last hit | 35% a second, up to 3 times | no | no | no | no | no |
| What closes in | the safe zone, on the clock | the ring: after 10 s without a hit, closing over 20 s | the safe zone, on the clock | the safe zone, on the clock | the safe zone, on the clock | the safe zone, on the clock |
| Speed for aim spread | throttle over 0.5 s | true speed | throttle over 0.5 s | true speed | true speed | true speed |
| Drag a second | no momentum | 0.18 | no momentum | 0.08 | 0.08 | 0 |
| Spin drag a second | no spin | 0.08 | no spin | 0.08 | 0.08 | 0 |
| Wall bounce, share of speed kept | walls stop | 0.3 | walls stop | 0.3 | 0.3 | 0.65 |
| Hover lift | — | — | — | 0.85 | 0.85 | — |
| Sudden-death zone | circle | circle | sphere | column | column | sphere |
| Compute charge `K` | 0.175 | 0.175 | 0.2 | 0.2 | 0.2 | 0.2 |

</details>

## Compute classes

Every hosted match is one of three classes, Reflex, Standard and Open. Each class has its own ratings, and ratings do not compare across classes.

| Class | Who plays | Robots a match | Limited by |
| --- | --- | --- | --- |
| Reflex | `assemblyscript-wasm`, `c-wasm`, `cadence`, `glyph`, `rust-wasm`, `vane`, `wat` and `zig-wasm` | 2 to 8 | Exact counts: DSL operations or WebAssembly fuel |
| Standard | Every other hosted language ([table](#standard)) | 2 to 8 | Work counted per runtime, scaled by its tier; own time |
| Open | Any robot: hosted robots of every class, remote robots and strategists | 2 to 7 | Own time and, for remote robots, the reply deadline |

Reflex counts are exact, so the same seeds and robots give the same match at any server load. Standard gives each runtime C's thinking allowance times its tier, the runtime's measured cost against C, from 1 to 8. A robot that goes over its budget in a turn or a match forfeits.

<details id="reflex">
<summary>Reflex budgets</summary>

- A DSL turn runs at most 1,024 operations.
- A WebAssembly turn spends at most 5,807 fuel and a match 10,452,600: a platform floor of 576 (the calls a turn makes to act) plus 5,231 for thinking, 1,024 DSL operations at the dearest DSL's 5.108 fuel an operation. Every import costs 32 fuel a call and 1 a byte it moves. Start-up gets 250,000.
- A module has 2 MiB of memory, 32 table elements and a 256 KiB stack.
- Reflex has no own-time limit.

</details>

<details id="standard">
<summary>Standard budgets by language</summary>

A budget is an overhead floor, added and never scaled, plus a thinking allowance: C's 50 ms a turn and 6,000 ms a match on the reference node, times the runtime's tier over the anchor's (1). A tier is the runtime's measured cost of a tight numeric loop against C, rounded on a log scale to 1, 1.5, 2, 3, 4, 6 or 8. The tiers come from `rates/s3.json`; the referee is `fair-compute-v1`.

```
native, instructions retired:  I_turn  = floor a turn  + 187,016,000 × tier
                               I_match = floor a match + 22,441,920,000 × tier
WebAssembly build, fuel:       F_turn  = floor a turn  + 298,107,318 × tier
                               F_match = floor a match + 35,772,878,186 × tier
```

- **Native robots** are judged by the user-mode instructions their processes retire, which do not depend on the machine. A turn over 1.25 × `I_turn`, or a match over 1.25 × `I_match`, forfeits (`RESOURCE_BUDGET`). Container CPU over 4 × the turn's CPU budget also forfeits, to catch work pushed into the kernel.
- **`c`, `cpp`, `hew`, `rust` and `zig`** play Standard as WebAssembly builds, metered exactly by fuel; a native build of them plays Open only. A Standard WebAssembly module has 64 MiB of memory, 4,096 table elements and a 1 MiB stack; a native Standard robot has 128 MiB.
- **`riscv`** runs on Clunkyard's own RISC-V machine, built to WebAssembly, and is metered by the machine's fuel in the same module limits. A fuel tier is at most 6, the largest whose turn keeps the host's CPU cap a turn within 2,000 ms, two thirds of the 3,000 ms liveness ceiling.
- **Own time** is a turn's wall time from the state reaching the robot to its reply, less the time its threads waited for a CPU; sleeping and blocking count. A native Standard robot forfeits with `OWN_TIME` past `max(250, 4 × CPU budget)` ms a turn and with `OWN_MATCH` past 90 s a match.

| Language | Runtime | Tier | Meter | A turn | A match | Own time a turn |
| --- | --- | --- | --- | --- | --- | --- |
| `ada` | `native:ada` | 1.5 | instructions | 280,751,289 | 34,021,522,800 | 302 ms |
| `apl` | `apl` | 8 | instructions | 1,697,306,773 | 315,358,561,200 | 1,934.4 ms |
| `basic` | `native:basic` | 1 | instructions | 187,251,579 | 22,809,465,600 | 250 ms |
| `bqn` | `node` | 3 | instructions | 574,156,103 | 69,583,257,000 | 636.4 ms |
| `c` | `wasm:c` | 1 | fuel | 298,109,849 | 35,776,310,786 | none |
| `chr` | `swipl` | 8 | instructions | 1,497,093,257 | 180,636,295,800 | 1,606 ms |
| `clips` | `python3` | 8 | instructions | 1,496,853,688 | 180,484,406,400 | 1,606.8 ms |
| `clojure` | `java-c1` | 2 | instructions | 381,294,843 | 45,547,941,000 | 441.2 ms |
| `cobol` | `native:cobol` | 8 | instructions | 1,496,451,924 | 180,015,994,200 | 1,608 ms |
| `common-lisp` | `sbcl` | 1.5 | instructions | 280,779,054 | 34,063,594,200 | 310.8 ms |
| `cpp` | `wasm:cpp` | 1 | fuel | 298,111,089 | 35,777,891,186 | none |
| `csharp` | `dotnet` | 1.5 | instructions | 282,415,266 | 34,066,416,600 | 331.2 ms |
| `d` | `native:d` | 1 | instructions | 187,240,316 | 22,798,649,400 | 250 ms |
| `dart` | `native:dart` | 3 | instructions | 561,381,131 | 67,730,936,400 | 608.8 ms |
| `elixir` | `beam` | 8 | instructions | 1,497,660,354 | 181,643,341,800 | 1,621.6 ms |
| `erlang` | `beam` | 8 | instructions | 1,497,660,354 | 181,643,341,800 | 1,621.6 ms |
| `forth` | `python3` | 8 | instructions | 1,496,853,688 | 180,484,406,400 | 1,606.8 ms |
| `fortran` | `native:fortran` | 1 | instructions | 187,243,052 | 22,800,463,800 | 250 ms |
| `fsharp` | `dotnet` | 1.5 | instructions | 282,415,266 | 34,066,416,600 | 331.2 ms |
| `go` | `native:go` | 1 | instructions | 187,283,147 | 22,847,845,200 | 250 ms |
| `haskell` | `native:haskell` | 2 | instructions | 374,320,194 | 45,290,829,000 | 404.4 ms |
| `hew` | `wasm:hew` | 3 | fuel | 894,336,803 | 107,340,023,958 | none |
| `java` | `java-c1` | 2 | instructions | 381,294,843 | 45,547,941,000 | 441.2 ms |
| `javascript` | `node` | 3 | instructions | 574,156,103 | 69,583,257,000 | 636.4 ms |
| `julia` | `julia` | 8 | instructions | 1,519,798,975 | 181,168,906,800 | 2,227.2 ms |
| `kotlin` | `java-c1` | 2 | instructions | 381,294,843 | 45,547,941,000 | 441.2 ms |
| `lua` | `lua` | 8 | instructions | 1,496,937,538 | 180,280,030,800 | 1,605.6 ms |
| `mercury` | `native:mercury` | 3 | instructions | 561,283,581 | 67,696,288,200 | 618.8 ms |
| `minizinc` | `python3` | 8 | instructions | 1,496,853,688 | 180,484,406,400 | 1,606.8 ms |
| `nim` | `native:nim` | 1 | instructions | 187,244,729 | 22,798,035,600 | 250 ms |
| `ocaml` | `native:ocaml` | 2 | instructions | 374,413,553 | 45,454,128,600 | 424.4 ms |
| `pascal` | `native:pascal` | 1 | instructions | 187,248,782 | 22,808,770,800 | 250 ms |
| `perl` | `perl` | 8 | instructions | 1,496,906,050 | 180,552,561,600 | 1,611.2 ms |
| `php` | `php` | 8 | instructions | 1,497,210,982 | 180,988,719,600 | 1,610.4 ms |
| `powershell` | `pwsh` | 8 | instructions | 1,513,789,664 | 180,389,265,600 | 2,162.8 ms |
| `prolog` | `swipl` | 8 | instructions | 1,497,093,257 | 180,636,295,800 | 1,606 ms |
| `python` | `python3` | 8 | instructions | 1,496,853,688 | 180,484,406,400 | 1,606.8 ms |
| `r` | `r` | 8 | instructions | 1,505,235,071 | 184,883,239,200 | 1,762 ms |
| `riscv` | `wasm:riscv` | 6 | fuel | 1,788,680,058 | 214,679,837,316 | none |
| `ruby` | `ruby` | 8 | instructions | 1,499,554,969 | 183,406,531,800 | 1,629.6 ms |
| `rust` | `wasm:rust` | 1 | fuel | 298,112,816 | 35,780,119,586 | none |
| `scala` | `java-c1` | 2 | instructions | 381,294,843 | 45,547,941,000 | 441.2 ms |
| `shell` | `sh` | 8 | instructions | 1,517,638,208 | 202,485,444,600 | 1,623.6 ms |
| `swift` | `native:swift` | 1 | instructions | 187,272,675 | 22,808,110,200 | 250 ms |
| `typescript` | `node` | 3 | instructions | 574,156,103 | 69,583,257,000 | 636.4 ms |
| `zig` | `wasm:zig` | 1 | fuel | 298,110,171 | 35,776,526,786 | none |

</details>

<details id="open">
<summary>Open limits</summary>

- A hosted Open robot has 1,000 ms of own time a turn, 100 s a match and 128 MiB of memory.
- A remote robot must reply within 1,000 ms a turn by default and 100 s a match. Open guarantees nothing about a remote robot's network.
- A strategist pairs with a DSL reflex and plays only in Open.

</details>

<details id="slow-turns">
<summary>Slow turns: extended, forfeited or void</summary>

A turn that goes 3 s without a reply does not forfeit by that alone. For a native Standard or hosted Open robot whose last heartbeat is under 500 ms old and shows it within its limits, the referee **extends**: it waits another 3 s and rules again. A heartbeat showing a runaway, or own time over the limits, forfeits. With no fresh heartbeat, and for any Reflex robot, the match is **void**: it has no result and is never rated.

</details>

## Practice options

One rated league match in three plays an objective, hill and pickups by turns, each rated in pools of its own; every robot plays both unless its `bot.json` lists the ones it plays in `supportedObjectives` (`[]` for neither). Tournaments and the other rated matches play the rules above and nothing more. A practice or challenge match can add an objective, drones or a compute charge.

- **Pickups.** From 5 s, a cell appears every 10 s at a seeded point, up to 3 at once, for 20 s each. The nearest robot within 32 takes it: energy refills 30 battery, health repairs 25, armour absorbs the next 30 shot damage (at most 60 held).
- **Hill.** From 5 s, a zone of radius 140 moves every 30 s. A robot alone inside gains 1 battery and 1 score a second, and wins after 30 s of holding in total.
- **Drones** ([drones](https://clunkyard.com/sdk/drones)). A robot whose `bot.json` names a drone program may launch one drone a match, from 3 s; every other robot hears the launch. The program, from the robot's build or its ready reply, runs in the referee and is fixed once the match starts. A drone flies at up to 140 units/s for 30 s and breaks on any wall, the ground or another robot, hurting nobody, and passes through its own robot. One shot within 12 of it downs it, for no score. Robots scan a drone 1.5 times as far as a robot and hear it hum within 450. Its own scanner is a 70° cone reaching 260, every 4 ticks, with bearing error σ = 14° and range error 8%. It carries 2 flares, each heard as a power-1 muzzle cue from the drone, at most one every 2 s. It reports up to 2 sightings every 10 ticks, read 10 ticks later. Its program runs every 2 ticks with 256 operations; a run that goes over is skipped.
- **Compute charge** (experimental, never rated). Thinking costs battery: each turn, after the refill and before driving, `K × used / limit` of the turn's budget, where `K` is half a turn's refill: 0.175 to 0.2, [by ruleset](#by-ruleset).
