Documentation
¶
Overview ¶
Package spar provides a controlled PvP sparring harness: it logs in two or more agents, equips and moves them to a non-empire arena, and runs scripted (or human-partnered) battles so combat mechanics are observable and testable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNonEmpireArena ¶
func IsNonEmpireArena(s game.SystemData) bool
IsNonEmpireArena reports whether a system permits anything-goes PvP: it is not owned by an empire, or is lawless / unpoliced / a pirate stronghold.
func SelectArena ¶
func SelectArena(systems []game.SystemData, byID map[string]game.SystemData, reachable func(systemID string) bool) (string, error)
SelectArena picks the best non-empire arena from systems: it must be a non-empire system, be reachable by all combatants (reachable(id) true), have a rendezvous POI, and have safe-space adjacency. Among candidates the first match (by input order) is returned. Pure — no network.
func ValidateArenaSystem ¶
func ValidateArenaSystem(s game.SystemData) error
ValidateArenaSystem checks that an already-loaded system is a legal arena. Used at arrival to confirm a --arena value really is outside empire space.
Types ¶
type Action ¶
type Action struct {
Kind string // "battle" | "noop"
BattleAction string // advance | retreat | stance | target
Payload map[string]any // stance, target_id
}
Action is a Policy's chosen move. Kind is "battle" (dispatch via client.Battle with BattleAction+Payload) or "noop" (do nothing this tick).
type Combatant ¶
type Combatant struct {
AgentID string
Username string
Client game.GameClient
Policy Policy // nil for the human partner slot
WeaponID string
ShieldID string
NoEquip bool
Logger *log.Logger // must be non-nil: game.NavigateToSystem dereferences it
}
Combatant is one logged-in agent plus its assigned policy and setup config.
type Match ¶
type Match struct {
Combatants []*Combatant
Arena string // arena system id (must be set; auto-discovery deferred)
Rendezvous string // POI type, e.g. "asteroid_belt"
AggressorIdx int // index of the bot that initiates (botvbot mode)
Partner bool // partner mode: don't initiate; wait for a human to attack
MaxTicks int
Logger *log.Logger
}
Match orchestrates a sparring session.
type Policy ¶
Policy decides one battle action from a View. Implementations are pure functions of the View, which keeps them unit-testable. This interface is the seam where custom .smolt-style battle scripts plug in later.
func NewAggressor ¶
func NewAggressor() Policy
NewAggressor advances to the engaged zone, then targets the nearest enemy and holds the fire stance.
func NewDummy ¶
func NewDummy() Policy
NewDummy braces and never advances or fires — a low-risk practice partner.
func NewRetreater ¶
func NewRetreater() Policy
NewRetreater immediately adopts the flee stance (which auto-retreats over several ticks), exercising the escape mechanic.
func NewSkirmisher ¶
NewSkirmisher holds the mid zone and fires, but retreats one zone when its own hull percentage drops below hullFloor.
func PolicyByName ¶
PolicyByName resolves a preset name to a Policy. The skirmisher uses a 40% hull floor by default.
type View ¶
type View struct {
Self game.BattleParticipant
Enemies []game.BattleParticipant
Allies []game.BattleParticipant
BattleID string
}
View is the read-only battle picture handed to a Policy each tick.