actionspace

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package actionspace evaluates game state to produce a pruned set of valid mutation commands with targets, precondition metadata, and branching factor metrics. Used by the ToT decision pipeline and a standalone graph visualizer.

Index

Constants

This section is empty.

Variables

View Source
var (
	RequiresDocked = Precondition{
		Name:        "requires_docked",
		Description: "Ship must be docked at a station",
		Check:       func(gc *GameContext) bool { return gc.Docked },
	}
	RequiresUndocked = Precondition{
		Name:        "requires_undocked",
		Description: "Ship must be undocked in space",
		Check:       func(gc *GameContext) bool { return !gc.Docked && !gc.InTransit },
	}
	RequiresNotInTransit = Precondition{
		Name:        "requires_not_in_transit",
		Description: "Ship must not be traveling",
		Check:       func(gc *GameContext) bool { return !gc.InTransit },
	}
)

Docking state preconditions.

View Source
var (
	RequiresFuel = Precondition{
		Name:        "requires_fuel",
		Description: "Ship needs fuel",
		Check:       func(gc *GameContext) bool { return gc.Fuel > 0 },
	}
	RequiresCargoSpace = Precondition{
		Name:        "requires_cargo_space",
		Description: "Cargo hold has room",
		Check:       func(gc *GameContext) bool { return gc.CargoUsed < gc.CargoCapacity },
	}
	RequiresCredits = Precondition{
		Name:        "requires_credits",
		Description: "Must have credits",
		Check:       func(gc *GameContext) bool { return gc.Credits > 0 },
	}
	RequiresDamaged = Precondition{
		Name:        "requires_damaged",
		Description: "Hull is below maximum",
		Check:       func(gc *GameContext) bool { return gc.Hull < gc.MaxHull },
	}
	RequiresNotFullFuel = Precondition{
		Name:        "requires_not_full_fuel",
		Description: "Fuel tank is not full",
		Check:       func(gc *GameContext) bool { return gc.Fuel < gc.MaxFuel },
	}
	RequiresHasCargo = Precondition{
		Name:        "requires_has_cargo",
		Description: "Must have items in cargo",
		Check:       func(gc *GameContext) bool { return gc.CargoItemCount > 0 },
	}
)

Resource preconditions.

View Source
var (
	RequiresInCombat = Precondition{
		Name:        "requires_in_combat",
		Description: "Must be in combat",
		Check:       func(gc *GameContext) bool { return gc.InCombat || gc.InBattle },
	}
	RequiresNotInCombat = Precondition{
		Name:        "requires_not_in_combat",
		Description: "Must not be in combat",
		Check:       func(gc *GameContext) bool { return !gc.InCombat && !gc.InBattle },
	}
)

Combat preconditions.

View Source
var (
	RequiresMiningPOI = Precondition{
		Name:        "requires_mining_poi",
		Description: "Must be at a mineable location (asteroid belt, ice field, or gas cloud)",
		Check: func(gc *GameContext) bool {
			switch gc.CurrentPOIType {
			case "asteroid_belt", "asteroid_field", "asteroid", "ice_field", "gas_cloud":
				return true
			default:
				return false
			}
		},
	}
	RequiresHasConnections = Precondition{
		Name:        "requires_has_connections",
		Description: "System must have jump connections",
		Check:       func(gc *GameContext) bool { return len(gc.Connections) > 0 },
	}
	RequiresHasPOIs = Precondition{
		Name:        "requires_has_pois",
		Description: "System must have other POIs to travel to",
		Check:       func(gc *GameContext) bool { return len(gc.SystemPOIs) > 1 },
	}
)

Location preconditions.

View Source
var (
	RequiresFaction = Precondition{
		Name:        "requires_faction",
		Description: "Must be in a faction",
		Check:       func(gc *GameContext) bool { return gc.HasFaction },
	}
	RequiresNearbyPlayers = Precondition{
		Name:        "requires_nearby_players",
		Description: "Other players must be at this POI",
		Check:       func(gc *GameContext) bool { return gc.NearbyPlayerCount > 0 },
	}
	RequiresWrecks = Precondition{
		Name:        "requires_wrecks",
		Description: "Wrecks must be at current POI",
		Check:       func(gc *GameContext) bool { return gc.WreckCount > 0 },
	}
	RequiresTowingWreck = Precondition{
		Name:        "requires_towing_wreck",
		Description: "Must be towing a wreck",
		Check:       func(gc *GameContext) bool { return gc.TowingWreck },
	}
	RequiresStoredShips = Precondition{
		Name:        "requires_stored_ships",
		Description: "Must have ships stored at this station",
		Check:       func(gc *GameContext) bool { return gc.StoredShipCount > 0 },
	}
)

