Documentation
¶
Overview ¶
Package agentstate provides a unified state object that combines live game state, knowledge-base enrichment, action space evaluation, and optional agent strategic context into a single object attachable to any tool or call.
Index ¶
- type ActionState
- type AgentContext
- type AgentState
- func (s *AgentState) BestSellsForCargo() []market.BestPrice
- func (s *AgentState) CanDo(action string) bool
- func (s *AgentState) Cargo() []game.CargoItem
- func (s *AgentState) CargoSpace() (used, capacity float64)
- func (s *AgentState) Constraints() []string
- func (s *AgentState) Credits() float64
- func (s *AgentState) CurrentPOI() string
- func (s *AgentState) CurrentPOIType() string
- func (s *AgentState) CurrentSystem() string
- func (s *AgentState) Docked() bool
- func (s *AgentState) Focus() string
- func (s *AgentState) Fuel() (current, max float64)
- func (s *AgentState) FuelCostTo(systemID string) (float64, bool)
- func (s *AgentState) GameState() *game.State
- func (s *AgentState) Goal() *agent.Goal
- func (s *AgentState) HasQueuedPlan() bool
- func (s *AgentState) Hull() (current, max float64)
- func (s *AgentState) InBattle() bool
- func (s *AgentState) InCombat() bool
- func (s *AgentState) MarketSnapshot() *market.MarketSnapshot
- func (s *AgentState) Nearby() []game.NearbyPlayer
- func (s *AgentState) NeighborInfo(systemID string) *EnrichedNeighbor
- func (s *AgentState) Neighbors() []EnrichedNeighbor
- func (s *AgentState) Player() game.Player
- func (s *AgentState) QueuedPlan() []agent.PlannedAction
- func (s *AgentState) Refresh(ctx context.Context)
- func (s *AgentState) ResourceDepletion() []knowledge.DepletingResource
- func (s *AgentState) SetAgentContext(ctx *AgentContext)
- func (s *AgentState) Ship() game.Ship
- func (s *AgentState) Skills() map[string]game.Skill
- func (s *AgentState) Snapshot() StateSnapshot
- func (s *AgentState) System() game.SystemData
- func (s *AgentState) SystemDanger() *knowledge.DangerZone
- func (s *AgentState) SystemSecurity() string
- func (s *AgentState) Tick() int64
- func (s *AgentState) Traveling() bool
- func (s *AgentState) ValidActions() []actionspace.ActionResult
- type EnrichedNeighbor
- type EnrichedState
- type StateSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionState ¶
type ActionState struct {
ValidActions []actionspace.ActionResult
AllActions []actionspace.ActionResult
GameContext actionspace.GameContext
}
ActionState holds the evaluated action space for the current state.
type AgentContext ¶
type AgentContext struct {
Personality *agent.Personality
Goal *agent.Goal
Priority *agent.Priority
RecentActions []agent.HistoryEntry
QueuedPlan []agent.PlannedAction
Weights *tot.AxisWeights
}
AgentContext carries agent-specific strategic data. Nil for non-agent consumers.
type AgentState ¶
type AgentState struct {
// contains filtered or unexported fields
}
AgentState is the unified state object that can be attached to any tool, strategy, or agent decision cycle. It combines live game state, KB-enriched data, and optional agent strategic context.
func NewWithAgent ¶
func NewWithAgent(state *game.State, kb knowledge.Base, mc *market.Collector, agentCtx *AgentContext) *AgentState
NewWithAgent creates an AgentState with agent strategic context attached.
func (*AgentState) BestSellsForCargo ¶
func (s *AgentState) BestSellsForCargo() []market.BestPrice
BestSellsForCargo returns the best sell opportunities for items in cargo.
func (*AgentState) CanDo ¶
func (s *AgentState) CanDo(action string) bool
CanDo returns whether a specific action is currently valid.
func (*AgentState) Cargo ¶
func (s *AgentState) Cargo() []game.CargoItem
Cargo returns a copy of the current cargo items.
func (*AgentState) CargoSpace ¶
func (s *AgentState) CargoSpace() (used, capacity float64)
CargoSpace returns cargo used and total capacity.
func (*AgentState) Constraints ¶
func (s *AgentState) Constraints() []string
Constraints returns the agent's active constraints, or nil.
func (*AgentState) Credits ¶
func (s *AgentState) Credits() float64
Credits returns the player's credit balance.
func (*AgentState) CurrentPOI ¶
func (s *AgentState) CurrentPOI() string
CurrentPOI returns the ID of the current point of interest.
func (*AgentState) CurrentPOIType ¶
func (s *AgentState) CurrentPOIType() string
CurrentPOIType returns the type of the current POI (e.g., "station", "asteroid_belt").
func (*AgentState) CurrentSystem ¶
func (s *AgentState) CurrentSystem() string
CurrentSystem returns the ID of the current system.
func (*AgentState) Docked ¶
func (s *AgentState) Docked() bool
Docked returns whether the ship is docked at a station.
func (*AgentState) Focus ¶
func (s *AgentState) Focus() string
Focus returns the agent's current strategic focus, or empty string.
func (*AgentState) Fuel ¶
func (s *AgentState) Fuel() (current, max float64)
Fuel returns current and maximum fuel.
func (*AgentState) FuelCostTo ¶
func (s *AgentState) FuelCostTo(systemID string) (float64, bool)
FuelCostTo returns the average fuel cost to reach a neighbor system.
func (*AgentState) GameState ¶
func (s *AgentState) GameState() *game.State
GameState returns the underlying live game state pointer. Use sparingly — prefer the typed accessors.
func (*AgentState) Goal ¶
func (s *AgentState) Goal() *agent.Goal
Goal returns the agent's current strategic goal, or nil.
func (*AgentState) HasQueuedPlan ¶
func (s *AgentState) HasQueuedPlan() bool
HasQueuedPlan returns whether the agent has a queued multi-step plan.
func (*AgentState) Hull ¶
func (s *AgentState) Hull() (current, max float64)
Hull returns current and maximum hull.
func (*AgentState) InBattle ¶
func (s *AgentState) InBattle() bool
InBattle returns whether the player is in a tactical battle.
func (*AgentState) InCombat ¶
func (s *AgentState) InCombat() bool
InCombat returns whether the player is in NPC/pirate combat.
func (*AgentState) MarketSnapshot ¶
func (s *AgentState) MarketSnapshot() *market.MarketSnapshot
MarketSnapshot returns the latest market snapshot at the current station.
func (*AgentState) Nearby ¶
func (s *AgentState) Nearby() []game.NearbyPlayer
Nearby returns a copy of the nearby players list.
func (*AgentState) NeighborInfo ¶
func (s *AgentState) NeighborInfo(systemID string) *EnrichedNeighbor
NeighborInfo returns enriched data for a specific neighbor system, or nil.
func (*AgentState) Neighbors ¶
func (s *AgentState) Neighbors() []EnrichedNeighbor
Neighbors returns all enriched neighbor systems.
func (*AgentState) Player ¶
func (s *AgentState) Player() game.Player
Player returns a copy of the current player data.
func (*AgentState) QueuedPlan ¶
func (s *AgentState) QueuedPlan() []agent.PlannedAction
QueuedPlan returns the agent's queued planned actions, or nil.
func (*AgentState) Refresh ¶
func (s *AgentState) Refresh(ctx context.Context)
Refresh rebuilds the enrichment and action layers from current game state + KB. Called once at the top of each agent decision cycle.
func (*AgentState) ResourceDepletion ¶
func (s *AgentState) ResourceDepletion() []knowledge.DepletingResource
ResourceDepletion returns depleting resource data at the current POI.
func (*AgentState) SetAgentContext ¶
func (s *AgentState) SetAgentContext(ctx *AgentContext)
SetAgentContext replaces the agent context (e.g., after goal/priority changes).
func (*AgentState) Ship ¶
func (s *AgentState) Ship() game.Ship
Ship returns a copy of the current ship data.
func (*AgentState) Skills ¶
func (s *AgentState) Skills() map[string]game.Skill
Skills returns a copy of the player's skill map.
func (*AgentState) Snapshot ¶
func (s *AgentState) Snapshot() StateSnapshot
Snapshot produces a flat, JSON-serializable copy of the full unified state.
func (*AgentState) System ¶
func (s *AgentState) System() game.SystemData
System returns a copy of the current system data.
func (*AgentState) SystemDanger ¶
func (s *AgentState) SystemDanger() *knowledge.DangerZone
SystemDanger returns the danger zone data for the current system, or nil.
func (*AgentState) SystemSecurity ¶
func (s *AgentState) SystemSecurity() string
SystemSecurity returns the human-readable security label for the current system.
func (*AgentState) Traveling ¶
func (s *AgentState) Traveling() bool
Traveling returns whether the ship is in transit.
func (*AgentState) ValidActions ¶
func (s *AgentState) ValidActions() []actionspace.ActionResult
ValidActions returns the actions that passed all preconditions.
type EnrichedNeighbor ¶
type EnrichedNeighbor struct {
SystemID string `json:"system_id"`
Name string `json:"name"`
Distance int `json:"distance"`
Security string `json:"security"`
Empire string `json:"empire"`
IsStronghold bool `json:"is_stronghold"`
DangerLevel int `json:"danger_level"`
StationCount int `json:"station_count"`
ResourcePOIs int `json:"resource_pois"` //nolint:revive // POIs is an acronym used as a name
AvgFuelCost float64 `json:"avg_fuel_cost"`
AvgTravelTime float64 `json:"avg_travel_time"`
}
EnrichedNeighbor combines connection data with KB system intelligence.
type EnrichedState ¶
type EnrichedState struct {
// Current system enrichment.
SystemSecurity string
SystemDanger *knowledge.DangerZone
SystemAnomalies []knowledge.Anomaly
// Neighbor systems with full KB intelligence.
Neighbors []EnrichedNeighbor
// Current POI enrichment.
CurrentPOIType string
ResourceDepletion []knowledge.DepletingResource
ResourceHistory []knowledge.ResourceHistory
// Market intel (populated only when docked).
MarketSnapshot *market.MarketSnapshot
MarketAnalysis *market.MarketAnalysis
NearbyBestBuys []market.BestPrice
NearbyBestSells []market.BestPrice
// Route intelligence: systemID → avg fuel cost.
FuelToNeighbors map[string]float64
}
EnrichedState holds KB-derived data layered on top of live game state. Rebuilt on each Refresh() call via local SQLite queries.
type StateSnapshot ¶
type StateSnapshot struct {
// Timing.
Tick int64 `json:"tick"`
Refreshed time.Time `json:"refreshed"`
// Player.
Username string `json:"username"`
Empire string `json:"empire"`
Credits float64 `json:"credits"`
// Location.
CurrentSystem string `json:"current_system"`
CurrentPOI string `json:"current_poi"`
CurrentPOIType string `json:"current_poi_type"`
Docked bool `json:"docked"`
Traveling bool `json:"traveling"`
SystemSecurity string `json:"system_security"`
// Ship.
ShipClass string `json:"ship_class"`
ShipName string `json:"ship_name"`
Fuel float64 `json:"fuel"`
MaxFuel float64 `json:"max_fuel"`
Hull float64 `json:"hull"`
MaxHull float64 `json:"max_hull"`
CargoUsed float64 `json:"cargo_used"`
CargoCapacity float64 `json:"cargo_capacity"`
Cargo []game.CargoItem `json:"cargo"`
// Combat.
InCombat bool `json:"in_combat"`
InBattle bool `json:"in_battle"`
PirateName string `json:"pirate_name,omitempty"`
PirateTier string `json:"pirate_tier,omitempty"`
// Enrichment.
Neighbors []EnrichedNeighbor `json:"neighbors"`
SystemDangerLevel int `json:"system_danger_level"`
ResourceDepletion []knowledge.DepletingResource `json:"resource_depletion,omitempty"`
FuelToNeighbors map[string]float64 `json:"fuel_to_neighbors"`
// Actions.
ValidActionCount int `json:"valid_action_count"`
ValidActionNames []string `json:"valid_action_names"`
// Agent context (omitted if no agent attached).
Goal *agent.Goal `json:"goal,omitempty"`
Focus string `json:"focus,omitempty"`
Constraints []string `json:"constraints,omitempty"`
QueuedPlan []agent.PlannedAction `json:"queued_plan,omitempty"`
RecentActions []agent.HistoryEntry `json:"recent_actions,omitempty"`
}
StateSnapshot is a fully serializable copy of the unified state. Used for prompt generation, observer broadcasts, logging, and debugging.