Documentation ¶
Index ¶
- Variables
- func ValidDirection(dir Direction) bool
- type Area
- func (a Area) ContainsDot(dot Dot) bool
- func (a Area) ContainsLocation(location Location) bool
- func (a Area) ContainsRect(rect Rect) bool
- func (a Area) Dots() []Dot
- func (a Area) Height() uint8
- func (a Area) MarshalJSON() ([]byte, error)
- func (a Area) Navigate(dot Dot, dir Direction, dis uint8) (Dot, error)
- func (a Area) NewRandomDot(x, y uint8) Dot
- func (a Area) NewRandomRect(rw, rh, sx, sy uint8) (*Rect, error)
- func (a Area) Size() uint16
- func (a Area) String() string
- func (a Area) Width() uint8
- type Direction
- type Dot
- type DotsMask
- func (dm *DotsMask) Copy() *DotsMask
- func (dm *DotsMask) DotCount() (count uint16)
- func (dm *DotsMask) Empty() bool
- func (dm *DotsMask) Height() uint8
- func (dm *DotsMask) Location(x, y uint8) Location
- func (dm *DotsMask) TurnLeft() *DotsMask
- func (dm *DotsMask) TurnOver() *DotsMask
- func (dm *DotsMask) TurnRandom() *DotsMask
- func (dm *DotsMask) TurnRight() *DotsMask
- func (dm *DotsMask) Width() uint8
- type ErrAreaNotContainsDot
- type ErrDirectionMarshal
- type ErrInvalidAreaSize
- type ErrInvalidDirection
- type ErrNavigation
- type ErrReverseDirection
- type Location
- func (l Location) Add(dot Dot) Location
- func (l Location) Contains(dot Dot) bool
- func (l Location) Copy() Location
- func (l Location) Delete(dot Dot) Location
- func (l1 Location) Difference(l2 Location) Location
- func (l Location) Dot(i uint16) Dot
- func (l Location) DotCount() uint16
- func (l Location) Empty() bool
- func (l1 Location) Equals(l2 Location) bool
- func (l1 Location) EqualsStrict(l2 Location) bool
- func (l Location) Hash() []uint16
- func (l1 Location) Intersection(l2 Location) (intersection Location)
- func (l Location) Reverse() Location
- type Rect
- func (r Rect) ContainsDot(d Dot) bool
- func (r1 Rect) ContainsRect(r2 Rect) bool
- func (r Rect) Dot(i uint16) Dot
- func (r Rect) DotCount() uint16
- func (r Rect) Dots() []Dot
- func (r1 Rect) Equals(r2 Rect) bool
- func (r Rect) Height() uint8
- func (r Rect) Location() Location
- func (r Rect) MarshalJSON() ([]byte, error)
- func (r Rect) Width() uint8
- func (r Rect) X() uint8
- func (r Rect) Y() uint8
Constants ¶
This section is empty.
Variables ¶
View Source
var DotsMaskBigHome = NewDotsMask([][]uint8{
{1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1},
})
View Source
var DotsMaskCross = NewDotsMask([][]uint8{
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0},
})
View Source
var DotsMaskCrossSmall = NewDotsMask([][]uint8{
{0, 1, 0},
{1, 1, 1},
{0, 1, 0},
})
View Source
var DotsMaskDiagonal = NewDotsMask([][]uint8{
{0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0},
})
View Source
var DotsMaskDiagonalSmall = NewDotsMask([][]uint8{
{1, 0, 1},
{0, 1, 0},
{1, 0, 1},
})
View Source
var DotsMaskHome1 = NewDotsMask([][]uint8{
{1, 1, 0, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1},
})
View Source
var DotsMaskHome2 = NewDotsMask([][]uint8{
{1, 1, 1, 0, 0, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 1, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 1, 0, 0, 1, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 0, 0, 1, 1, 1},
})
View Source
var DotsMaskLabyrinth = NewDotsMask([][]uint8{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 1},
{1, 0, 1, 0, 0, 0, 1, 1, 0, 1},
{1, 0, 1, 1, 1, 0, 1, 0, 0, 1},
{0, 0, 1, 0, 1, 0, 1, 1, 1, 1},
{0, 0, 1, 0, 0, 0, 0, 0, 1, 0},
{1, 0, 1, 0, 1, 0, 1, 0, 0, 0},
{1, 0, 1, 0, 1, 0, 1, 1, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
})
View Source
var DotsMaskSquare2x2 = NewDotsMask([][]uint8{
{1, 1},
{1, 1},
})
View Source
var DotsMaskTank = NewDotsMask([][]uint8{
{0, 1, 0},
{1, 1, 1},
{1, 0, 1},
})
View Source
var DotsMaskTunnel1 = NewDotsMask([][]uint8{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1},
})
View Source
var DotsMaskTunnel2 = NewDotsMask([][]uint8{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
})
Functions ¶
func ValidDirection ¶
ValidDirection returns true if passed direction is valid
Types ¶
type Area ¶
type Area struct {
// contains filtered or unexported fields
}
func NewUsefulArea ¶
func (Area) ContainsDot ¶
func (Area) ContainsLocation ¶
func (Area) ContainsRect ¶
func (Area) MarshalJSON ¶
Implementing json.Marshaler interface
func (Area) Navigate ¶
Navigate calculates and returns dot placed on distance dis dots from passed dot in direction dir
func (Area) NewRandomDot ¶
NewRandomDot generates random dot on area with starting coordinates X and Y
type Direction ¶
type Direction uint8
Direction indicates movement direction
func CalculateDirection ¶
CalculateDirection calculates direction by two passed dots
func (Direction) MarshalJSON ¶
Implementing json.Marshaler interface
type Dot ¶
func (Dot) DistanceTo ¶
DistanceTo calculates distance between two dots
func (Dot) MarshalJSON ¶
Implementing json.Marshaler interface
type DotsMask ¶
type DotsMask struct {
// contains filtered or unexported fields
}
func LocationToDotsMask ¶
func NewDotsMask ¶
func NewZeroDotsMask ¶
func (*DotsMask) TurnRandom ¶
type ErrAreaNotContainsDot ¶
type ErrAreaNotContainsDot struct {
Dot Dot
}
func (*ErrAreaNotContainsDot) Error ¶
func (e *ErrAreaNotContainsDot) Error() string
type ErrDirectionMarshal ¶
type ErrDirectionMarshal struct {
Err error
}
func (*ErrDirectionMarshal) Error ¶
func (e *ErrDirectionMarshal) Error() string
type ErrInvalidAreaSize ¶
func (*ErrInvalidAreaSize) Error ¶
func (e *ErrInvalidAreaSize) Error() string
type ErrInvalidDirection ¶
type ErrInvalidDirection struct {
Direction Direction
}
func (*ErrInvalidDirection) Error ¶
func (e *ErrInvalidDirection) Error() string
type ErrNavigation ¶
type ErrNavigation struct {
}func (*ErrNavigation) Error ¶
func (e *ErrNavigation) Error() string
type ErrReverseDirection ¶
type ErrReverseDirection struct {
Err error
}
func (ErrReverseDirection) Error ¶
func (e ErrReverseDirection) Error() string
type Location ¶
type Location []Dot
Location is set of dots
func HashToLocation ¶
func (Location) Difference ¶
func (Location) EqualsStrict ¶
func (Location) Intersection ¶
type Rect ¶
type Rect struct {
// contains filtered or unexported fields
}
func (Rect) ContainsDot ¶
func (Rect) ContainsRect ¶
func (Rect) MarshalJSON ¶
Implementing json.Marshaler interface
Click to show internal directories.
Click to hide internal directories.