Player status preconditions.

View Source
var AllActions = []Action{

	{
		Name: "undock", Summary: "Undock from a base",
		Category: "navigation", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},
	{
		Name: "dock", Summary: "Dock at a base",
		Category: "navigation", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresNotInCombat},
		Targets:       stationPOIs,
	},
	{
		Name: "travel", Summary: "Travel to a POI in current system",
		Category: "navigation", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresFuel, RequiresNotInCombat, RequiresHasPOIs},
		Targets:       otherPOIs,
	},
	{
		Name: "jump", Summary: "Jump to an adjacent star system",
		Category: "navigation", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresFuel, RequiresNotInCombat, RequiresHasConnections},
		Targets:       connectedSystems,
	},

	{
		Name: "mine", Summary: "Mine resources from asteroids, ice fields, or gas clouds",
		Category: "mining", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresCargoSpace, RequiresMiningPOI, RequiresNotInCombat},
	},

	{
		Name: "buy", Summary: "Buy items at market price from the station exchange",
		Category: "trading", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresCredits, RequiresCargoSpace},
	},
	{
		Name: "sell", Summary: "Sell items at market price on the station exchange",
		Category: "trading", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresHasCargo},
	},
	{
		Name: "trade_offer", Summary: "Offer a trade to another player",
		Category: "trading", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresNearbyPlayers},
	},
	{
		Name: "trade_accept", Summary: "Accept a trade offer",
		Category: "trading", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},
	{
		Name: "trade_cancel", Summary: "Cancel your trade offer",
		Category: "trading", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},
	{
		Name: "trade_decline", Summary: "Decline a trade offer",
		Category: "trading", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},

	{
		Name: "create_buy_order", Summary: "Place a buy offer on the station exchange",
		Category: "exchange", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresCredits},
	},
	{
		Name: "create_sell_order", Summary: "List items for sale on the station exchange",
		Category: "exchange", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresHasCargo},
	},
	{
		Name: "cancel_order", Summary: "Cancel an active order and return escrow",
		Category: "exchange", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},
	{
		Name: "modify_order", Summary: "Change the price on an existing order",
		Category: "exchange", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},

	{
		Name: "attack", Summary: "Attack another player, pirate, or empire NPC",
		Category: "combat", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresNearbyPlayers},
	},
	{
		Name: "battle_advance", Summary: "Advance toward the enemy in battle",
		Category: "combat", IsMutation: true,
		Preconditions: []Precondition{RequiresInCombat},
	},
	{
		Name: "battle_retreat", Summary: "Retreat from the enemy in battle",
		Category: "combat", IsMutation: true,
		Preconditions: []Precondition{RequiresInCombat},
	},
	{
		Name: "cloak", Summary: "Toggle cloaking device",
		Category: "combat", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresNotInCombat},
	},
	{
		Name: "scan", Summary: "Scan another player or empire NPC",
		Category: "combat", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresNearbyPlayers},
	},
	{
		Name: "reload", Summary: "Reload a weapon's magazine from ammo in cargo",
		Category: "combat", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresHasCargo},
	},
	{
		Name: "self_destruct", Summary: "Destroy your own ship",
		Category: "combat", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},

	{
		Name: "loot_wreck", Summary: "Loot items from a wreck",
		Category: "salvage", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresWrecks, RequiresCargoSpace},
	},
	{
		Name: "tow_wreck", Summary: "Attach a tow line to a wreck for hauling",
		Category: "salvage", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresWrecks},
	},
	{
		Name: "release_tow", Summary: "Release a towed wreck at your current location",
		Category: "salvage", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresTowingWreck},
	},
	{
		Name: "scrap_wreck", Summary: "Scrap a towed wreck for salvage materials",
		Category: "salvage", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresTowingWreck, RequiresCargoSpace},
	},
	{
		Name: "sell_wreck", Summary: "Sell a towed wreck to the salvage yard for credits",
		Category: "salvage", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresTowingWreck},
	},

	{
		Name: "refuel", Summary: "Refuel your ship or transfer fuel to another ship",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresNotFullFuel},
	},
	{
		Name: "repair", Summary: "Repair hull at station or in space with repair kits",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresDamaged},
	},
	{
		Name: "repair_module", Summary: "Repair wear on a module using a Repair Kit",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresHasCargo},
	},
	{
		Name: "install_mod", Summary: "Install a module on your ship",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresHasCargo},
	},
	{
		Name: "uninstall_mod", Summary: "Uninstall a module from your ship",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},
	{
		Name: "switch_ship", Summary: "Switch to a different ship stored at this station",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresStoredShips},
	},
	{
		Name: "buy_listed_ship", Summary: "Purchase a ship from the exchange",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresCredits},
	},
	{
		Name: "sell_ship", Summary: "Sell a stored ship at the current station",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresStoredShips},
	},
	{
		Name: "list_ship_for_sale", Summary: "List a stored ship for sale on the exchange",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresStoredShips},
	},
	{
		Name: "cancel_ship_listing", Summary: "Remove your ship listing from the exchange",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},
	{
		Name: "commission_ship", Summary: "Commission a ship to be built at this shipyard",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresCredits},
	},
	{
		Name: "cancel_commission", Summary: "Cancel a pending or in-progress ship commission",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},
	{
		Name: "supply_commission", Summary: "Donate materials to a commission",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresHasCargo},
	},
	{
		Name: "name_ship", Summary: "Set or clear a custom name for your active ship",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},
	{
		Name: "use_item", Summary: "Use a consumable item from cargo",
		Category: "ship", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresHasCargo},
	},

	{
		Name: "jettison", Summary: "Jettison items from cargo into space",
		Category: "cargo", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresHasCargo},
	},

	{
		Name: "deposit_items", Summary: "Move items from cargo to station storage",
		Category: "storage", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresHasCargo},
	},
	{
		Name: "withdraw_items", Summary: "Move items from station storage to cargo",
		Category: "storage", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresCargoSpace},
	},
	{
		Name: "send_gift", Summary: "Send items, credits, or a ship to another player",
		Category: "storage", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},

	{
		Name: "craft", Summary: "Craft an item (supports batch crafting)",
		Category: "crafting", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresHasCargo},
	},

	{
		Name: "accept_mission", Summary: "Accept a mission from the mission board",
		Category: "missions", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},
	{
		Name: "complete_mission", Summary: "Complete a mission and claim rewards",
		Category: "missions", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},
	{
		Name: "abandon_mission", Summary: "Abandon an active mission",
		Category: "missions", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},
	{
		Name: "distress_signal", Summary: "Broadcast a distress signal for emergency rescue",
		Category: "missions", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked},
	},

	{
		Name: "create_faction", Summary: "Create a new faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},
	{
		Name: "join_faction", Summary: "Join a faction via invitation",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},
	{
		Name: "leave_faction", Summary: "Leave your faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_invite", Summary: "Invite a player to your faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_kick", Summary: "Kick a player from your faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_promote", Summary: "Promote or demote a faction member",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_deposit_credits", Summary: "Transfer credits to faction treasury",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction, RequiresCredits},
	},
	{
		Name: "faction_deposit_items", Summary: "Move items from cargo to faction storage",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction, RequiresHasCargo},
	},
	{
		Name: "faction_withdraw_credits", Summary: "Transfer credits from faction treasury",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_withdraw_items", Summary: "Move items from faction storage to cargo",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction, RequiresCargoSpace},
	},
	{
		Name: "faction_declare_war", Summary: "Declare war on another faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_propose_peace", Summary: "Propose peace to a faction you're at war with",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_accept_peace", Summary: "Accept a peace proposal",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_propose_ally", Summary: "Propose a mutual alliance with another faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_accept_ally", Summary: "Accept a pending alliance proposal",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_remove_ally", Summary: "Dissolve an alliance with another faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_set_enemy", Summary: "Mark another faction as enemy",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_submit_intel", Summary: "Submit system intel to faction's shared map",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit, RequiresFaction},
	},
	{
		Name: "faction_submit_trade_intel", Summary: "Submit market prices to faction ledger",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction},
	},
	{
		Name: "espionage", Summary: "Send a spy to gather intel on the docked station via the faction's Espionage HQ",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction},
	},
	{
		Name: "faction_post_mission", Summary: "Post a mission on faction's mission board",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction, RequiresCredits},
	},
	{
		Name: "faction_cancel_mission", Summary: "Cancel a posted faction mission",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction},
	},
	{
		Name: "faction_create_buy_order", Summary: "Create a buy order for your faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction},
	},
	{
		Name: "faction_create_sell_order", Summary: "Create a sell order for your faction",
		Category: "faction", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresFaction},
	},

	{
		Name: "fleet", Summary: "Create and manage player fleets",
		Category: "social", IsMutation: true,
		Preconditions: []Precondition{RequiresNotInTransit},
	},

	{
		Name: "buy_insurance", Summary: "Purchase ship insurance",
		Category: "insurance", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked, RequiresCredits},
	},
	{
		Name: "set_home_base", Summary: "Set your home base for respawning",
		Category: "insurance", IsMutation: true,
		Preconditions: []Precondition{RequiresDocked},
	},

	{
		Name: "survey_system", Summary: "Scan for hidden deep core deposits",
		Category: "exploration", IsMutation: true,
		Preconditions: []Precondition{RequiresUndocked, RequiresNotInCombat},
	},
}

