trades

package
v1.63.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

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 INFthreshold = math.MaxInt / 1000
View Source
const NO_PARENT = -1
View Source
const PrecisionMultipiler = cfg.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 cfg.Vector, Pos2 cfg.Vector) float64

func GetTimeMs

func GetTimeMs(f *GameGraph, dist [][]int, keya string, keyb string) (cfg.MillisecondsI, error)

func GetTimeMs2

func GetTimeMs2(f *GameGraph, dist [][]int, keya string, keyb string) cfg.MillisecondsI

func ReverseSlice

func ReverseSlice(s interface{})

panic if s is not a slice

Types

type DetailedPath

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

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

type DijkstraOption func(graph *DijkstraAPSP)

func WithPathDistsForAllNodes

func WithPathDistsForAllNodes() DijkstraOption

type DijkstraResult

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

type ExtraBase

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

type GameGraph

type GameGraph struct {
	IndexByNick             map[VertexName]int  `json:"index_by_nickname"`
	NicknameByIndex         map[int]VertexName  `json:"nickname_by_index"`
	AllowedVertixesForCalcs map[VertexName]bool // Consider deleting this
	AvgCruiseSpeed          int

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

func MapConfigsToFGraph

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

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

func (*GameGraph) GetPaths

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

func (*GameGraph) GetTimeForDist

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

func (*GameGraph) SetEdge

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

func (*GameGraph) SetIdsName

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

func (*GameGraph) SetIstRadelane

func (f *GameGraph) SetIstRadelane(keya string)

func (*GameGraph) WipeMatrix added in v1.61.0

func (g *GameGraph) WipeMatrix()

type Item

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

An Item is something we manage in a priority queue.

type MappingOptions

type MappingOptions struct {
	TradeRoutesDetailedTradeLane *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

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

type Path

type Path struct {
	Node     int
	NextNode int
	Dist     int
}

func GetPath

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

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

type ShipSpeeds

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