route

package
v0.7.19 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 17 Imported by: 0 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 route plans an efficient order for a character's quest stops: pick-ups, objectives and turn-ins, with map coordinates. The order comes from a deterministic optimiser (Held-Karp up to ExactMax stops, then nearest-neighbour improved by order-respecting 2-opt and or-opt), never from a language model. The rules are in docs/plan-format.md.

Index

Constants

View Source
const (
	MaxSteps    = 20  // stops on the route; the rest go to "later"
	MaxTotal    = 25  // stops on the route, locked follow-ups included
	MaxLater    = 30  // stops listed in "later"
	LevelMargin = 1   // a quest above the player's level + this goes to "later"
	MergeRadius = 3.0 // objective stops this close (map percent) on one map are one stop
	ClusterSize = 8.0 // spawns this close (map percent) are one cluster

)

Limits.

View Source
const (
	KindPickup    = "pickup"
	KindObjective = "objective"
	KindTurnIn    = "turnin"
	KindTravel    = "travel"
)

Stop kinds.

View Source
const ExactMax = 12

ExactMax is the most stops solved exactly; larger routes use the heuristic.

View Source
const File = "Plan.lua"

File is the file name, next to Digest.lua.

View Source
const Schema = "1.1"

Schema is the Plan.lua format version (docs/plan-format.md).

Variables

This section is empty.

Functions

func Lines

func Lines(p Plan, limit int) (lines []string, summary string)

Lines is the plan as short numbered lines for the overlay, with a one-line summary.

func Render

func Render(p Plan, limit int) string

Render is the plan as plain text for a prompt: the first limit steps and a count.

func Solve

func Solve(p *Problem, seeds ...[]int) []int

Solve returns the best order found. seeds are extra feasible orders to start the heuristic from (for example the naive quest-by-quest order); the result is never longer than any of them.

func StepText added in v0.7.5

func StepText(s Stop) string

StepText is one overlay line: the action, and for a locked step where it waits. The place is not in it: X and Y are separate fields for the UI to show dimly.

func UnlockNotes added in v0.7.5

func UnlockNotes(p Plan) map[int][]string

UnlockNotes is, for each turn-in quest id, the "Quest (from NPC, here)" texts of the follow-ups it unlocks on this route.

Types

type Envelope

type Envelope struct {
	Generated int64
	Plans     []Plan
}

Envelope is the whole file: one plan per character.

func (Envelope) Lua

func (e Envelope) Lua() string

Lua renders the one data-only `WoWCompanionPlan = {...}` assignment.

type FindStop added in v0.7.0

type FindStop struct {
	N       int    `json:"n"`
	QuestID int    `json:"quest_id,omitempty"`
	Quest   string `json:"quest,omitempty"`
	Label   string `json:"label"`
}

FindStop is an objective the planner could not place on the map: something to find, with no x or y.

type FollowNote added in v0.7.5

type FollowNote struct {
	QuestID    int    `json:"quest_id"`
	Quest      string `json:"quest"`
	NPC        string `json:"npc,omitempty"`
	Here       bool   `json:"here,omitempty"` // the NPC who takes the unlocking turn-in
	Observed   bool   `json:"observed,omitempty"`
	UnlockedBy []int  `json:"unlocked_by"`
}

FollowNote describes one follow-up quest on the route, for the digest's "Unlocks:" line.

type Node

type Node struct {
	X, Y float64
	Pred []int
}

Node is one place to visit. Pred lists the indexes of nodes that must come first.

type Options added in v0.7.5

type Options struct {
	Lines  unlock.Lines   // the dataset's quest lines: a fallback where Questie is silent
	Obs    []unlock.Obs   // unlocks learned in game (the local file)
	Events []unlock.Event // the addon's observation log
	Depth  int            // follow-up links to look ahead; 0 is unlock.DefaultDepth
}

Options are the chain-aware inputs of a plan; the zero value plans from Questie alone.

func OptionsFor added in v0.7.5

func OptionsFor(addonSV string, ds store.DataStore) Options

OptionsFor gathers the chain-aware inputs of a plan: the dataset's quest lines (ds may be nil), the addon's observation log read from addonSV (the addon's WoWCompanion.lua; empty or unreadable: none) and the local file of observed unlocks, which this call updates with what the log newly shows. Everything stays on the player's machine.

type Plan

type Plan struct {
	Character string       `json:"character"`
	Zone      string       `json:"zone,omitempty"`
	Start     *Point       `json:"start,omitempty"`
	Steps     []Stop       `json:"steps"`
	Later     []Stop       `json:"later,omitempty"`
	Find      []FindStop   `json:"find,omitempty"` // objectives with no known location; not on the route
	Distance  float64      `json:"distance"`       // route length in map percent
	Naive     float64      `json:"naive_distance"` // the quest-by-quest order's length, for comparison
	Total     int          `json:"total"`          // stops on the route, a travel stop included
	Notes     []string     `json:"notes,omitempty"`
	Follow    []FollowNote `json:"follow_ups,omitempty"` // the locked follow-ups on the route, one per quest
}

Plan is the ordered route for one character.

func Build

func Build(c character.Character, qx *questie.Index) Plan

Build plans c's route from the player's own QuestieDB. A nil index or a character with no level gives an empty plan with a note saying why.

func BuildWith added in v0.7.5

func BuildWith(c character.Character, qx *questie.Index, opt Options) Plan

BuildWith is Build with the chain-aware inputs: the dataset's quest lines, unlocks learned in game and the addon's observation log.

type Point

type Point struct {
	Map int     `json:"map"`
	X   float64 `json:"x"`
	Y   float64 `json:"y"`
}

Point is a place on a map, in map percent.

type Problem

type Problem struct {
	Nodes []Node
	Start *[2]float64
	// Scale multiplies a distance (map percent to yards, say); 0 means 1. It does not change the order
	// on a single map, only the reported length.
	Scale float64
}

Problem is an open path from Start (nil: free start) through every node, respecting Pred.

func (*Problem) Feasible

func (p *Problem) Feasible(order []int) bool

Feasible reports whether order visits every node once with each node after its predecessors.

func (*Problem) Length

func (p *Problem) Length(order []int) float64

Length is the path length of order, in map percent (before Scale).

type Stop

type Stop struct {
	N       int     `json:"n"`
	Kind    string  `json:"kind"`
	QuestID int     `json:"quest_id,omitempty"`
	Quest   string  `json:"quest,omitempty"`
	Label   string  `json:"label"`
	Map     int     `json:"map"`
	X       float64 `json:"x"`
	Y       float64 `json:"y"`
	Done    bool    `json:"done"`

	// Chain-aware plan (Plan.lua 1.1). A locked step is a follow-up the plan's turn-ins unlock.
	Locked     bool   `json:"locked,omitempty"`
	UnlockedBy []int  `json:"unlocked_by,omitempty"` // the turn-ins that unlock it
	Depth      int    `json:"depth,omitempty"`       // links from a planned quest
	Chain      string `json:"chain,omitempty"`       // the quest line's name, when known
	Unlocks    []int  `json:"unlocks,omitempty"`     // on a turn-in: the follow-ups it unlocks
	After      int    `json:"after,omitempty"`       // on a locked step: the step number of its last unlocking turn-in
	Observed   bool   `json:"observed,omitempty"`    // the link or the giver was observed in game
	Giver      string `json:"giver,omitempty"`       // on a locked pick-up: the NPC
	Here       bool   `json:"here,omitempty"`        // on a locked pick-up: the same NPC as the unlocking turn-in
}

Stop is one place on the route.

Jump to

Keyboard shortcuts

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