trades

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// already accounted for
	AvgTransportCruiseSpeed = 350
	AvgFreighterCruiseSpeed = 500
	// already accounted for
	AvgTradeLaneSpeed = 1900

	// 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 = 20
)
View Source
const INF = math.MaxInt
View Source
const NO_PARENT = -1

Variables

This section is empty.

Functions

func ArraysFill

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

func DistanceForVecs

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

func GetDist

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

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, [][]int)

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 GameGraph

type GameGraph struct {
	IndexByNick             map[VertexName]int
	NicknameByIndex         map[int]VertexName
	AllowedVertixesForCalcs map[VertexName]bool // Consider deleting this
	AvgCruiseSpeed          int
	// contains filtered or unexported fields
}

func MapConfigsToFGraph added in v0.65.0

func MapConfigsToFGraph(configs *configs_mapped.MappedConfigs, avgCruiseSpeed int, with_freighter_paths WithFreighterPaths) *GameGraph

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.

func NewGameGraph

func NewGameGraph(avgCruiseSpeed int) *GameGraph

func (*GameGraph) GetDistForTime added in v0.65.0

func (graph *GameGraph) GetDistForTime(time int) float64

func (*GameGraph) GetPaths added in v0.65.0

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

func (*GameGraph) GetTimeForDist added in v0.65.0

func (graph *GameGraph) GetTimeForDist(dist float64) int

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)

type Item

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

An Item is something we manage in a priority queue.

type Neighbour

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

func NewNeighbour

func NewNeighbour(destination int, weight int) *Neighbour

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 [][]int, 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 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