Documentation
¶
Overview ¶
Package ai provides AI-native infrastructure for LLM integration.
Index ¶
- func TokenEstimate(compact string) int
- type Action
- type ActionExecutor
- type ActionNode
- type ActionType
- type Anomaly
- type AnomalyDetector
- type AnomalyType
- type AssetGenerator
- func (g *AssetGenerator) ExportAssetList(assets map[string]string) string
- func (g *AssetGenerator) GenerateGameAssets(theme string) map[string]string
- func (g *AssetGenerator) GenerateSFXPrompt(spec SFXPrompt) string
- func (g *AssetGenerator) GenerateSpritePrompt(spec SpritePrompt) string
- func (g *AssetGenerator) GenerateSpriteSheet(subject string, style AssetStyle) []string
- type AssetStyle
- type BTContext
- type BehaviorTree
- type CompactExporter
- type Condition
- type DecisionFn
- type DetectionRule
- type DialogueChoice
- type DialogueNode
- type DifficultyBalancer
- func (d *DifficultyBalancer) GetDifficultyLevel() float64
- func (d *DifficultyBalancer) GetMetricAverage(name string) float64
- func (d *DifficultyBalancer) GetParameter(name string) float64
- func (d *DifficultyBalancer) RecordMetric(name string, value float64)
- func (d *DifficultyBalancer) RegisterMetric(name string, target, tolerance float64, maxSamples int)
- func (d *DifficultyBalancer) RegisterParameter(name string, defaultVal, minVal, maxVal float64, inverted bool)
- func (d *DifficultyBalancer) Reset()
- func (d *DifficultyBalancer) SetAdjustmentRate(rate float64)
- func (d *DifficultyBalancer) SetDifficultyLevel(level float64)
- func (d *DifficultyBalancer) Update()
- type EntitySnapshot
- type EntitySpec
- type FailNode
- type GameAdapter
- type GameState
- type Inverter
- type LoreDatabase
- func (db *LoreDatabase) AddEntry(entry LoreEntry)
- func (db *LoreDatabase) Count() int
- func (db *LoreDatabase) ExportMarkdown() string
- func (db *LoreDatabase) GenerateContextPrompt(query, additionalContext string) string
- func (db *LoreDatabase) GetAllEntries() []*LoreEntry
- func (db *LoreDatabase) GetEntry(id string) *LoreEntry
- func (db *LoreDatabase) Query(query string, limit int) []*LoreEntry
- func (db *LoreDatabase) QueryByCategory(category string) []*LoreEntry
- func (db *LoreDatabase) QueryByTag(tag string) []*LoreEntry
- type LoreEntry
- type MetricTracker
- type MoveAction
- type NarrativeController
- func (n *NarrativeController) AddDialogue(node DialogueNode)
- func (n *NarrativeController) AddQuest(quest Quest)
- func (n *NarrativeController) GenerateDialoguePrompt(character, context string) string
- func (n *NarrativeController) GenerateQuestPrompt(theme, difficulty string) string
- func (n *NarrativeController) GetActiveQuests() []*Quest
- func (n *NarrativeController) GetAvailableChoices() []DialogueChoice
- func (n *NarrativeController) GetCurrentDialogue() *DialogueNode
- func (n *NarrativeController) GetVariable(key string) any
- func (n *NarrativeController) OnDialogueChange(callback func(node *DialogueNode))
- func (n *NarrativeController) SelectChoice(choiceIndex int) *DialogueNode
- func (n *NarrativeController) SetVariable(key string, value any)
- func (n *NarrativeController) StartDialogue(id string) *DialogueNode
- func (n *NarrativeController) StartQuest(id string)
- func (n *NarrativeController) UpdateObjective(questID string, objectiveIndex, progress int)
- type Node
- type NodeStatus
- type Observation
- type Observer
- func (o *Observer) Clear()
- func (o *Observer) GetPositionHistory() [][2]float64
- func (o *Observer) GetScoreHistory() []int
- func (o *Observer) GetStateChanges() []Observation
- func (o *Observer) History() []Observation
- func (o *Observer) LastN(n int) []Observation
- func (o *Observer) Record(tick int64, state GameState, action ActionType) Observation
- func (o *Observer) Stats() ObserverStats
- type ObserverStats
- type Parameter
- type Player
- type QAAgent
- func (a *QAAgent) ClearLog()
- func (a *QAAgent) ExportLog() string
- func (a *QAAgent) ExportLogCompact() string
- func (a *QAAgent) Log() []QAEntry
- func (a *QAAgent) Run(steps int, decisionFn DecisionFn) []QAEntry
- func (a *QAAgent) RunUntil(cond func(*ecs.World) bool, maxSteps int, decisionFn DecisionFn) []QAEntry
- func (a *QAAgent) Step(decisionFn DecisionFn) QAEntry
- type QAEntry
- type QAMetrics
- type QAReport
- type QASession
- type Quest
- type QuestObjective
- type QuestStatus
- type RandomPlayer
- type RemoveEntityAction
- type Repeater
- type ReplayPlayer
- type RunResult
- type SFXPrompt
- type SceneGenerator
- type SceneSpec
- type Selector
- type Sequence
- type SessionConfig
- type SetPositionAction
- type SetStateAction
- type SetVelocityAction
- type Severity
- type SpritePrompt
- type StateExporter
- type StrategyPlayer
- type SucceedNode
- type WeightedRandomPlayer
- type WorldSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TokenEstimate ¶
TokenEstimate estimates token count for a compact string. Assumes ~4 chars per token on average.
Types ¶
type Action ¶
type Action interface {
// Execute performs the action on the world.
Execute(world *ecs.World) error
// Name returns a human-readable action name.
Name() string
}
Action represents a game action that can be executed by an AI agent.
type ActionExecutor ¶
type ActionExecutor struct {
// contains filtered or unexported fields
}
ActionExecutor handles execution of AI actions.
func NewActionExecutor ¶
func NewActionExecutor(world *ecs.World) *ActionExecutor
NewActionExecutor creates an action executor for the given world.
func (*ActionExecutor) Execute ¶
func (e *ActionExecutor) Execute(action Action) error
Execute runs a single action.
func (*ActionExecutor) ExecuteBatch ¶
func (e *ActionExecutor) ExecuteBatch(actions []Action) []error
ExecuteBatch runs multiple actions, returning any errors.
type ActionNode ¶
type ActionNode struct {
Do func(ctx *BTContext) NodeStatus
}
ActionNode executes a function.
func NewActionNode ¶
func NewActionNode(do func(ctx *BTContext) NodeStatus) *ActionNode
NewActionNode creates an action node.
func (*ActionNode) Tick ¶
func (n *ActionNode) Tick(ctx *BTContext) NodeStatus
type ActionType ¶
type ActionType string
ActionType represents a game action that can be performed.
const ( ActionNone ActionType = "none" ActionMoveUp ActionType = "move_up" ActionMoveDown ActionType = "move_down" ActionMoveLeft ActionType = "move_left" ActionMoveRight ActionType = "move_right" ActionJump ActionType = "jump" ActionAttack ActionType = "attack" ActionUse ActionType = "use" ActionPause ActionType = "pause" )
Common action types (games can define more).
type Anomaly ¶
type Anomaly struct {
Type AnomalyType `json:"type"`
Severity Severity `json:"severity"`
Tick int64 `json:"tick"`
Description string `json:"description"`
Evidence []Observation `json:"evidence,omitempty"`
}
Anomaly represents a detected issue during QA testing.
type AnomalyDetector ¶
type AnomalyDetector struct {
// Configurable thresholds
StuckThreshold int // Ticks without movement to trigger stuck
EntityLeakThreshold int // Max entities before leak warning
DeathLoopRadius float64 // Distance to consider same death location
HealthDrainRate float64 // Health lost per tick to trigger warning
BoundsWidth float64 // Game world width
BoundsHeight float64 // Game world height
// contains filtered or unexported fields
}
AnomalyDetector analyzes observation history to find bugs.
func NewAnomalyDetector ¶
func NewAnomalyDetector() *AnomalyDetector
NewAnomalyDetector creates a detector with default thresholds.
func (*AnomalyDetector) AddRule ¶
func (d *AnomalyDetector) AddRule(rule DetectionRule)
AddRule adds a custom detection rule.
func (*AnomalyDetector) Analyze ¶
func (d *AnomalyDetector) Analyze(history []Observation) []Anomaly
Analyze runs all detection rules on the observation history.
func (*AnomalyDetector) GenerateReport ¶
func (d *AnomalyDetector) GenerateReport() string
GenerateReport creates a markdown report of anomalies.
func (*AnomalyDetector) GetAnomalies ¶
func (d *AnomalyDetector) GetAnomalies() []Anomaly
GetAnomalies returns all detected anomalies.
type AnomalyType ¶
type AnomalyType string
AnomalyType categorizes detected issues.
const ( AnomalyStuck AnomalyType = "stuck" // Player not moving AnomalyDeathLoop AnomalyType = "death_loop" // Repeated deaths at same location AnomalyEntityLeak AnomalyType = "entity_leak" // Entity count growing unbounded AnomalyStateOscillation AnomalyType = "state_oscillation" // Rapid state changes AnomalyScoreRegression AnomalyType = "score_regression" // Score decreased AnomalyHealthDrain AnomalyType = "health_drain" // Rapid health loss AnomalyInfiniteLoop AnomalyType = "infinite_loop" // Same state repeating AnomalyBoundaryViolation AnomalyType = "boundary_violation" // Entity out of bounds )
type AssetGenerator ¶
type AssetGenerator struct {
// contains filtered or unexported fields
}
AssetGenerator generates prompts for AI image/audio generation.
func NewAssetGenerator ¶
func NewAssetGenerator(style AssetStyle) *AssetGenerator
NewAssetGenerator creates a new asset generator.
func (*AssetGenerator) ExportAssetList ¶
func (g *AssetGenerator) ExportAssetList(assets map[string]string) string
ExportAssetList generates a markdown list of asset prompts.
func (*AssetGenerator) GenerateGameAssets ¶
func (g *AssetGenerator) GenerateGameAssets(theme string) map[string]string
GenerateGameAssets generates prompts for common game assets.
func (*AssetGenerator) GenerateSFXPrompt ¶
func (g *AssetGenerator) GenerateSFXPrompt(spec SFXPrompt) string
GenerateSFXPrompt creates a prompt for ElevenLabs/audio AI.
func (*AssetGenerator) GenerateSpritePrompt ¶
func (g *AssetGenerator) GenerateSpritePrompt(spec SpritePrompt) string
GenerateSpritePrompt creates a prompt for DALL-E/Stable Diffusion.
func (*AssetGenerator) GenerateSpriteSheet ¶
func (g *AssetGenerator) GenerateSpriteSheet(subject string, style AssetStyle) []string
GenerateSpriteSheet generates prompts for a full animation sprite sheet.
type AssetStyle ¶
type AssetStyle string
AssetStyle defines the visual style for generated assets.
const ( StylePixelArt AssetStyle = "pixel-art" StyleCartoon AssetStyle = "cartoon" StyleRealistic AssetStyle = "realistic" StyleAnime AssetStyle = "anime" StyleLowPoly AssetStyle = "low-poly" )
type BTContext ¶
type BTContext struct {
World *ecs.World
Entity ecs.Entity
Data map[string]any // Blackboard for sharing data
}
BTContext provides context for behavior tree execution.
type BehaviorTree ¶
type BehaviorTree struct {
Root Node
}
BehaviorTree wraps a root node for execution.
func NewBehaviorTree ¶
func NewBehaviorTree(root Node) *BehaviorTree
NewBehaviorTree creates a behavior tree with the given root.
func (*BehaviorTree) Tick ¶
func (bt *BehaviorTree) Tick(ctx *BTContext) NodeStatus
Tick runs one tick of the behavior tree.
type CompactExporter ¶
type CompactExporter struct {
// contains filtered or unexported fields
}
CompactExporter exports world state in minimal-token format for LLMs. Format: "T{tick}|{entities}" Entity format: "{type}:{x},{y}[;{extras}]" Type codes: P=player, E=enemy, I=item, X=projectile, U=ui, F=effect.
func NewCompactExporter ¶
func NewCompactExporter(world *ecs.World) *CompactExporter
NewCompactExporter creates a compact exporter.
func (*CompactExporter) Export ¶
func (e *CompactExporter) Export(world *ecs.World, tick int64) string
Export returns compact state string. Format: "T42|P:100,200|E:50,75;H:80/100|I:30,40".
func (*CompactExporter) ExportDelta ¶
func (e *CompactExporter) ExportDelta( world *ecs.World, tick int64, changedEntities map[ecs.Entity]bool, ) string
ExportDelta returns only entities that changed since last tick. changedEntities is a set of entity IDs that have changes.
type Condition ¶
Condition checks a predicate.
func NewCondition ¶
NewCondition creates a condition node.
func (*Condition) Tick ¶
func (n *Condition) Tick(ctx *BTContext) NodeStatus
type DecisionFn ¶
DecisionFn is a function that decides what action to take based on state.
type DetectionRule ¶
type DetectionRule func(history []Observation) []Anomaly
DetectionRule is a function that checks for anomalies.
type DialogueChoice ¶
type DialogueChoice struct {
Text string
NextID string
Condition func() bool // Optional condition to show this choice
OnSelect func() // Callback when selected
}
DialogueChoice represents a player choice.
type DialogueNode ¶
type DialogueNode struct {
ID string
Speaker string
Text string
Choices []DialogueChoice
Condition func() bool // Optional condition to show this node
OnEnter func() // Callback when entering this node
}
DialogueNode represents a node in a dialogue tree.
type DifficultyBalancer ¶
type DifficultyBalancer struct {
// contains filtered or unexported fields
}
DifficultyBalancer tracks player performance and adjusts game parameters.
func NewDifficultyBalancer ¶
func NewDifficultyBalancer() *DifficultyBalancer
NewDifficultyBalancer creates a new difficulty balancer.
func (*DifficultyBalancer) GetDifficultyLevel ¶
func (d *DifficultyBalancer) GetDifficultyLevel() float64
GetDifficultyLevel returns the current difficulty multiplier.
func (*DifficultyBalancer) GetMetricAverage ¶
func (d *DifficultyBalancer) GetMetricAverage(name string) float64
GetMetricAverage returns the rolling average of a metric.
func (*DifficultyBalancer) GetParameter ¶
func (d *DifficultyBalancer) GetParameter(name string) float64
GetParameter returns the current value of a parameter.
func (*DifficultyBalancer) RecordMetric ¶
func (d *DifficultyBalancer) RecordMetric(name string, value float64)
RecordMetric records a metric value.
func (*DifficultyBalancer) RegisterMetric ¶
func (d *DifficultyBalancer) RegisterMetric(name string, target, tolerance float64, maxSamples int)
RegisterMetric registers a metric to track.
func (*DifficultyBalancer) RegisterParameter ¶
func (d *DifficultyBalancer) RegisterParameter( name string, defaultVal, minVal, maxVal float64, inverted bool, )
RegisterParameter registers an adjustable parameter.
func (*DifficultyBalancer) Reset ¶
func (d *DifficultyBalancer) Reset()
Reset resets all metrics and parameters to defaults.
func (*DifficultyBalancer) SetAdjustmentRate ¶
func (d *DifficultyBalancer) SetAdjustmentRate(rate float64)
SetAdjustmentRate sets how quickly difficulty adjusts.
func (*DifficultyBalancer) SetDifficultyLevel ¶
func (d *DifficultyBalancer) SetDifficultyLevel(level float64)
SetDifficultyLevel manually sets the difficulty level.
func (*DifficultyBalancer) Update ¶
func (d *DifficultyBalancer) Update()
Update adjusts difficulty based on tracked metrics.
type EntitySnapshot ¶
type EntitySnapshot struct {
ID uint32 `json:"id"`
EntityType string `json:"type"`
Description string `json:"description,omitempty"`
Position *[2]float64 `json:"position,omitempty"`
Velocity *[2]float64 `json:"velocity,omitempty"`
State string `json:"state,omitempty"`
Tags []string `json:"tags,omitempty"`
Effects []string `json:"effects,omitempty"`
Health *[2]int `json:"health,omitempty"` // [current, max]
}
EntitySnapshot represents a serialized entity with its key components.
type EntitySpec ¶
type EntitySpec struct {
Name string
Type string // "sprite", "player", "enemy", "collectible"
Position [2]float64
Sprite string
Properties map[string]string
}
EntitySpec describes an entity to generate.
type FailNode ¶
type FailNode struct{}
FailNode always returns Failure.
func (*FailNode) Tick ¶
func (n *FailNode) Tick(ctx *BTContext) NodeStatus
type GameAdapter ¶
type GameAdapter interface {
// Name returns the game's identifier.
Name() string
// GetState returns the current game state as an observable snapshot.
GetState() GameState
// IsGameOver returns true if the current run has ended.
IsGameOver() bool
// GetScore returns the current score (or relevant metric).
GetScore() int
// AvailableActions returns the list of valid actions in current state.
AvailableActions() []ActionType
// PerformAction executes the given action.
PerformAction(action ActionType) error
// Step advances the game by one tick/frame.
Step() error
// Reset restarts the game to initial state.
Reset() error
}
GameAdapter is a universal interface for any game to be QA-tested. Implement this interface to enable automated testing for your game.
type GameState ¶
type GameState struct {
Tick int64 `json:"tick"`
Score int `json:"score"`
PlayerPos [2]float64 `json:"player_pos"`
PlayerHealth [2]int `json:"player_health"` // [current, max]
EntityCount int `json:"entity_count"`
CustomData map[string]any `json:"custom,omitempty"`
}
GameState contains observable game state for AI analysis.
type Inverter ¶
type Inverter struct {
Child Node
}
Inverter inverts the result of its child.
func (*Inverter) Tick ¶
func (n *Inverter) Tick(ctx *BTContext) NodeStatus
type LoreDatabase ¶
type LoreDatabase struct {
// contains filtered or unexported fields
}
LoreDatabase is a simple RAG-style lore database.
func NewLoreDatabase ¶
func NewLoreDatabase() *LoreDatabase
NewLoreDatabase creates a new lore database.
func (*LoreDatabase) AddEntry ¶
func (db *LoreDatabase) AddEntry(entry LoreEntry)
AddEntry adds a lore entry to the database.
func (*LoreDatabase) Count ¶
func (db *LoreDatabase) Count() int
Count returns the number of entries.
func (*LoreDatabase) ExportMarkdown ¶
func (db *LoreDatabase) ExportMarkdown() string
ExportMarkdown exports all lore as a markdown document.
func (*LoreDatabase) GenerateContextPrompt ¶
func (db *LoreDatabase) GenerateContextPrompt(query, additionalContext string) string
GenerateContextPrompt creates a prompt with relevant lore for LLM.
func (*LoreDatabase) GetAllEntries ¶
func (db *LoreDatabase) GetAllEntries() []*LoreEntry
GetAllEntries returns all entries.
func (*LoreDatabase) GetEntry ¶
func (db *LoreDatabase) GetEntry(id string) *LoreEntry
GetEntry returns a specific entry by ID.
func (*LoreDatabase) Query ¶
func (db *LoreDatabase) Query(query string, limit int) []*LoreEntry
Query searches for relevant lore entries.
func (*LoreDatabase) QueryByCategory ¶
func (db *LoreDatabase) QueryByCategory(category string) []*LoreEntry
QueryByCategory returns all entries in a category.
func (*LoreDatabase) QueryByTag ¶
func (db *LoreDatabase) QueryByTag(tag string) []*LoreEntry
QueryByTag returns all entries with a specific tag.
type LoreEntry ¶
type LoreEntry struct {
ID string
Title string
Content string
Category string // "character", "location", "event", "item"
Tags []string
Embedding []float32 // Optional: pre-computed embedding for similarity search
Relevance float32 // Computed similarity score
}
LoreEntry represents a piece of game lore.
type MetricTracker ¶
type MetricTracker struct {
// contains filtered or unexported fields
}
MetricTracker tracks a rolling average of a metric.
type MoveAction ¶
MoveAction moves an entity by a delta.
func (MoveAction) Name ¶
func (a MoveAction) Name() string
type NarrativeController ¶
type NarrativeController struct {
// contains filtered or unexported fields
}
NarrativeController manages dynamic storytelling and dialogue.
func NewNarrativeController ¶
func NewNarrativeController() *NarrativeController
NewNarrativeController creates a new narrative controller.
func (*NarrativeController) AddDialogue ¶
func (n *NarrativeController) AddDialogue(node DialogueNode)
AddDialogue adds a dialogue node.
func (*NarrativeController) AddQuest ¶
func (n *NarrativeController) AddQuest(quest Quest)
AddQuest adds a quest.
func (*NarrativeController) GenerateDialoguePrompt ¶
func (n *NarrativeController) GenerateDialoguePrompt(character, context string) string
GenerateDialoguePrompt creates a prompt for LLM dialogue generation.
func (*NarrativeController) GenerateQuestPrompt ¶
func (n *NarrativeController) GenerateQuestPrompt(theme, difficulty string) string
GenerateQuestPrompt creates a prompt for LLM quest generation.
func (*NarrativeController) GetActiveQuests ¶
func (n *NarrativeController) GetActiveQuests() []*Quest
GetActiveQuests returns all active quests.
func (*NarrativeController) GetAvailableChoices ¶
func (n *NarrativeController) GetAvailableChoices() []DialogueChoice
GetAvailableChoices returns choices that pass their conditions.
func (*NarrativeController) GetCurrentDialogue ¶
func (n *NarrativeController) GetCurrentDialogue() *DialogueNode
GetCurrentDialogue returns the current dialogue node.
func (*NarrativeController) GetVariable ¶
func (n *NarrativeController) GetVariable(key string) any
GetVariable gets a narrative variable.
func (*NarrativeController) OnDialogueChange ¶
func (n *NarrativeController) OnDialogueChange(callback func(node *DialogueNode))
OnDialogueChange sets a callback for dialogue changes.
func (*NarrativeController) SelectChoice ¶
func (n *NarrativeController) SelectChoice(choiceIndex int) *DialogueNode
SelectChoice selects a dialogue choice.
func (*NarrativeController) SetVariable ¶
func (n *NarrativeController) SetVariable(key string, value any)
SetVariable sets a narrative variable.
func (*NarrativeController) StartDialogue ¶
func (n *NarrativeController) StartDialogue(id string) *DialogueNode
StartDialogue begins a dialogue sequence.
func (*NarrativeController) StartQuest ¶
func (n *NarrativeController) StartQuest(id string)
StartQuest activates a quest.
func (*NarrativeController) UpdateObjective ¶
func (n *NarrativeController) UpdateObjective(questID string, objectiveIndex, progress int)
UpdateObjective updates a quest objective progress.
type Node ¶
type Node interface {
Tick(ctx *BTContext) NodeStatus
}
Node is the interface for all behavior tree nodes.
type NodeStatus ¶
type NodeStatus int
NodeStatus represents the result of a behavior tree node tick.
const ( // Running means the node is still executing. Running NodeStatus = iota // Success means the node completed successfully. Success // Failure means the node failed. Failure )
type Observation ¶
type Observation struct {
Tick int64 `json:"tick"`
Timestamp time.Time `json:"timestamp"`
State GameState `json:"state"`
Action ActionType `json:"action"`
Metrics QAMetrics `json:"metrics"`
}
Observation represents a single frame of game state during QA testing.
type Observer ¶
type Observer struct {
// Callbacks
OnObservation func(obs Observation)
OnAnomalyFound func(anomaly Anomaly)
// contains filtered or unexported fields
}
Observer records game state history for anomaly detection.
func NewObserver ¶
NewObserver creates an observer with the given history limit.
func (*Observer) GetPositionHistory ¶
GetPositionHistory returns player positions over time.
func (*Observer) GetScoreHistory ¶
GetScoreHistory returns score progression over time.
func (*Observer) GetStateChanges ¶
func (o *Observer) GetStateChanges() []Observation
GetStateChanges returns observations where state changed significantly.
func (*Observer) History ¶
func (o *Observer) History() []Observation
History returns all recorded observations.
func (*Observer) LastN ¶
func (o *Observer) LastN(n int) []Observation
LastN returns the most recent N observations.
func (*Observer) Record ¶
func (o *Observer) Record(tick int64, state GameState, action ActionType) Observation
Record adds an observation to history.
func (*Observer) Stats ¶
func (o *Observer) Stats() ObserverStats
Stats returns summary statistics of observations.
type ObserverStats ¶
type ObserverStats struct {
TotalTicks int64
Observations int
MaxScore int
MinHealth int
MaxEntities int
FinalScore int
}
ObserverStats contains summary statistics.
type Parameter ¶
type Parameter struct {
Value float64
Min float64
Max float64
Default float64
Inverted bool // If true, lower is harder
}
Parameter represents an adjustable game parameter.
type Player ¶
type Player interface {
// DecideAction chooses an action based on current state.
DecideAction(state GameState, available []ActionType) ActionType
}
Player is an interface for AI players that decide actions.
type QAAgent ¶
type QAAgent struct {
// contains filtered or unexported fields
}
QAAgent is an automated game tester that logs state and actions.
func NewQAAgent ¶
func NewQAAgent(game *engine.HeadlessGame) *QAAgent
NewQAAgent creates a QA agent for the given headless game.
func (*QAAgent) ExportLogCompact ¶
ExportLogCompact exports the log as a compact string for LLM analysis.
func (*QAAgent) Run ¶
func (a *QAAgent) Run(steps int, decisionFn DecisionFn) []QAEntry
Run executes multiple steps with the decision function.
func (*QAAgent) RunUntil ¶
func (a *QAAgent) RunUntil(cond func(*ecs.World) bool, maxSteps int, decisionFn DecisionFn) []QAEntry
RunUntil runs until condition is met or max steps reached.
func (*QAAgent) Step ¶
func (a *QAAgent) Step(decisionFn DecisionFn) QAEntry
Step runs one game tick with a decision function.
type QAEntry ¶
type QAEntry struct {
Tick int64
State string // Compact state before action
Action string // Action taken
Result string // Outcome description
Timestamp time.Time
}
QAEntry represents a single step in the QA log.
type QAMetrics ¶
type QAMetrics struct {
EntityCount int `json:"entity_count"`
FPS float64 `json:"fps,omitempty"`
MemoryMB float64 `json:"memory_mb,omitempty"`
UpdateTimeMs float64 `json:"update_time_ms,omitempty"`
}
QAMetrics contains performance and health metrics.
type QAReport ¶
type QAReport struct {
GameName string `json:"game_name"`
SessionTime time.Time `json:"session_time"`
Config SessionConfig `json:"config"`
Runs []RunResult `json:"runs"`
// Aggregated
TotalAnomalies int `json:"total_anomalies"`
BestScore int `json:"best_score"`
WorstScore int `json:"worst_score"`
AvgScore int `json:"avg_score"`
Conclusion string `json:"conclusion"`
}
QAReport is the final report from a QA session.
func (*QAReport) GenerateMarkdown ¶
GenerateMarkdown creates a markdown report.
type QASession ¶
type QASession struct {
// contains filtered or unexported fields
}
QASession orchestrates automated QA testing.
func NewQASession ¶
func NewQASession(adapter GameAdapter) *QASession
NewQASession creates a QA session for the given game.
func (*QASession) SetConfig ¶
func (s *QASession) SetConfig(config SessionConfig)
SetConfig sets the session configuration.
func (*QASession) SetDetector ¶
func (s *QASession) SetDetector(detector *AnomalyDetector)
SetDetector replaces the anomaly detector.
type Quest ¶
type Quest struct {
ID string
Title string
Description string
Objectives []QuestObjective
Status QuestStatus
Rewards []string
OnComplete func()
}
Quest represents a game quest.
type QuestObjective ¶
QuestObjective is a single objective within a quest.
type QuestStatus ¶
type QuestStatus int
QuestStatus represents quest state.
const ( QuestNotStarted QuestStatus = iota QuestActive QuestCompleted QuestFailed )
type RandomPlayer ¶
type RandomPlayer struct {
// contains filtered or unexported fields
}
RandomPlayer selects actions randomly for fuzz testing.
func NewRandomPlayer ¶
func NewRandomPlayer(seed int64) *RandomPlayer
NewRandomPlayer creates a player that picks random actions.
func (*RandomPlayer) DecideAction ¶
func (p *RandomPlayer) DecideAction(state GameState, available []ActionType) ActionType
DecideAction picks a random action from available actions.
type RemoveEntityAction ¶
RemoveEntityAction removes an entity from the world.
func (RemoveEntityAction) Name ¶
func (a RemoveEntityAction) Name() string
type Repeater ¶
Repeater repeats its child a set number of times.
func NewRepeater ¶
NewRepeater creates a repeater node.
func (*Repeater) Tick ¶
func (n *Repeater) Tick(ctx *BTContext) NodeStatus
type ReplayPlayer ¶
type ReplayPlayer struct {
// contains filtered or unexported fields
}
ReplayPlayer replays a recorded action sequence.
func NewReplayPlayer ¶
func NewReplayPlayer(actions []ActionType) *ReplayPlayer
NewReplayPlayer creates a player that replays actions.
func (*ReplayPlayer) DecideAction ¶
func (p *ReplayPlayer) DecideAction(state GameState, available []ActionType) ActionType
DecideAction returns the next action in the sequence.
func (*ReplayPlayer) Reset ¶
func (p *ReplayPlayer) Reset()
Reset restarts the replay from beginning.
type RunResult ¶
type RunResult struct {
RunIndex int `json:"run_index"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
TotalTicks int64 `json:"total_ticks"`
FinalScore int `json:"final_score"`
GameOver bool `json:"game_over"`
Anomalies []Anomaly `json:"anomalies"`
Stats ObserverStats `json:"stats"`
}
RunResult contains the result of a single game run.
type SFXPrompt ¶
type SFXPrompt struct {
Description string // What the sound is (e.g., "coin pickup")
Duration float64 // Length in seconds
Intensity string // quiet, normal, loud
Category string // ui, ambient, action, music
}
SFXPrompt describes a sound effect to generate.
type SceneGenerator ¶
type SceneGenerator struct {
// contains filtered or unexported fields
}
SceneGenerator generates game code from specifications.
func NewSceneGenerator ¶
func NewSceneGenerator() *SceneGenerator
NewSceneGenerator creates a new scene generator.
func (*SceneGenerator) ExportMarkdown ¶
func (g *SceneGenerator) ExportMarkdown(spec SceneSpec) string
ExportMarkdown generates a markdown description of a scene.
func (*SceneGenerator) GenerateCode ¶
func (g *SceneGenerator) GenerateCode(spec SceneSpec) string
GenerateCode generates Go code from a SceneSpec.
func (*SceneGenerator) GenerateFromPrompt ¶
func (g *SceneGenerator) GenerateFromPrompt(prompt string) string
GenerateFromPrompt generates code directly from a prompt.
func (*SceneGenerator) ParsePrompt ¶
func (g *SceneGenerator) ParsePrompt(prompt string) SceneSpec
ParsePrompt extracts a SceneSpec from natural language. This is a simplified parser - in production, use an LLM.
type SceneSpec ¶
type SceneSpec struct {
Name string
Width int
Height int
Background string
Entities []EntitySpec
Description string
}
SceneSpec describes a scene to generate.
type Selector ¶
type Selector struct {
Children []Node
// contains filtered or unexported fields
}
Selector runs children until one succeeds. Returns Success if any succeeds, Failure if all fail.
func NewSelector ¶
NewSelector creates a selector node.
func (*Selector) Tick ¶
func (n *Selector) Tick(ctx *BTContext) NodeStatus
type Sequence ¶
type Sequence struct {
Children []Node
// contains filtered or unexported fields
}
Sequence runs children in order until one fails. Returns Success if all succeed, Failure if any fails.
func NewSequence ¶
NewSequence creates a sequence node.
func (*Sequence) Tick ¶
func (n *Sequence) Tick(ctx *BTContext) NodeStatus
type SessionConfig ¶
type SessionConfig struct {
Runs int // Number of game runs to perform
MaxTicks int // Maximum ticks per run
RecordEvery int // Record observation every N ticks (0 = every tick)
StopOnAnomaly bool // Stop run when anomaly detected
}
SessionConfig configures a QA testing session.
func DefaultSessionConfig ¶
func DefaultSessionConfig() SessionConfig
DefaultSessionConfig returns sensible defaults.
type SetPositionAction ¶
SetPositionAction sets an entity's absolute position.
func (SetPositionAction) Name ¶
func (a SetPositionAction) Name() string
type SetStateAction ¶
SetStateAction updates an entity's AIMetadata visual state.
func (SetStateAction) Name ¶
func (a SetStateAction) Name() string
type SetVelocityAction ¶
SetVelocityAction sets an entity's velocity.
func (SetVelocityAction) Name ¶
func (a SetVelocityAction) Name() string
type SpritePrompt ¶
type SpritePrompt struct {
Subject string // What to draw (e.g., "warrior", "tree")
Style AssetStyle // Visual style
Animation string // Animation state (idle, walk, attack)
Direction string // Facing direction (front, side, back)
Size string // Sprite size (16x16, 32x32, 64x64)
Variations int // Number of variations to generate
Transparent bool // Use transparent background
}
SpritePrompt describes a sprite to generate.
type StateExporter ¶
type StateExporter struct {
// contains filtered or unexported fields
}
StateExporter exports ECS world state for LLM consumption.
func NewStateExporter ¶
func NewStateExporter(world *ecs.World) *StateExporter
NewStateExporter creates a new state exporter for the given world.
func (*StateExporter) ExportJSON ¶
func (e *StateExporter) ExportJSON(world *ecs.World, tick int64) string
ExportJSON returns the world state as JSON string.
func (*StateExporter) ExportMarkdown ¶
func (e *StateExporter) ExportMarkdown(world *ecs.World, tick int64) string
ExportMarkdown returns the world state as Markdown string.
func (*StateExporter) ExportWorld ¶
func (e *StateExporter) ExportWorld(world *ecs.World, tick int64) WorldSnapshot
ExportWorld creates a snapshot of the current world state.
type StrategyPlayer ¶
type StrategyPlayer struct {
// contains filtered or unexported fields
}
StrategyPlayer uses a behavior tree for decision making.
func NewStrategyPlayer ¶
func NewStrategyPlayer(tree *BehaviorTree) *StrategyPlayer
NewStrategyPlayer creates a player with a behavior tree strategy.
func (*StrategyPlayer) DecideAction ¶
func (p *StrategyPlayer) DecideAction(state GameState, available []ActionType) ActionType
DecideAction runs the behavior tree to pick an action.
type SucceedNode ¶
type SucceedNode struct{}
SucceedNode always returns Success.
func (*SucceedNode) Tick ¶
func (n *SucceedNode) Tick(ctx *BTContext) NodeStatus
type WeightedRandomPlayer ¶
type WeightedRandomPlayer struct {
// contains filtered or unexported fields
}
WeightedRandomPlayer selects actions with weighted probabilities.
func NewWeightedRandomPlayer ¶
func NewWeightedRandomPlayer(seed int64, weights map[ActionType]float64) *WeightedRandomPlayer
NewWeightedRandomPlayer creates a player with action weights.
func (*WeightedRandomPlayer) DecideAction ¶
func (p *WeightedRandomPlayer) DecideAction(state GameState, available []ActionType) ActionType
DecideAction picks an action based on weights.
type WorldSnapshot ¶
type WorldSnapshot struct {
Tick int64 `json:"tick"`
Entities []EntitySnapshot `json:"entities"`
Summary string `json:"summary,omitempty"`
}
WorldSnapshot represents a serializable snapshot of the world state.