Skip to content

Playground

What should the character do next?

What should the character do next? When health is low it drinks a potion to stay alive; when health is high it attacks.

What this sample shows. Game AI is full of "pick one move from a fixed list" decisions, usually hand-written as if-else trees. Here the character's state goes to a decision model as a single choice question: attack, drink a potion, flee, ask for a truce, or taunt. You get back one action your game loop can run as-is, plus the probability behind every option.

Sample input and result (sample data, not a live model run). A border guard stands on a narrow bridge at 12% health, facing 3 enemies, with 1 healing potion and no ally nearby. Result: drink a potion, 58%. Flee follows at 24%, ask for a truce 9%, attack 7%, taunt 2%. Change only the health to 80%. The pick flips to attack at 64%, with taunt at 18% and the potion down to 3%.

Why the probabilities matter. In the low-health case, the potion wins with 58% while fleeing still holds 24%. You can sample from that spread, or fall back to a scripted rule when the top option isn't confident enough, so the guard doesn't behave identically every time.

When to use this approach. It fits when the state fits in a few fields, the moves are fixed, and you want an answer you can execute rather than a paragraph of reasoning. The sample request uses Decider (decider-v1.1). If the state includes a screenshot, switch to a Clef model, which accepts images.

Frequently asked questions

Are the probabilities on this page computed live?

No. They are sample data and don't change when you switch models. Sign in to run your own game state.

Can I define my own actions?

Yes. The model picks from whatever you list in criteria. The maximum number of options is in each model's Model info.

Is it cheap enough to call every frame?

Cost depends on request size and the number of questions; see Pricing. Measure latency in your own game before calling it per frame.

Sample results do not change with the selected model.

Request

state
application/json
{  "npc": "Border guard",  "hp": "12%",  "enemies": 3,  "inventory": {    "healing_potion": 1  },  "terrain": "narrow bridge",  "ally_nearby": false}

Results

Sample data
Compare two examples

These two examples differ by one detail. The result changes with them.

What changedLow health → high health

These results are sample data, not a live model run. Sign in to try them with your own content.
action: attack · Attack → potion · Drink a potion
actionchoice
potion · Drink a potion
Confidence per option
Attack
7%
Drink a potion
58%
Flee
24%
Ask for a truce
9%
Taunt
2%

Copy the code

Set SYSTEM_ONE_API_KEY. The snippet uses a published catalog model id.

Request JSON
application/json
{"model":"decider-v1.1","state":{"npc":"Border guard","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"narrow bridge","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC's next action given the game state.","criteria":{"attack":"Attack","potion":"Drink a potion","flee":"Flee","parley":"Ask for a truce","taunt":"Taunt"}}}}
cURL · POST /v1/systemone
sh
curl "https://system-one.dev/v1/systemone" \  -H "Authorization: Bearer $SYSTEM_ONE_API_KEY" \  -H 'Content-Type: application/json' \  -H 'Idempotency-Key: saved-operation-id' \  --data '{"model":"decider-v1.1","state":{"npc":"Border guard","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"narrow bridge","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC'\''s next action given the game state.","criteria":{"attack":"Attack","potion":"Drink a potion","flee":"Flee","parley":"Ask for a truce","taunt":"Taunt"}}}}'
TypeScript
TypeScript
// npm install @system-one-ai/core@0.8.0 @system-one-ai/adapter-system-one@0.7.0 @system-one-ai/transport-fetch@0.8.0import { createSystemOne, choice, score, booleanQuestion } from '@system-one-ai/core';import { systemOneAdapter } from '@system-one-ai/adapter-system-one';import { createFetchTransport } from '@system-one-ai/transport-fetch';const client = createSystemOne({  baseURL: "https://system-one.dev/v1",  apiKey: process.env.SYSTEM_ONE_API_KEY!,  model: "decider-v1.1",  adapter: systemOneAdapter,  transport: createFetchTransport(),  timeoutMs: 30_000,  maxRetries: 0,});const result = await client.evaluate({  state: {    "npc": "Border guard",    "hp": "12%",    "enemies": 3,    "inventory": {      "healing_potion": 1    },    "terrain": "narrow bridge",    "ally_nearby": false  },  questions: {  action: choice("Choose the NPC's next action given the game state.", {    attack: "Attack",    potion: "Drink a potion",    flee: "Flee",    parley: "Ask for a truce",    taunt: "Taunt",  }),  },}, { headers: { 'Idempotency-Key': crypto.randomUUID() } });result.answers.action.choiceresult.response.requestId;