fitting

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 6 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 fitting computes ship-module fitting against the game's catalog data. It answers two questions offline: how many of a module fit on a hull, and which hulls can fit a given count of a module. Slots, CPU, power, capacity- adding modules, and the Engineering skill are all accounted for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog holds the loaded ships, modules, and Engineering efficiency values.

func LoadCatalog

func LoadCatalog(dir string) (*Catalog, error)

LoadCatalog reads catalog_ships.json, catalog_items.json, and catalog_skills.json from dir and returns a populated Catalog. Items without a "slot" field are not modules and are skipped. Engineering efficiency defaults to 1%/level if the skill or its bonus keys are absent.

func (*Catalog) Engineering

func (c *Catalog) Engineering(level int) Engineering

Engineering returns an Engineering at the given level using the catalog's efficiency-per-level values.

func (*Catalog) Module

func (c *Catalog) Module(id string) (Module, bool)

Module returns the module with the given id.

func (*Catalog) Ship

func (c *Catalog) Ship(id string) (Ship, bool)

Ship returns the ship with the given id.

func (*Catalog) Ships

func (c *Catalog) Ships() []Ship

Ships returns all loaded ships sorted by tier then name.

type Engineering

type Engineering struct {
	Level            int
	CPUEffPerLevel   float64
	PowerEffPerLevel float64
}

Engineering carries the assumed Engineering skill level and the data-driven per-level efficiency values read from the skills catalog (both 1 by default).

func DefaultEngineering

func DefaultEngineering(level int) Engineering

DefaultEngineering returns an Engineering at the given level using the default 1%-per-level efficiency for both CPU and power. Used when no catalog skill data overrides it.

type FitResult

type FitResult struct {
	Fits              bool
	MaxCount          int    // populated by MaxFit: how many copies fit
	SlotType          string // module slot type ("" or "mixed" for multi-slot loadouts)
	SlotsUsed         int
	SlotsAvail        int
	CPUUsed           int
	CPUAvail          int
	PowerUsed         int
	PowerAvail        int
	BindingConstraint string // "weapon slots" | "defense slots" | "utility slots" | "CPU" | "power" | ""
	SkillWarnings     []string
}

FitResult reports the outcome of a fit calculation.

func CheckFit

func CheckFit(s Ship, loadout []ModuleCount, eng Engineering) FitResult

CheckFit reports whether an arbitrary loadout fits on ship s at the given Engineering level. It checks slot counts per type plus aggregate CPU and power, accounting for capacity-adding modules. The first violated constraint is reported in BindingConstraint.

func MaxFit

func MaxFit(s Ship, m Module, eng Engineering) FitResult

MaxFit reports how many copies of module m fit on ship s at the given Engineering level. It adds copies one at a time so that capacity-adding modules (cpu_bonus / power_bonus) correctly raise the budget as they are fitted. Iteration is bounded by the relevant slot count.

type Module

type Module struct {
	ID             string
	Name           string
	Type           string // "weapon" | "defense" | "mining" | "utility"
	Slot           string // "weapon" | "defense" | "utility"
	CPUUsage       int
	PowerUsage     int
	CPUBonus       int            // adds to CPU capacity (e.g. tow rig)
	PowerBonus     int            // adds to power capacity (e.g. reactor)
	RequiredSkills map[string]int // informational only
}

Module is the fitting-relevant subset of a catalog module.

type ModuleCount

type ModuleCount struct {
	Module Module
	Count  int
}

ModuleCount pairs a module with how many copies are being fitted.

type Ship

type Ship struct {
	ID             string
	Name           string
	CPUCapacity    int
	PowerCapacity  int
	WeaponSlots    int
	DefenseSlots   int
	UtilitySlots   int
	Tier           int
	DefaultModules []string // parsed but ignored by the fit math (bare-hull assumption)
}

Ship is the fitting-relevant subset of a catalog hull.

type ShipFit

type ShipFit struct {
	Ship   Ship
	Result FitResult
}

ShipFit pairs a ship with its MaxFit result for the queried module.

func ShipsThatFit

func ShipsThatFit(ships []Ship, m Module, count int, eng Engineering) []ShipFit

ShipsThatFit returns every ship that can fit at least `count` copies of module m, sorted by tier ascending then name. Each entry carries the per-ship MaxFit result.

Jump to

Keyboard shortcuts

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