pkg

package
v0.0.0-...-4fffddb Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 4 Imported by: 9

Documentation

Index

Constants

View Source
const (
	HEXASOUTH = iota
	HEXASOUTHEAST
	HEXANORTHEAST
	HEXANORTH
	HEXANORTHWEST
	HEXASOUTHWEST
)
View Source
const (
	UP = iota
	LEFT
	DOWN
	RIGHT
)

Variables

View Source
var DirectionMap = map[int]struct {
	x, y int
	name string
}{
	UP:    {0, 1, "up"},
	LEFT:  {1, 0, "left"},
	DOWN:  {0, -1, "down"},
	RIGHT: {-1, 0, "right"},
}
View Source
var HexaDirectionMap = map[int]struct {
	x, y int
	name string
}{
	HEXASOUTH:     {1, 0, "SOUTH"},
	HEXASOUTHEAST: {1, -1, "SOUTHEAST"},
	HEXANORTHEAST: {0, -1, "NORTHEAST"},
	HEXANORTH:     {-1, 0, "NORTH"},
	HEXANORTHWEST: {-1, 1, "NORTHWEST"},
	HEXASOUTHWEST: {0, 1, "SOUTHWEST"},
}

Functions

func Abs

func Abs(i int) int

func Check

func Check(err error)

func GCD

func GCD(a, b int) int

func GetAllPermutations

func GetAllPermutations(s string) []string

func HexaDist

func HexaDist(x, y int) int

func LCM

func LCM(a, b int) int

func Max

func Max(values ...int) int

func Min

func Min(values ...int) int

func Multiply

func Multiply(values ...int) int

func MustAtoi

func MustAtoi(s string) int

func MustScanf

func MustScanf(line, format string, a ...interface{})

func ParseIntList

func ParseIntList(s, sep string) []int

func ParseIntMap

func ParseIntMap(s, sep string) map[int]int

func Perm

func Perm(a []rune, f func([]rune))

Perm calls f with each permutation of a.

func RecursiveSum

func RecursiveSum(i int, sumFunc SumFunc) int

func Sum

func Sum(values ...int) int

Types

type HexaP

type HexaP struct {
	X, Y             int
	CurrentDirection int
}

func NewHexaPoint

func NewHexaPoint() *HexaP

func (*HexaP) DistFrom

func (p *HexaP) DistFrom(from *HexaP) int

func (*HexaP) DistFromOrigin

func (p *HexaP) DistFromOrigin() int

func (*HexaP) Move

func (p *HexaP) Move(steps int)

func (*HexaP) MoveNorth

func (p *HexaP) MoveNorth(steps int)

func (*HexaP) MoveNorthEast

func (p *HexaP) MoveNorthEast(steps int)

func (*HexaP) MoveNorthWest

func (p *HexaP) MoveNorthWest(steps int)

func (*HexaP) MoveSouth

func (p *HexaP) MoveSouth(steps int)

func (*HexaP) MoveSouthEast

func (p *HexaP) MoveSouthEast(steps int)

func (*HexaP) MoveSouthWest

func (p *HexaP) MoveSouthWest(steps int)

func (*HexaP) TurnLeft

func (p *HexaP) TurnLeft()

func (*HexaP) TurnRight

func (p *HexaP) TurnRight()

type P

type P struct {
	X, Y             int
	CurrentDirection int
	Steps            int
}

func NewPoint

func NewPoint() *P

func (*P) DistFrom

func (p *P) DistFrom(from *P) int

func (*P) DistFromOrigin

func (p *P) DistFromOrigin() int

func (*P) FindInMap

func (p *P) FindInMap(stringMap [][]string, origin P) string

func (*P) FourWays

func (p *P) FourWays() []P

func (*P) Move

func (p *P) Move(steps int)

func (*P) MoveDown

func (p *P) MoveDown(steps int)

func (*P) MoveLeft

func (p *P) MoveLeft(steps int)

func (*P) MoveRight

func (p *P) MoveRight(steps int)

func (*P) MoveUp

func (p *P) MoveUp(steps int)

func (P) String

func (p P) String() string

func (*P) TurnLeft

func (p *P) TurnLeft()

func (*P) TurnRight

func (p *P) TurnRight()

type SumFunc

type SumFunc func(int) (int, bool)

type Tile

type Tile struct {
	P           P
	RowLenght   int
	EmptyPoints map[P]*Tile
}

func (*Tile) PathEstimatedCost

func (t *Tile) PathEstimatedCost(to astar.Pather) float64

PathEstimatedCost uses Manhattan distance to estimate orthogonal distance

func (*Tile) PathNeighborCost

func (t *Tile) PathNeighborCost(to astar.Pather) float64

PathNeighborCost returns the cost of the tube leading to Truck.

func (*Tile) PathNeighbors

func (t *Tile) PathNeighbors() []astar.Pather

func (*Tile) Score

func (t *Tile) Score() int

func (*Tile) SetEmptyTiles

func (t *Tile) SetEmptyTiles(c map[P]*Tile)

func (*Tile) String

func (t *Tile) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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