Documentation ¶
Index ¶
- Variables
- func ValidDirection(dir Direction) bool
- type Area
- func (a Area) Contains(dot Dot) bool
- 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) Width() uint8
- type Direction
- type Dot
- type ErrAreaNotContainsDot
- type ErrDelete
- type ErrDirectionMarshal
- type ErrDotsOccupied
- type ErrInvalidAreaSize
- type ErrInvalidDirection
- type ErrLocate
- type ErrLocated
- type ErrNavigation
- type ErrNotLocated
- type ErrRelocate
- type ErrRelocateAvailableDots
- 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 (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
- type Scene
- func (s *Scene) Delete(location Location) *ErrDelete
- func (s *Scene) DotOccupied(dot Dot) bool
- func (s *Scene) GetLocationByDot(dot Dot) Location
- func (s *Scene) Height() uint8
- func (s *Scene) Locate(location Location) *ErrLocate
- func (s *Scene) LocateAvailableDots(location Location) Location
- func (s *Scene) LocateRandomDot() (Location, error)
- func (s *Scene) LocateRandomRect(rw, rh uint8) (Location, error)
- func (s *Scene) LocateRandomRectMargin(rw, rh, margin uint8) (Location, error)
- func (s *Scene) Located(location Location) bool
- func (s *Scene) Navigate(dot Dot, dir Direction, dis uint8) (Dot, error)
- func (s *Scene) Relocate(old, new Location) *ErrRelocate
- func (s *Scene) RelocateAvailableDots(old, new Location) (Location, *ErrRelocateAvailableDots)
- func (s *Scene) Size() uint16
- func (s *Scene) Width() uint8
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRetriesLimit = errors.New("retries limit was reached")
View Source
var FindRetriesNumber = 32
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) 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 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 ErrDotsOccupied ¶
type ErrDotsOccupied struct {
Dots []Dot // List of occupied dots
}
func (*ErrDotsOccupied) Error ¶
func (e *ErrDotsOccupied) 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 ErrLocated ¶
type ErrLocated struct {
Location Location
}
func (*ErrLocated) Error ¶
func (e *ErrLocated) Error() string
type ErrNavigation ¶
type ErrNavigation struct {
}func (*ErrNavigation) Error ¶
func (e *ErrNavigation) Error() string
type ErrNotLocated ¶
type ErrNotLocated struct {
Location Location
}
func (*ErrNotLocated) Error ¶
func (e *ErrNotLocated) Error() string
type ErrRelocate ¶
type ErrRelocate struct {
Err error
}
func (*ErrRelocate) Error ¶
func (e *ErrRelocate) Error() string
type ErrRelocateAvailableDots ¶
type ErrRelocateAvailableDots struct {
Err error
}
func (*ErrRelocateAvailableDots) Error ¶
func (e *ErrRelocateAvailableDots) 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 (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
type Scene ¶
type Scene struct {
// contains filtered or unexported fields
}
Scene contains locations
func (*Scene) Delete ¶
Delete deletes passed location from scene and returns error if there is a problem
func (*Scene) DotOccupied ¶
func (*Scene) GetLocationByDot ¶
func (*Scene) LocateAvailableDots ¶
func (*Scene) LocateRandomDot ¶
func (*Scene) LocateRandomRectMargin ¶
func (*Scene) Relocate ¶
func (s *Scene) Relocate(old, new Location) *ErrRelocate
func (*Scene) RelocateAvailableDots ¶
func (s *Scene) RelocateAvailableDots(old, new Location) (Location, *ErrRelocateAvailableDots)
Click to show internal directories.
Click to hide internal directories.