AllActions is the complete registry of mutation commands. Action names MUST match the cases in pkg/agent/runner.go executeDecision().

Functions

func CommandAnnotations

func CommandAnnotations() map[string]Annotation

CommandAnnotations returns the complete mapping of command name to annotation. This is the single source of truth for preconditions and target generators.

Types

type Action

type Action struct {
	Name          string                      // e.g. "mine", "travel", "buy"
	Summary       string                      // From OpenAPI: "Mine resources from asteroids..."
	Category      string                      // Tag: "navigation", "trading", "combat", etc.
	IsMutation    bool                        // Always true for actions in this registry
	Preconditions []Precondition              // All must pass for action to be valid
	Targets       func(*GameContext) []string // Dynamic target generator (nil = no targets needed)
}

Action represents a single game mutation with its context requirements.

type ActionOption

type ActionOption struct {
	Action      string   `json:"action"`
	Description string   `json:"description"`
	Targets     []string `json:"targets,omitempty"`
}

ActionOption matches the tot.ActionOption type for bridging to the ToT pipeline. This avoids an import cycle between actionspace and tot.

type ActionResult

type ActionResult struct {
	Action         Action
	Valid          bool
	Targets        []string // Populated if valid and action has targets
	FailedChecks   []string // Names of preconditions that failed
	BranchingCount int      // 1 if no targets, len(Targets) if valid, 0 if invalid
}

