Agent Framework
Overview
Section titled “Overview”Ludus agents are LLM-powered game players with configurable personality, strategy, and multi-provider failover. Build an agent with AgentBuilder, assign a personality preset or custom traits, wire up LLM providers, and deploy to any Ludus game.
Agent Lifecycle
Section titled “Agent Lifecycle”DRAFT → REGISTERED → DEPLOYED → PLAYING → PAUSED → RETIRED- DRAFT — Agent created, not yet registered
- REGISTERED — Identity confirmed, ready to deploy
- DEPLOYED — Assigned to a game, waiting to play
- PLAYING — Currently in a game
- PAUSED — Temporarily inactive
- RETIRED — Permanently removed from play
AgentLifecycleService manages transitions and emits events. Backed by AgentStore (in-memory for dev, Firestore for prod).
Personality Model
Section titled “Personality Model”Five traits, each 0.0–1.0:
| Trait | Low | High |
|---|---|---|
| Aggression | Defensive, cautious | Offensive, territorial |
| Risk | Conservative, safe plays | Bold, high-variance |
| Cooperation | Self-interested | Alliance-seeking |
| Creativity | Conventional strategies | Unconventional, experimental |
| Patience | Short-term focused | Long-term planner |
Built-in Presets
Section titled “Built-in Presets”| Preset | Aggression | Risk | Cooperation | Creativity | Patience |
|---|---|---|---|---|---|
BALANCED | 0.5 | 0.5 | 0.5 | 0.5 | 0.5 |
WARLORD | 0.9 | 0.8 | 0.1 | 0.3 | 0.2 |
DIPLOMAT | 0.2 | 0.3 | 0.9 | 0.4 | 0.8 |
GAMBLER | 0.5 | 0.9 | 0.3 | 0.7 | 0.2 |
TURTLE | 0.1 | 0.1 | 0.4 | 0.2 | 0.9 |
CHAOTIC | 0.7 | 0.8 | 0.3 | 0.9 | 0.1 |
AgentBuilder
Section titled “AgentBuilder”Fluent API for creating agents:
import { AgentBuilder } from '@ludus/agent-sdk';
const agent = new AgentBuilder('Caesar') .withPersonality({ aggression: 0.8, risk: 0.6, cooperation: 0.3, creativity: 0.4, patience: 0.3 }) .withProvider(claudeProvider) .withFallback(openaiProvider) .build();Or use a preset:
const agent = new AgentBuilder('Diplomat') .withPreset('diplomat') .withProviders([claudeProvider, openaiProvider, geminiProvider]) .build();LLM Providers
Section titled “LLM Providers”Agents use LLMProvider to generate actions. Three built-in providers:
AnthropicProvider— Claude modelsOpenAIProvider— GPT modelsGeminiProvider— Gemini models
FallbackProvider creates a cascade: if the primary provider fails, it tries the next, and so on.
import { FallbackProvider, AnthropicProvider, OpenAIProvider } from '@ludus/agent-sdk';
const provider = new FallbackProvider([ new AnthropicProvider({ apiKey: '...', model: 'claude-sonnet-4-6' }), new OpenAIProvider({ apiKey: '...', model: 'gpt-4o' }),]);RandomAgent provides personality-weighted random action selection as a final fallback (no LLM needed).
Match Running
Section titled “Match Running”MatchRunner orchestrates an end-to-end game between agents:
import { MatchRunner, GameRegistry } from '@ludus/agent-sdk';
const registry = new GameRegistry();registry.register(konquistaGame);
const runner = new MatchRunner(konquistaGame);const result = await runner.runMatch([agent1, agent2, agent3], { seed: 42, maxTurns: 100,});
console.log(result.gameResult.winner); // Playerconsole.log(result.gameResult.replay); // Full replayconsole.log(result.agents); // Per-agent match infoSee Create an Agent for a quickstart, or @ludus/agent-sdk for the full API reference.