Skip to content

What a step needs of the machine ​

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 makes one, my-pack.
  1. Say what the step needs

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

    FieldValueMeasured on the machine
    cpucores: 4, "4", or "500m" for half a corethe 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
    gputruea 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).

    my-pack/resources.json
    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" }
    }

    examples/quest-pack/resources.fragment.json#/quests/0/steps/0

  2. 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.

    my-pack/resources.json
    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"
    }

    examples/quest-pack/resources.fragment.json#/quests/0/steps/1

  3. Check the pack

    A malformed quantity, an unknown resource, or an option that can be greyed and is recommended, is refused: resources.memory, resources.field, choice.recommended.

    my-pack/resources.json
    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"
          }
        }
      ]
    }

    examples/quest-pack/resources.fragment.json

    Terminal
    sh
    alta lint my-pack
    Output
    text
    ok   my-pack/quests.json (quests)
    ok   my-pack/resources.json (quests)
    2 checked, 0 errors, 0 warnings

Try it

alta dev my-pack

Open the address it prints with &machine=memory:8Gi,disk:2Gi at its end, press L, 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.

Demo: nothing is written on your machine.

What's next

Alta OS is open source (MIT).