AI Integration
The AI is a planner and author, not the real-time game loop. It converts intent into a small Lua policy that composes deterministic Hexis actions. Java/native code executes time-sensitive behavior.
Why Lua remains important
Model calls are too slow and unpredictable for aiming, movement corrections, attack timing, or mining coordination. A generated script can make policy decisions locally while calling trusted actions that operate at game speed.
The model should generate tens of lines of intent, not hundreds of lines that recreate the Hexis engine.
Contract registry
The long-term source of truth is a machine-readable registry for every AI-visible capability:
- canonical name and version;
- concise semantic description;
- typed arguments and defaults;
- result and progress schemas;
- stable failure codes and retry guidance;
- required permissions and resource leases;
- server-pack requirements;
- positive, negative, and composition examples;
- deprecation and replacement metadata.
Bindings, reference tables, Lua annotations, AI tool definitions, validation, and contract tests should be generated from this registry. Handwritten prose explains architecture and judgment; generated surfaces prevent drift.
Generation pipeline
- Translate the user request into explicit goals, constraints, and stop rules.
- Select the smallest sufficient capabilities and server pack.
- Prefer high-level actions; use
hexis.rawonly when no suitable contract exists or the user explicitly requests custom mechanics. - Generate a capability manifest and Lua plan.
- Validate syntax, types, permissions, lifecycle, and boundedness.
- Simulate or dry-run where the action supports it.
- Ask for approval when permissions or irreversible consequences require it.
- Execute with budgets, cancellation, and structured telemetry.
- Repair policy from stable result codes, never from arbitrary memory scraping.
AI quality evaluation
Every candidate contract is evaluated with a fixed prompt suite:
- generate a correct first attempt from a user goal;
- choose high-level actions instead of unnecessary raw input;
- handle documented terminal failures;
- cancel and clean up correctly;
- adapt the same goal to a second server pack;
- repair a script from structured diagnostics;
- avoid nonexistent or deprecated functions.
Track first-pass success, raw-overuse rate, repair turns, permission accuracy, lines of Lua, and live task success. If an AI repeatedly guesses the wrong call, the contract or documentation is defective.
Longer-term goal execution
Future agents may maintain a user goal over multiple sessions, inspect inventory/world observations, select scripts as reusable skills, and create new policies. That orchestration remains outside the tick loop. It must respect the same permissions, budgets, provenance, and user-visible stop controls as a single generated script.