ActionResult is the evaluated state of a single action.

type ActionSpace

type ActionSpace struct {
	Context GameContext
	Actions []ActionResult
	Stats   Stats
}

ActionSpace is the full evaluated result.

func Evaluate

func Evaluate(gc GameContext) ActionSpace

Evaluate computes the full action space using the default AllActions registry.

func (ActionSpace) ToActionOptions

func (as ActionSpace) ToActionOptions() []ActionOption

ToActionOptions converts valid actions to the ActionOption format used by the ToT pipeline. Only includes actions that passed all preconditions.

func (ActionSpace) ValidActions

func (as ActionSpace) ValidActions() []ActionResult

ValidActions returns only the actions that passed all preconditions.

func (ActionSpace) ValidByCategory

func (as ActionSpace) ValidByCategory(category string) []ActionResult

ValidByCategory returns valid actions filtered by category.

type Annotation

type Annotation struct {
	Preconditions []Precondition
	Targets       func(*GameContext) []string

	// Category override (empty = use tag from OpenAPI spec).
	Category string
	// Summary override for virtual actions not in the spec.
	Summary string

	// IncludeNonMutation marks a command that lacks x-is-mutation in the spec
	// but should still be included in the action registry because it changes state.
	IncludeNonMutation bool
	// Virtual marks actions that don't exist as top-level OpenAPI paths
	// (e.g. battle_advance is a sub-action of the battle endpoint).
	Virtual bool
}

