util

package
v0.0.0-...-26478da Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BFS

func BFS(context *SearchContext) int

Types

type Grid

type Grid struct {
	Nodes         [][]*Node
	StartLocation *Node
	EndLocation   *Node
}

func MakeGrid

func MakeGrid(input []string) *Grid

func (*Grid) FindShortestPath

func (g *Grid) FindShortestPath(start, end *Node) int

func (*Grid) GetAdjacentNodes

func (g *Grid) GetAdjacentNodes(node *Node) []*Node

func (*Grid) GetNodeAt

func (g *Grid) GetNodeAt(col, row int) *Node

func (*Grid) GetNodesWithElevationAt

func (g *Grid) GetNodesWithElevationAt(level int) []*Node

func (*Grid) GetShortestPathSteps

func (g *Grid) GetShortestPathSteps() int

func (*Grid) PrintNodes

func (g *Grid) PrintNodes() string

type Node

type Node struct {
	Name      string
	Row       int
	Col       int
	Elevation int
	Grid      *Grid
}

func NewNode

func NewNode(grid *Grid) *Node

func (*Node) Print

func (n *Node) Print() string

type NodeQueueItem

type NodeQueueItem struct {
	Node  *Node
	Steps int
}

type SearchContext

type SearchContext struct {
	RootNode   *Node
	TargetNode *Node
	Explored   *map[[2]int]bool
	Queue      *data.Queue[NodeQueueItem]
}

Jump to

Keyboard shortcuts

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