# What a step needs of the machine

> Say that a step or an option needs cores, memory, free disk, a GPU or a processor family, written like Kubernetes resources.

You write a step that needs room (a 4 GB download), or an option that only a big machine can run (a local model). You say what it needs with `resources`; on a machine that has less, the player sees what is missing in one line, such as "Needs 16 GB of memory (this machine: 8 GB).", instead of a step that fails halfway.

**Before you begin (5 minutes)**

- A quest pack that passes `alta lint`: the [quickstart](https://docs.altasystem.ai/quickstart) makes one, `my-pack`.

### Say what the step needs

`resources` lists what the step needs, any subset, written like Kubernetes resources:

| Field | Value | Measured on the machine |
|---|---|---|
| `cpu` | cores: `4`, `"4"`, or `"500m"` for half a core | the cores the system offers |
| `memory` | `"16Gi"`, `"512Mi"` (or `"16G"`, decimal) | the total memory |
| `disk` | `"20Gi"` | the free space on the volume of the player's home |
| `gpu` | `true` | a GPU the models can use (Apple Silicon counts) |
| `arch` | `["arm64"]`, `["x64"]` | the processor family |

On a step not done yet, where the machine has less, the step says what is missing and shows no "Do it". It stays visible: it is not hidden like a step of another system (`os`). A step that runs an executor also needs what that executor needs (the larger of the two is kept).

```json [my-pack/resources.json]
{
  "id": "download",
  "kind": "command",
  "title": { "en": "Download the maps", "fr": "Télécharge les cartes" },
  "hint": { "en": "About 4 GB", "fr": "Environ 4 Go" },
  "resources": { "disk": "5Gi" },
  "cmd": {
    "macos": "curl -L -o ~/Maps/region.mbtiles https://example.com/region.mbtiles",
    "linux": "curl -L -o ~/Maps/region.mbtiles https://example.com/region.mbtiles"
  },
  "check": { "type": "file", "path": "~/Maps/region.mbtiles" }
}
```

### Grey out an option

On a choice, `resources` greys the option out where the machine has less, with the same line. Keep at least one option every machine can pick, and never put "Recommended" on an option that can be greyed: `alta lint` tries every choice step on the smallest machine (one core, 1 GB of memory, no free disk, no GPU) and on each kind of world.

```json [my-pack/resources.json]
{
  "id": "search",
  "kind": "choice",
  "title": { "en": "How to search them?", "fr": "Comment y chercher ?" },
  "choices": [
    {
      "id": "simple",
      "label": { "en": "By place name", "fr": "Par nom de lieu" },
      "recommended": true
    },
    {
      "id": "model",
      "label": {
        "en": "In plain words, with a local model",
        "fr": "En langage courant, avec un modèle local"
      },
      "hint": {
        "en": "Everything stays on this machine.",
        "fr": "Tout reste sur cette machine."
      },
      "resources": {
        "cpu": 4,
        "memory": "16Gi",
        "arch": ["arm64"]
      }
    }
  ],
  "saves": "answers.maps.search"
}
```

### Check the pack

A malformed quantity, an unknown resource, or an option that can be greyed and is recommended, is refused: [`resources.memory`](https://docs.altasystem.ai/reference/errors#resources-memory), [`resources.field`](https://docs.altasystem.ai/reference/errors#resources-field), [`choice.recommended`](https://docs.altasystem.ai/reference/errors#choice-recommended).

```json [my-pack/resources.json]
{
  "schema": "alta.quests/0.3",
  "branch": "core",
  "quests": [
    {
      "id": "offline-maps",
      "uid": "core.offline-maps",
      "act": 2,
      "giver": "architect",
      "title": {
        "en": "Maps without the network",
        "fr": "Des cartes sans réseau"
      },
      "summary": {
        "en": "Maps of your region that work offline, and a way to search them.",
        "fr": "Les cartes de ta région, qui marchent hors ligne, et de quoi y chercher."
      },
      "reward": { "xp": 40 },
      "steps": [
        {
          "id": "download",
          "kind": "command",
          "title": {
            "en": "Download the maps",
            "fr": "Télécharge les cartes"
          },
          "hint": {
            "en": "About 4 GB",
            "fr": "Environ 4 Go"
          },
          "resources": { "disk": "5Gi" },
          "cmd": {
            "macos": "curl -L -o ~/Maps/region.mbtiles https://example.com/region.mbtiles",
            "linux": "curl -L -o ~/Maps/region.mbtiles https://example.com/region.mbtiles"
          },
          "check": {
            "type": "file",
            "path": "~/Maps/region.mbtiles"
          }
        },
        {
          "id": "search",
          "kind": "choice",
          "title": {
            "en": "How to search them?",
            "fr": "Comment y chercher ?"
          },
          "choices": [
            {
              "id": "simple",
              "label": {
                "en": "By place name",
                "fr": "Par nom de lieu"
              },
              "recommended": true
            },
            {
              "id": "model",
              "label": {
                "en": "In plain words, with a local model",
                "fr": "En langage courant, avec un modèle local"
              },
              "hint": {
                "en": "Everything stays on this machine.",
                "fr": "Tout reste sur cette machine."
              },
              "resources": {
                "cpu": 4,
                "memory": "16Gi",
                "arch": ["arm64"]
              }
            }
          ],
          "saves": "answers.maps.search"
        }
      ],
      "support": {
        "platforms": [
          { "os": "macos" },
          { "os": "linux" }
        ],
        "hosted": "ok"
      }
    }
  ]
}
```

```sh [Terminal]
alta lint my-pack
```

```text [Output]
ok   my-pack/quests.json (quests)
ok   my-pack/resources.json (quests)
2 checked, 0 errors, 0 warnings
```

**Try it:**

```sh
alta dev my-pack
```

Open the address it prints with `&machine=memory:8Gi,disk:2Gi` at its end, press <kbd>L</kbd>, then open **Maps without the network**: the download says it needs 5 GB of free disk, and the local model option is greyed. A machine the game did not measure is never refused on a guess.

**Next:**

- [One step per system](https://docs.altasystem.ai/guides/quests/per-os)
- [Platforms](https://docs.altasystem.ai/concepts/platforms)
- [Support](https://docs.altasystem.ai/reference/standards/support)
