trades

package
v0.106.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// Add for every pair of jumphole in path
	JumpHoleDelaySec = 15 // and jump gate
	// add for every tradelane vertex pair in path
	TradeLaneDockingDelaySec = 10
	// add just once
	BaseDockingDelay = 10
)
View Source
const INF = math.MaxInt
View Source
const NO_PARENT = -1
View Source
const PrecisionMultipiler = cfgtype.Milliseconds(1000)

makes time in ms. Higher int value help having better calcs.

Variables

This section is empty.

Functions

func ArraysFill

func ArraysFill[T any](array []T, value T)

func DistanceForVecs

func DistanceForVecs(Pos1 cfgtype.Vector, Pos2 cfgtype.Vector) float64

func GetDist

func GetDist(f *GameGraph, dist [][]int, keya string, keyb string) int

func ReverseSlice added in v0.65.0

func ReverseSlice(s interface{})

panic if s is not a slice

Types

type DetailedPath added in v0.65.0

type DetailedPath struct {
	PrevName    string
	NextName    string
	PrevIdsName int
	NextIdsName int
	PrevNode    int
	NextNode    int
	Dist        int
	TimeMinutes int
	TimeSeconds int
}

type DijkstraAPSP

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

func NewDijkstraApsp added in v0.65.0

func NewDijkstraApsp(vertices int) *DijkstraAPSP

On using the below constructor, edges must be added manually to the graph using addEdge()

func NewDijkstraApspFromGraph

func NewDijkstraApspFromGraph(graph *GameGraph, opts ...DijkstraOption) *DijkstraAPSP

func NewDijkstraApspFromMatrix

func NewDijkstraApspFromMatrix(vertices int, adjacencyMatrix [][]int) *DijkstraAPSP

// On using the below constructor, // edges will be added automatically // to the graph using the adjacency matrix

func (*DijkstraAPSP) DijkstraApsp

func (g *DijkstraAPSP) DijkstraApsp() ([][]int, [][]Parent)

type DijkstraOption added in v0.65.0

type DijkstraOption func(graph *DijkstraAPSP)

func WithPathDistsForAllNodes added in v0.65.0

func WithPathDistsForAllNodes() DijkstraOption

type DijkstraResult

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

type ExtraBase added in v0.69.0

type ExtraBase struct {
	Pos      cfgtype.Vector
	Nickname cfgtype.BaseUniNick
}

type GameGraph

type GameGraph struct {
	IndexByNick             map[VertexName]int
	NicknameByIndex         map[int]VertexName
	AllowedVertixesForCalcs map[VertexName]bool // Consider deleting this
	AvgCruiseSpeed          int

	IsTradelane               map[VertexName]bool
	CanVisitFreightersOnlyJHs WithFreighterPaths
	// contains filtered or unexported fields
}

func MapConfigsToFGraph added in v0.65.0

func MapConfigsToFGraph(
	configs *configs_mapped.MappedConfigs,
	avgCruiseSpeed int,
	with_freighter_paths WithFreighterPaths,
	extra_bases_by_system map[string][]ExtraBase,
	opts MappingOptions,
) *GameGraph

func NewGameGraph

func NewGameGraph(avgCruiseSpeed int, canVisitFreighterOnlyJHs WithFreighterPaths) *GameGraph

func (*GameGraph) DistanceToTime added in v0.77.0

func (graph *GameGraph) DistanceToTime(distance float64, system_speed_multiplier float64) cfgtype.Milliseconds

func (*GameGraph) GetPaths added in v0.65.0

func (graph *GameGraph) GetPaths(parents [][]Parent, dist [][]int, source_key string, target_key string) []DetailedPath

func (*GameGraph) GetTimeForDist added in v0.65.0

func (graph *GameGraph) GetTimeForDist(dist cfgtype.Milliseconds) cfgtype.Seconds

func (*GameGraph) SetEdge

func (f *GameGraph) SetEdge(keya string, keyb string, distance float64)

func (*GameGraph) SetIdsName added in v0.65.0

func (f *GameGraph) SetIdsName(keya string, ids_name int)

func (*GameGraph) SetIstRadelane added in v0.66.0

func (f *GameGraph) SetIstRadelane(keya string)

type Item

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

An Item is something we manage in a priority queue.

type MappingOptions added in v0.101.0

type MappingOptions struct {
	SimplifiedTradeLanesCalc *bool
}

Algorithm should be like this: We iterate through list of Systems: Adding all bases, jump gates, jump holes, tradelanes as Vertexes. We scan in advance nicknames for object on another side of jump gate/hole and add it as vertix We calculcate distances between them. Distance between jump connections is 0 (or time to wait measured in distance) We calculate distances between trade lanes as shorter than real distance for obvious reasons. The matrix built on a fight run will be having connections between vertixes as hashmaps of possible edges? For optimized memory consumption in a sparse matrix.

Then on second run, knowing amount of vertixes We build Floyd matrix? With allocating memory in bulk it should be rather rapid may be. And run Floud algorithm. Thus we have stuff calculated for distances between all possible trading locations. (edited) [6:02 PM] ==== Then we build table of Bases as starting points. And on click we show proffits of delivery to some location. With time of delivery. And profit per time. [6:02 PM] ==== Optionally print sum of two best routes that can be started within close range from each other.

type Neighbour

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

func NewNeighbour

func NewNeighbour(destination int, weight int) *Neighbour

type Parent added in v0.67.1

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

type Path added in v0.65.0

type Path struct {
	Node     int
	NextNode int
	Dist     int
}

func GetPath added in v0.65.0

func GetPath(graph *GameGraph, parents [][]Parent, dist [][]int, source_key string, target_key string) []Path

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() any

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x any)

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type RouteShipType added in v0.77.0

type RouteShipType int64
const (
	RouteTransport RouteShipType = iota
	RouteFrigate
	RouteFreighter
)

type ShipSpeeds added in v0.69.0

type ShipSpeeds struct {
	AvgTransportCruiseSpeed int
	AvgFrigateCruiseSpeed   int
	AvgFreighterCruiseSpeed int
}
var DiscoverySpeeds ShipSpeeds = ShipSpeeds{
	AvgTransportCruiseSpeed: 350,
	AvgFrigateCruiseSpeed:   500,
	AvgFreighterCruiseSpeed: 500,
}
var FLSRSpeeds ShipSpeeds = ShipSpeeds{
	AvgTransportCruiseSpeed: 500,
	AvgFrigateCruiseSpeed:   500,
	AvgFreighterCruiseSpeed: 500,
}
var VanillaSpeeds ShipSpeeds = ShipSpeeds{
	AvgTransportCruiseSpeed: 350,
	AvgFrigateCruiseSpeed:   350,
	AvgFreighterCruiseSpeed: 350,
}

type SystemObject

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

type VertexName

type VertexName string

type WithFreighterPaths

type WithFreighterPaths bool

Jump to

Keyboard shortcuts

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