跳至主要内容

Playground

角色下一步该做什么?

角色下一步该做什么?生命值低时喝药水求生;生命值高时攻击。

本示例展示什么。 游戏 AI 里充满「从固定列表中选一步」的决策,通常写成 if-else。这里把角色状态交给决策模型,作为单一 Choice 问题:攻击、喝药水、逃跑、求和或嘲讽。你得到游戏循环可直接执行的一个动作,以及每个选项的概率。

示例输入与结果(示例数据,非实况模型运行)。 边境守卫站在窄桥上,生命值 12%,面对 3 名敌人,有 1 瓶治疗药水,附近无盟友。结果:喝药水,58%。逃跑 24%,求和 9%,攻击 7%,嘲讽 2%。 仅将生命值改为 80%。选择翻转为攻击 64%,嘲讽 18%,药水降至 3%。

概率为何重要。 低生命时药水以 58% 胜出,逃跑仍有 24%。可从该分布中采样,或在最高选项不够自信时回退到脚本规则,避免守卫每次行为完全相同。

适用场景。 状态可用少量字段表示、动作固定、且需要可执行答案而非长段推理时适用。示例请求使用 Decider(decider-v1.1)。若状态含截图,可改用支持图像的 Clef 模型。

常见问题

本页的概率是实时计算的吗?

不是。它们是示例数据,切换模型不会变化。登录后可运行你自己的游戏状态。

可以自定义动作吗?

可以。模型从你在 criteria 中列出的选项中选择。选项数量上限见各模型的 Model info。

每帧调用成本够低吗?

成本取决于请求大小与问题数量;见 定价。在每帧调用前,请先在自己的游戏中测量延迟。

示例结果不随所选模型变化。

请求

state
application/json
{  "npc": "边境守卫",  "hp": "12%",  "enemies": 3,  "inventory": {    "healing_potion": 1  },  "terrain": "狭窄桥面",  "ally_nearby": false}

结果

示例数据
对比两个示例

这两个示例仅有一处细节不同。结果随之变化。

变化之处低生命值 → 高生命值

这些结果为示例数据,非实况模型运行。登录后可用你自己的内容试用。
action: attack · 攻击 → potion · 喝药水
actionchoice
potion · 喝药水
各选项置信度
攻击
7%
喝药水
58%
逃跑
24%
请求停战
9%
嘲讽
2%

复制代码

设置 SYSTEM_ONE_API_KEY。代码片段使用已发布的目录模型 ID。

请求 JSON
application/json
{"model":"decider-v1.1","state":{"npc":"边境守卫","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"狭窄桥面","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC's next action given the game state.","criteria":{"attack":"攻击","potion":"喝药水","flee":"逃跑","parley":"请求停战","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":"边境守卫","hp":"12%","enemies":3,"inventory":{"healing_potion":1},"terrain":"狭窄桥面","ally_nearby":false},"questions":{"action":{"type":"choice","instructions":"Choose the NPC'\''s next action given the game state.","criteria":{"attack":"攻击","potion":"喝药水","flee":"逃跑","parley":"请求停战","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": "边境守卫",    "hp": "12%",    "enemies": 3,    "inventory": {      "healing_potion": 1    },    "terrain": "狭窄桥面",    "ally_nearby": false  },  questions: {  action: choice("Choose the NPC's next action given the game state.", {    attack: "攻击",    potion: "喝药水",    flee: "逃跑",    parley: "请求停战",    taunt: "嘲讽",  }),  },}, { headers: { 'Idempotency-Key': crypto.randomUUID() } });result.answers.action.choiceresult.response.requestId;