
_
在可靠的游戏 AI 集成中,JEV 不应发明任意命令。游戏首先生成 可执行动作: Choice 在当前规则、感知、资源和权限约束下可能的情况。 JEV 可以选择或 Score 那些候选人;执行者在改变世界之前重新检查它们.
什么是法律诉讼?可执行动作是允许当前特工尝试的有意义的命令。它具有稳定的名称、显式参数、前提条件和执行所有者。示例包括attack(targetId)_、_takeCover(coverId)_、 heal(allyId), 和 retreat(routeId).为什么不采取自由形式的操作?自由格式生成使验证、测试和平衡变得更加困难。模型可能会返回不再存在的目标、无法到达的路线或未实现的动词。封闭的行动集将发明转化为选择:设计者检查候选人,QA 重播他们,执行者拒绝合同之外的任何内容。在游戏代码中生成候选
if (canSeeTarget && ammo > 0) add({ name: 'attack', targetId }); if (safeCover) add({ name: 'takeCover', coverId }); if (allyNeedsHelp) add({ name: 'assist', allyId }); if (empty) add({ name: 'holdPosition' });
构建器使用权威状态和代理的感知。候选列表仍然是一个快照,不能替代最终验证。
Choice、Score 和门
if (canSeeTarget && ammo > 0) add({ name: 'attack', targetId }); if (safeCover) add({ name: 'takeCover', coverId }); if (allyNeedsHelp) add({ name: 'assist', allyId }); if (empty) add({ name: 'holdPosition' });执行前重新验证
当响应到达时,重建或重新检查当前操作集。验证名称、参数、状态版本、目标存在、资源和权限。如果候选人消失,则丢弃响应并使用 兜底策略。永远不要将旧的决定强加于新的世界状态。
const current = buildLegalActions(world, npc); const selected = current.find(action => sameAction(action, decision)); if (!selected) return 兜底策略(); return execute(selected);
动作空间应该有多大?
从一些代表真正权衡的选项开始。公开每个移动选项迫使决策层一起解决导航和战术问题。对于NPC小队来说,防守、掩护、协助、攻击和撤退就足够了;导航和能力处理低级细节。
const current = buildLegalActions(world, npc); const selected = current.find(action => sameAction(action, decision)); if (!selected) return fallback(); return execute(selected);目标死亡、冷却时间开始、路线受阻、感知发生变化。在实时游戏中将陈旧视为正常现象。丢弃结果,重建状态,并继续执行确定性策略。对于 API 实现,请阅读 JEV API 用法_。对于 NPC 架构,请参阅 JEV .
有用的操作模式
将每个操作表示为具有 ID、意图、参数、先决条件、估计持续时间、资源成本和执行者的数据。当前快照的 ID 应该是稳定的,而目标和位置引用应该是明确的。这为设计人员和 QA 提供了讨论行为的共享词汇。
{ id: 'cover-wall-a', intent: 'takeCover', target: { coverId: 'wall-a' }, cost: { timeMs: 900 }, preconditions: ['reachable', 'notOccupied'] }排名前修剪硬约束属于模型评估之前。删除违反范围、冷却时间、所有权、可见性、导航或多人游戏规则的操作。只有这样,JEV 才应该比较更软的权衡,例如安全、客观压力、资源节约和团队协调。这可以减少噪音并使结果更容易解释。动作空间较大时使用两阶段设计:首先Score或将候选者过滤到一个小范围内,然后选择一个操作。例如,游戏代码可以生成二十个可见的掩护点,JEV 可以 Score 其战术价值,而确定性策略可以在最终 Choice 之前保留最好的三个。导航仍然拥有路径有效性。
动作空间设计是游戏平衡
添加操作会更改 NPC 的策略空间。增加撤退可能会使守卫生存得更久;增加助攻可能会提高球队凝聚力,但会延迟目标的实现。版本化动作词汇,重播代表性的遭遇,并要求设计者不仅审查动作是否合法,而且审查它是否会产生预期的权衡。
{ id: 'cover-wall-a', intent: 'takeCover', target: { coverId: 'wall-a' }, cost: { timeMs: 900 }, preconditions: ['reachable', 'notOccupied'] }_每个候选人都有一个处理程序.每个处理程序都会检查当前的先决条件再次.未知操作 ID 无法关闭。参数类型和目标所有权为已验证。过时的候选者在重播和实时测试中被拒绝。当候选者列表有效时,兜底策略 仍然合法。空._
Hard constraints belong before model evaluation. Remove actions that violate range, cooldown, ownership, visibility, navigation, or multiplayer rules. Only then should JEV compare softer trade-offs such as safety, objective pressure, resource conservation, and team coordination. This reduces noise and makes the result easier to explain.
When the action space is large
Use a two-stage design: first score or filter candidates into a small frontier, then choose one action. For example, game code can generate twenty visible cover points, JEV can score their tactical value, and a deterministic policy can keep the best three before a final Choice. Navigation still owns path validity.
Action-space design is game balance
Adding an action changes the NPC's strategy space. Adding retreat may make a guard survive longer; adding assist may improve squad cohesion but delay the objective. Version the action vocabulary, replay representative encounters, and ask designers to review not only whether an action is legal but also whether it creates the intended trade-off.
Contract tests
- Every candidate has a handler.
- Every handler checks current preconditions again.
- Unknown action IDs fail closed.
- Parameter types and target ownership are validated.
- Stale candidates are rejected in replay and live tests.
- The 兜底策略 remains legal when the candidate list is empty.


