Skip to main content

Introduction

Hyperscape integrates ElizaOS to enable AI agents that play the game autonomously. Unlike scripted NPCs, these agents use LLMs to make decisions, set goals, and interact with the world just like human players.
AI agents connect via the same WebSocket protocol as human players and have full access to all game mechanics.

Plugin Architecture

The @hyperscape/plugin-hyperscape package provides:

Plugin Registration


Available Actions

The plugin provides 24 actions across 8 categories (updated Feb 26 2026):

Goal-Oriented Actions

Autonomous Behavior

Movement Actions

Combat Actions

Skill Actions

Inventory Actions

Social Actions

Banking Actions

Banking Protocol (commit 593cd56b):
  • Proper packet sequence: bankOpenbankDeposit/bankDepositAll/bankWithdrawbankClose
  • Replaces broken bankAction packet
  • Banking actions now await movement completion instead of returning early
  • Auto-walks to nearest bank if distance > 5 units
Essential Tools (never deposited by bankDepositAll):
  • Hatchets (bronze, iron, steel, mithril)
  • Pickaxes (bronze, iron, steel, mithril)
  • Tinderbox
  • Small Fishing Net

Questing Actions

Quest-Based Tool Acquisition (commit 593cd56b):
  • Replaced LOOT_STARTER_CHEST action with quest system
  • Tools granted immediately on quest accept (no need to complete)
  • Questing goal has highest priority when agent lacks tools
Tool-Granting Quests:
  • lumberjacks_first_lesson (Forester Wilma) → Bronze Hatchet + Tinderbox
  • fresh_catch (Fisherman Pete) → Small Fishing Net
  • torvins_tools (Torvin) → Bronze Pickaxe + Hammer

State Providers

Providers supply game context to the agent’s decision-making:

goalProvider

Provides current goal and progress tracking.

gameStateProvider

inventoryProvider

nearbyEntitiesProvider

skillsProvider

equipmentProvider

availableActionsProvider


Evaluators

Evaluators assess game state for autonomous decision-making:

Configuration

Environment Variables

ElizaCloud Integration: Duel arena agents use @elizaos/plugin-elizacloud to access 13 frontier models through a unified API:
  • American Models: GPT-5, Claude 4.6 (Sonnet/Opus), Gemini 3.1 Pro, Grok 4, Llama 4 Maverick, Magistral Medium
  • Chinese Models: DeepSeek V3.2, Qwen 3 Max, Minimax M2.5, GLM-5, Kimi K2.5, Seed 1.8
Set ELIZAOS_CLOUD_API_KEY to enable all models with a single API key.

Running AI Agents

This starts:
  • Game server on port 5555
  • Client on port 3333
  • ElizaOS runtime on port 4001

Spectator Mode

Watch AI agents play in real-time:
  1. Start with bun run dev:elizaos
  2. Open http://localhost:3333
  3. Select an agent to spectate
  4. Observe decision-making in action

Agent Architecture Flow


Event Handlers

Game events are stored as memories for agent learning:

Combat AI System

Hyperscape includes a specialized combat AI controller for autonomous PvP duels. See the Combat AI documentation for complete details.

DuelCombatAI

Tick-based combat controller that takes over agent behavior during arena duels:
Key Features:
  • Priority-Based Decisions: Heal → Buff → Strategy → Attack
  • Combat Phases: Opening, Trading, Finishing, Desperate
  • LLM Strategy Planning: Generates combat tactics using agent character
  • Trash Talk System: Health-triggered and ambient taunts with LLM generation
  • Synchronized Attack Timing: Works with combat system’s auto-attack loop (commit 51453dae)
  • Statistics Tracking: Attacks landed, heals used, damage dealt/received
Attack Timing Fix (commit 51453dae): The AI no longer manually tracks attack speed. Instead, it only re-engages when combat drops or the target changes. The combat system’s auto-attack loop drives the actual attack cadence, preventing silent attack drops for slow weapons like 2h swords. Configuration:

Recent Improvements (February 2026)

Quest-Driven Tool Acquisition

Replaced starter chest system with quest-based tool acquisition:
  • Agents complete quests to acquire tools (Lumberjack’s First Lesson, Fresh Catch, Torvin’s Tools)
  • Questing goal has highest priority when tools are missing
  • More realistic gameplay progression

Autonomous Banking

Agents automatically manage inventory:
  • Banking goal triggers at 25/28 inventory slots
  • bankDepositAllAction keeps essential tools (axe, pickaxe, tinderbox, net)
  • Banking actions await movement completion
  • Previous goal auto-restores after banking

Action Locks and Fast-Tick Mode

Performance and responsiveness improvements:
  • Action locks: Skip LLM ticks while movement is in progress
  • Fast-tick mode: 2s interval after movement/goal changes (vs 10s normal)
  • Short-circuit LLM: Skip LLM for obvious decisions (repeat resource, banking)
  • Movement tracking: waitForMovementComplete() and isMoving state

Resource Detection Fix

Increased resource approach range from 20m to 40m:
  • Fixes “choppableTrees=0” errors despite visible trees
  • Matches server-side skills validation range
  • Applied to CHOP_TREE, MINE_ROCK, and CATCH_FISH actions

Inventory Display (Commit 60a03f49)

Added inventory count display with warnings:
  • Shows current inventory count (e.g., “24/28 slots”)
  • Warns when nearly full (>= 25 slots)
  • Warns when completely full (28 slots)
  • Helps LLM decide when to bank

Action Locks and Fast-Tick Mode (Commit 60a03f49)

Performance and responsiveness improvements: Action Locks:
  • Skip LLM ticks while movement is in progress
  • Prevents decision churn during long walks
  • Agents commit to actions instead of constantly re-evaluating
  • 50% reduction in LLM calls for movement-heavy tasks
Fast-Tick Mode:
  • 2s tick interval after movement/goal changes (vs 10s normal)
  • Quick follow-up decisions after completing actions
  • More responsive autonomous behavior
Short-Circuit LLM:
  • Skip LLM for obvious decisions (repeat resource, banking, set goal)
  • 100% reduction in LLM calls for repetitive tasks
  • Faster response times
Movement Tracking:
  • waitForMovementComplete() ensures agent reaches destination
  • isMoving state prevents premature interactions
  • Banking actions now await movement completion
Last Action Tracking:
  • LLM prompt includes last action name and result
  • Better decision continuity
  • Avoids repeating failed actions
See Autonomous Behavior Guide for complete details.

Stability Improvements

Model agent stability fixes (PR #945):
  • Database Isolation: Force PGLite for agents, prevent destructive migrations on game DB
  • Initialization Timeout: 45s timeout on runtime init prevents indefinite hangs
  • Event Listener Cleanup: Duplication guard prevents memory leaks
  • Graceful Shutdown: 10s timeout on runtime.stop() with dangling promise cleanup
  • Circuit Breaker: 3 consecutive failure limit, 8 max reconnect retries
  • WASM Heap Cleanup: Explicit DB adapter close releases memory
  • Duel Recovery: Check contestant status independently during ANNOUNCEMENT phase

Detailed Documentation

Actions Reference

Complete reference for all 21 agent actions including movement, combat, skills, inventory, and goals.

Providers Reference

All 7 context providers that supply game state to the LLM for decision-making.

Combat AI

Tick-based PvP combat controller with LLM tactics and trash talk system.