twod

package
v0.0.0-...-09c6c35 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RIGHT = "R"
	UP    = "U"
	LEFT  = "L"
	DOWN  = "D"
)

Variables

View Source
var (
	Dirs = map[string]*Pos{
		"R": NewPos(0, 1),
		"U": NewPos(-1, 0),
		"L": NewPos(0, -1),
		"D": NewPos(1, 0),
	}

	Diags = []*Pos{
		{Row: 1, Col: 1},
		{Row: -1, Col: 1},
		{Row: -1, Col: -1},
		{Row: 1, Col: -1},
	}

	Adjacent = []*Pos{
		{Row: -1, Col: -1}, {Row: -1, Col: 0}, {Row: -1, Col: 1},
		{Row: 0, Col: -1}, {Row: 0, Col: 1},
		{Row: 1, Col: -1}, {Row: 1, Col: 0}, {Row: 1, Col: 1},
	}
)

Functions

This section is empty.

Types

type Pos

type Pos struct {
	Row int
	Col int
}

func FromString

func FromString(s string) *Pos

func NewPos

func NewPos(r, c int) *Pos

func (*Pos) Add

func (p *Pos) Add(o *Pos)

func (*Pos) Adjacent

func (p *Pos) Adjacent(f ValidFunc) []*Pos

func (*Pos) Clone

func (p *Pos) Clone() *Pos

func (*Pos) Dist

func (p *Pos) Dist(o *Pos) int

func (*Pos) Equals

func (p *Pos) Equals(o *Pos) bool

func (*Pos) Follow

func (p *Pos) Follow(f ValidFunc, adj []*Pos) []*Pos

func (*Pos) Neighbors

func (p *Pos) Neighbors(f ValidFunc) []*Pos

func (*Pos) String

func (p *Pos) String() string

type ValidFunc

type ValidFunc func(p *Pos) bool

Jump to

Keyboard shortcuts

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