Annotation holds the preconditions, target generator, and metadata for a command.

type CategoryStats

type CategoryStats struct {
	Total           int `json:"total"`
	Valid           int `json:"valid"`
	Pruned          int `json:"pruned"`
	BranchingFactor int `json:"branching_factor"`
}

CategoryStats holds per-category metrics.

type ConnectionInfo

type ConnectionInfo struct {
	SystemID string
	Name     string
	Distance int
}

ConnectionInfo is a minimal system connection for target generation.

type GameContext

type GameContext struct {
	// Primary state (mutually exclusive)
	Docked    bool
	InTransit bool

	// Combat states
	InCombat bool // Pirate/NPC combat
	InBattle bool // Tactical battle system

	// Location
	CurrentPOIType string           // "asteroid_belt", "station", "ice_field", etc.
	CurrentPOIID   string           //nolint:revive // POI is an acronym used as a name
	SystemPOIs     []POIInfo        // All POIs in current system
	Connections    []ConnectionInfo // Adjacent systems

	// Ship status
	Fuel          float64
	MaxFuel       float64
	Hull          float64
	MaxHull       float64
	CargoUsed     float64
	CargoCapacity float64
	Credits       float64
	Modules       []string // Installed module IDs
	TowingWreck   bool

	// Player status
	HasFaction  bool
	FactionRank string
	IsCloaked   bool

	// Nearby entities
	NearbyPlayerCount int
	WreckCount        int
	StoredShipCount   int
	CargoItemCount    int // Number of distinct item types in cargo
}

GameContext is the flattened game state used for precondition evaluation. Built from *game.State for real use, or constructed manually for the visualizer.

func FromState

func FromState(state *game.State) GameContext

FromState builds a GameContext from live game state.

func (GameContext) Validate

func (gc GameContext) Validate() error

Validate checks that a GameContext has no impossible state combinations. Used by the visualizer to prevent nonsense configurations.

type POIInfo

type POIInfo struct {
	ID      string
	Name    string
	Type    string
	HasBase bool
}

POIInfo is a minimal POI representation for target generation.

type Precondition

type Precondition struct {
	Name        string                  // e.g. "requires_docked"
	Description string                  // Human-readable: "Ship must be docked at a station"
	Check       func(*GameContext) bool // Returns true if satisfied
}

Precondition is a named, evaluatable check against game context.

type PruningReason

type PruningReason struct {
	Precondition string `json:"precondition"`
	Count        int    `json:"count"`
}

PruningReason tracks how many actions a precondition pruned.

type Registry

type Registry struct {
	Actions []Action
	// Warnings collected during loading (unknown commands, missing annotations).
	Warnings []string
}

Registry holds the complete set of actions loaded from an OpenAPI spec and enriched with preconditions and target generators.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns a registry built from the hardcoded AllActions. Used when no OpenAPI spec is available.

func LoadFromOpenAPI

func LoadFromOpenAPI(path string) (*Registry, error)

LoadFromOpenAPI reads an OpenAPI spec file and builds a Registry by merging the spec's commands with the annotated preconditions and target generators.

Commands in the spec that have no annotation get a default precondition (RequiresNotInTransit). Commands in the annotation map not found in the spec generate warnings (stale annotations).

func (*Registry) Evaluate

func (r *Registry) Evaluate(gc GameContext) ActionSpace

Evaluate computes the full action space using this registry's actions.

func (*Registry) LogWarnings

func (r *Registry) LogWarnings()

LogWarnings prints any loading warnings to the default logger.

type Stats

type Stats struct {
	TotalActions      int                      `json:"total_actions"`
	ValidActions      int                      `json:"valid_actions"`
	PrunedActions     int                      `json:"pruned_actions"`
	PrunedPercent     float64                  `json:"pruned_percent"`
	BranchingFactor   int                      `json:"branching_factor"`
	ByCategory        map[string]CategoryStats `json:"by_category"`
	TopPruningReasons []PruningReason          `json:"top_pruning_reasons"`
}

Stats holds branching factor metrics for an evaluated action space.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL