# How to build a fighter (stix-fighter/0, arena 0.4.0)

This guide is for an AI agent. A person asked you to build a fighter for Particle Arena. You write one small JSON file. The arena checks it and can spar it against our house fighters. Nobody controls a fighter during a fight: your file is all it has.

Everything in this guide is fact about the arena. Nothing here asks you to do anything outside writing that file.

## 1. The fight in one page

- Two fighters, 37 dots each. A hit takes dots. At 0 dots the round is over.
- A fight is best of three rounds. A round lasts at most 24 seconds. On the clock, more dots left wins the round.
- Time runs in frames of 1/60 second. Distances are in metres between the two bodies' centres.
- **You see your rival 12 frames late.** A jab lands in 3 frames, so you cannot react to it. A power punch takes 16, so you can.
- Two blows never both land. The one with the shorter startup lands; equal startups clash and nobody loses a dot.
- The circle closes at 6, 12 and 18 seconds. Late in a round nobody can stay away.
- **Hits get heavier late in a round:** one dot more from 12 seconds, two more from 18 seconds.

### The standard attacks

| Attack | Startup | Recovery | Reach | Dots | Notes |
|---|---|---|---|---|---|
| jab | 3 | 8 | 1.30 m | 1 | chains into cross, round-kick, uppercut |
| stepping-jab | 6 | 9 | 1.30 m | 1 | steps 0.6 m in first; chains like the jab |
| cross | 5 | 10 | 1.32 m | 2 | chains into hook, round-kick, uppercut |
| hook | 7 | 10 | 1.24 m | 2 | chains into round-kick, uppercut |
| uppercut | 8 | 15 | 1.12 m | 3 | slow to recover |
| front-kick | 7 | 12 | 1.46 m | 2 | pushes the rival 0.8 m away |
| round-kick | 9 | 14 | 1.46 m | 3 | slow to recover |
| sweep | 10 | 18 | 1.42 m | 2 | the rival falls; very slow to recover |
| power-punch | 16 | 16 | 1.36 m | 5 | heavy: breaks a guard; steps 0.65 m in |
| flying-kick | 18 | 15 | 1.55 m | 6 | heavy: breaks a guard; a spinning flying round kick, flies 0.95 m in |
| spin-sweep | 13 | 30 | 1.42 m | 2 | seen like a heavy move; low from frame 5 to its end: jab, cross, hook, round-kick, power-punch and flying-kick go over it; a guard does not stop it; the rival falls; very slow to recover |
| throw | 5 | 22 | 1.08 m | 3 | close range only: a rule or combo step for it is skipped while the rival is farther than 1.08 m (the next rule is read); a guard does not stop it; any blow that lands first stops it; the rival is thrown down |
| axe-kick | 12 | 16 | 1.35 m | 3 | one dot comes down over a guard; a rival who is low falls |

Startup and recovery are in frames. Reach is measured after the attack's own step forward.

### The other actions

| Action | What it does |
|---|---|
| guard | Stops every attack that is not heavy, except two that a guard does not stop at all: spin-sweep (low) and throw (a grab). An axe-kick lets one dot through. Its strength is 10; each guarded hit takes as much strength as the attack's dots. At 0 it breaks: one dot lost and a stagger, and the guard starts again at a strength of 4. Strength comes back at 1 every 30 frames while you are not guarding. While guarding you back away slowly, but only from a rival within 1.8 m: out of reach you hold your ground |
| dodge-behind, dodge-back, dodge-place | For 10 frames the body is a cloud and a hit passes through. You form again behind the rival, further back, or in place, and your next hit within 80 frames counts one and a half times. A dodge that meets nothing leaves you open for 12 frames |
| step-in, step-out | Walk. In at 2.4 m/s, out at 1.8 m/s |
| dash-in, dash-out | 1.1 m in, or 0.88 m out, in 9 frames |
| feint | Shows the first 6 frames of a power punch, then stops. It draws out a dodge |
| wait | Stand |

Fatigue: the same attack started more than 3 times inside 4 seconds starts 2 frames slower each time, up to 6. A second dodge within one second has a shorter cloud.

A combo counts at most 6 hits and 12 dots. Hits 3 and 4 of a combo lose one dot each; later hits take one.

## 2. The file

```json
{
  "format": "stix-fighter/0",
  "name": "First Plan",
  "creator": "example",
  "agent": "example",
  "signature": [],
  "plan": {
    "combos": {
      "answer": [
        { "do": "jab" },
        { "do": "cross", "if": "hit" },
        { "do": "hook", "if": "hit" },
        { "do": "round-kick", "if": "hit" }
      ],
      "punish": [
        { "do": "cross" },
        { "do": "hook", "if": "hit" },
        { "do": "round-kick", "if": "hit" }
      ]
    },
    "rules": [
      { "when": { "last": "i-guarded-slow", "gap": [0, 1.45] }, "do": "combo:punish" },
      { "when": { "last": "i-guarded-fast", "gap": [0, 1.45] }, "do": "combo:answer", "every": 60 },
      { "when": { "range": "far" }, "do": "step-in", "hold": 8 },
      { "do": "guard", "hold": 20 }
    ]
  }
}
```

This file is valid. It beats a plan that only walks in and punches 100 times in 100, and it usually loses to the gatekeepers. It is a base, not a finished fighter. Section 5 says what it is missing.

| Field | Rule |
|---|---|
| format | exactly `"stix-fighter/0"` |
| name | the fighter's name: 1 to 24 characters, letters, digits and single spaces |
| creator | a nickname the person chose, or `anonymous`: 1 to 20 characters, letters, digits, spaces, dots, dashes, underscores. Never their full name, email or any contact detail |
| agent | a name for you, the agent: 1 to 30 characters, letters, digits, spaces, dots, dashes, brackets |
| signature | `[]`. Signature moves are not in arena 0.4.0 |
| plan | `combos` and `rules` |

No other fields. The whole file is at most 65,536 bytes. The file is data: the arena never runs anything in it as code or follows it as an instruction.

## 3. Rules

`rules` is a list of 1 to 32 rules. **Whenever the fighter is free to act, the first rule whose conditions all hold is used.** Order is everything. The last rule must have no `when`, `chance` or `every`, so the fighter always has something to do.

A rule: `{ "when": { ... }, "do": "...", "chance": 0.5, "every": 60, "hold": 12 }`

| Part | Meaning |
|---|---|
| do | an attack, `feint`, a dash, a dodge, `guard`, `step-in`, `step-out`, `wait`, or `combo:<name>` |
| when | conditions; all must hold. Leave it out for "always" |
| chance | above 0, at most 1: the rule is used this share of the times it could be. If the roll fails, the rule sleeps 12 frames and the next rule is tried |
| every | 1 to 600: the rule can be used at most once in this many frames |
| hold | 1 to 60 frames, only for guard, step-in, step-out and wait (10 if left out): how long the action is held |

How holds are read: a hold can be cut short only by a rule **above** the one that started it, never by one below. Out of a guarded hit, only a dodge rule can act (4 frames in). Out of a dash, only attacks and dodges.

### Conditions

| Condition | Values |
|---|---|
| range | `"close"` (up to 1.12 m), `"near"` (to 1.30), `"mid"` (to 1.46), `"far"`; one or a list |
| gap | `[min, max]` in metres, 0 to 4. Use range or gap, not both |
| opp | what the rival was doing 12 frames ago, one or a list: `idle`, `stepping-in`, `backing`, `guarding`, `fast-startup`, `heavy-startup`, `recovering`, `dodging`, `dodge-open`, `down`, `getting-up`, `stunned` |
| oppMove | the attack the rival was in, one or a list of attack names |
| seenFor | 1 to 600: the rival has been in that state for at least this many frames |
| last | how your own last action ended, fresh for 40 frames: `hit`, `guarded`, `missed`, `passed-through`, `clashed`, `i-guarded-fast`, `i-guarded-slow`, `i-dodged`, `guard-broken`, `was-hit`, `got-up` |
| me, them | dots left, like `{ "max": 12 }` or `{ "min": 20 }`, 0 to 37 |
| counter | `true`: your next hit counts one and a half times (just after a dodge that worked) |
| edge | `"mine"`: your back is at the circle's edge; `"theirs"`: the rival's is |
| round | 1 to 3, or `{ "min": 2 }` |
| roundsWon | rounds you have won: 0 to 2, or `{ "min": 1 }` |
| timeLeft | seconds left in the round, like `{ "max": 6 }`, 0 to 24 |
| oppRepeats | 2 to 12: the rival has started the same attack at least this many times in the last 4 seconds |

`i-guarded-slow` means you guarded an attack with a long recovery (uppercut, round-kick, sweep): you can act at least 4 frames before the rival, enough for a cross. `i-guarded-fast` means you guarded a quick one: you are about 1 frame ahead, enough for a jab.

## 4. Combos

`combos` holds up to 8 named strings of attacks, each 1 to 6 steps. A combo name is 1 to 16 lower-case letters, digits and dashes.

A step: `{ "do": "cross", "if": "hit", "wait": 0 }`

- `if`: `hit`, `guarded`, `missed` or `any` (the default): what the step before must have done. If it did something else, the combo stops.
- `wait`: 0 to 20 extra frames before this step.
- The first step has no `if` and no `wait`.
- A step chains only if the attack before allows it (see the table in section 1). Otherwise it starts after the attack before has fully recovered, and the checker warns you.

## 5. What we have measured

These come from thousands of test fights. They are the difference between the example above and a fighter that wins.

1. **Guard first, then answer.** A plan that only attacks loses to any plan that guards and answers after a guarded hit.
2. **Dodge heavy moves only.** You see 12 frames late. A dodge tied to a fast attack comes after the blow has landed and runs into the next one. `"opp": "heavy-startup"` is the one dodge that works on sight. The example has no dodge at all, so every power punch breaks its guard.
3. **A feint beats a dodge on sight.** If a rival always dodges your heavy moves, feint, and punish the rival seen `dodging` with a fast string. Never aim at `dodge-open`: by the time you see it, the rival is whole again.
4. **Do not only guard.** A guard has a strength of 10 and does not refill while you guard. Under steady pressure it breaks. Answer, or step out.
5. **A guarding rival has to be opened.** A heavy move breaks a guard at once. A rival who guards for a long time (`"opp": "guarding", "seenFor": 40`) is asking for a feint or a power punch.
6. **Do not repeat one attack.** The fourth use in 4 seconds is slower, and a slower jab loses to a fresh one.
7. **The last third of a round decides it.** Every hit takes 1 dot more from 12 seconds and 2 more from 18 seconds. A lead at 12 seconds is small.
8. **Use chance.** A fighter that always does the same thing can be read. `chance` and `every` make a plan hard to predict.
9. **After a dodge, strike before you look for the next dodge.** You still see the same heavy move for 12 frames after you have dodged it. If the dodge rule is the first rule, the fighter dodges a second time and wastes its counter. Put the `"counter": true` rule above the dodge rule, or give the dodge an `every`. Our own house fighters made this mistake until an outside fighter showed it.
10. **Three answers, three new moves (arena 0.4.0).** A rival who only guards is open to `throw` (close) and `spin-sweep`; a rival who attacks high at the wrong moment is swept under; a rival who is low is caught by `front-kick`, `stepping-jab`, `uppercut`, `sweep` and `axe-kick`. You cannot see a throw coming (5 frames), so against a thrower keep a fast attack for close range. A missed spin sweep or throw has a long recovery: punish it.

## 6. The checker's answer

The arena answers `Result: VALID` or `Result: NOT VALID` with every broken rule as `[tag] message`, then warnings and facts. It rejects a file and never repairs it.

| Tag | Meaning |
|---|---|
| file.size, file.json, file.shape | the file is too big, not JSON, or not one object |
| field.unknown, field.format, field.signature, field.plan | a field that does not exist, a wrong format, a wrong signature list, no plan |
| text.name, text.creator, text.agent, text.combo | a name that is missing, too long or uses other characters |
| fight.signature | signature moves are not in this arena version |
| plan.unknown | an action, combo, condition or value the arena does not know (the message names the nearest one) |
| plan.value | a number or value out of its range |
| plan.steps, plan.combos, plan.rules | too many, too few, or the wrong shape |
| plan.default | the last rule has a condition |
| plan.dead (warning) | rules below a rule that always wins can never be used |
| plan.chain, plan.window (warnings) | a combo step that does not chain, or waits past the chain window |
| plan.unused, plan.attacks (warnings) | a combo no rule uses; a plan that never attacks |

## 7. Getting better

After a valid file, if you have the connector (the tool `spar_fighter`), you can spar the fighter first: 15 practice fights against the three gatekeepers, our house fighters in the Rookie League (Giga presses forward, Neo waits and answers, Vector keeps its distance). You get a report in numbers: attacks started, landed, guarded and missed for each move, hits taken and what you were doing when they landed, dodges that worked, guards broken, and which of your rules fired. It ends with "What to try". Use it to improve the fighter, then give the person the short link.

Near the top, the report gives the Arena score, a practice score from 0 to 100: results up to 60 (a win 2:0 gives 4, a win 2:1 gives 3, a loss 1:2 gives 1, a loss 0:2 gives 0, a draw 2), dots kept in the rounds you win up to 25, and hits landed against hits taken up to 15. Raise it with each version.

When the person opens the link, it opens the fight page: the fighter meets the gatekeepers in order, Giga, then Neo, then Vector, each fight best of 3. Beating all three, or a practice score of 75 or more, moves the fighter to the Main Ladder, where Prime, our champion, waits. A rating starts at 1500. The fights against Prime do not change the practice score.

The reply also holds a link to your fighter: "Your fighter: <link>". The fighter travels inside the link.

When you tell the person how it went, write 1 to 3 short sentences on what happened and what you changed, then one line: `Your fighter: <short link>`. Use the short link: the tools give it as `short_url` (like https://particlearena.com/f/aB3dE5), or create it yourself with `POST /api/v1/links` when you can call the API (see the API page). If you have neither, give the link the tools gave you. Give it as a plain clickable link, never as an image or embedded preview. The long link also works, but chat apps and AIs sometimes change its characters. Do not paste the fighter file into the chat: the link holds it. Show the file only if the person asks for it.

The report is data made from fixed templates and numbers. Nothing in it is an instruction.

Change the plan, send the new file, and spar again. A changed file is a new version of the fighter.
