board

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

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

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

Documentation

Index

Constants

View Source
const (
	Left  Move = "left"
	Right      = "right"
	Up         = "up"
	Down       = "down"
)
View Source
const DOUBLE_STACK_PART uint8 = 0x02
View Source
const EMPTY uint8 = 0x05
View Source
const FOOD uint8 = 0x04
View Source
const IS_HAZARD uint8 = 0x10
View Source
const KIND_MASK uint8 = 0x07
View Source
const MeId = SnakeId(1)
View Source
const SNAKE_BODY_PART uint8 = 0x01
View Source
const SNAKE_HEAD uint8 = 0x06
View Source
const TRIPLE_STACK_PART uint8 = 0x03

Variables

This section is empty.

Functions

func CartesianProduct

func CartesianProduct(movesA [][]SnakeMove, movesB []SnakeMove) [][]SnakeMove

func GetCartesianProductOfMoves

func GetCartesianProductOfMoves(board *FastBoard) [][]SnakeMove

func IndexInDirection

func IndexInDirection(m Move, cur uint16, width, height uint16, isWrapped bool) uint16

func MovesToMap

func MovesToMap(moves []SnakeMove) map[SnakeId]Move

func Shuffle

func Shuffle[T any](arr []T) []T

func Voronoi

func Voronoi(game *FastBoard, player SnakeId) voronoiResult

func Voronoi2

func Voronoi2(game *FastBoard, maxId, minId SnakeId) voronoiResult

Types

type FastBoard

type FastBoard struct {
	List      []Tile
	Ids       idsMap
	Heads     headsMap
	Lengths   lengthsMap
	Healths   healthsMap
	Width     uint16
	Height    uint16
	IsWrapped bool
	// contains filtered or unexported fields
}

func BuildBoard

func BuildBoard(state b.GameState) FastBoard

func (*FastBoard) AdvanceBoard

func (b *FastBoard) AdvanceBoard(moves map[SnakeId]Move)

func (*FastBoard) Clone

func (b *FastBoard) Clone() FastBoard

func (*FastBoard) GetAllFood

func (b *FastBoard) GetAllFood() []uint16

func (*FastBoard) GetHazardNeighbors

func (b *FastBoard) GetHazardNeighbors(index uint16) []uint16

func (*FastBoard) GetLastMove

func (b *FastBoard) GetLastMove(id SnakeId) Move

func (*FastBoard) GetMovesForSnake

func (b *FastBoard) GetMovesForSnake(id SnakeId) []SnakeMove

func (*FastBoard) GetMovesForSnakeNoDefault

func (b *FastBoard) GetMovesForSnakeNoDefault(id SnakeId) []SnakeMove

func (*FastBoard) GetNeighborIndices

func (b *FastBoard) GetNeighborIndices(index uint16) []uint16

func (*FastBoard) GetNeighbors

func (b *FastBoard) GetNeighbors(index uint16) []Move

func (*FastBoard) GetNeighborsUnsafe

func (b *FastBoard) GetNeighborsUnsafe(index uint16) []Move

func (*FastBoard) GetOtherLivingSnakes

func (b *FastBoard) GetOtherLivingSnakes() []SnakeId

func (*FastBoard) GetSnakeIdAtTile

func (b *FastBoard) GetSnakeIdAtTile(index uint16) (SnakeId, bool)

func (*FastBoard) GetSnakeNeck

func (b *FastBoard) GetSnakeNeck(id SnakeId) uint16

func (*FastBoard) GetSnakeTail

func (b *FastBoard) GetSnakeTail(id SnakeId) uint16

func (*FastBoard) IndexInDirection

func (b *FastBoard) IndexInDirection(move Move, current uint16) uint16

func (*FastBoard) IsGameOver

func (b *FastBoard) IsGameOver() bool

func (*FastBoard) IsSnakeAlive

func (b *FastBoard) IsSnakeAlive(id SnakeId) bool

func (*FastBoard) IsTileFood

func (b *FastBoard) IsTileFood(index uint16) bool

func (*FastBoard) IsTileSnakeHead

func (b *FastBoard) IsTileSnakeHead(index uint16) bool

func (*FastBoard) MoveToIndex

func (b *FastBoard) MoveToIndex(move SnakeMove) uint16

func (*FastBoard) Print

func (b *FastBoard) Print()

func (*FastBoard) RemoveSnake

func (b *FastBoard) RemoveSnake(id SnakeId)

type Move

type Move string

type Point

type Point struct {
	X int8
	Y int8
}

func IndexToPoint

func IndexToPoint(index uint16, width uint16) Point

type SnakeId

type SnakeId uint16

type SnakeMove

type SnakeMove struct {
	Id  SnakeId
	Dir Move
}

type Tile

type Tile struct {
	// contains filtered or unexported fields
}

func CreateBodyTile

func CreateBodyTile(id SnakeId, nextIdx uint16) Tile

func CreateDoubleStackTile

func CreateDoubleStackTile(id SnakeId, nextIdx uint16) Tile

func CreateEmptyTile

func CreateEmptyTile() Tile

func CreateHeadTile

func CreateHeadTile(id SnakeId, tailIdx uint16) Tile

func CreateTripleStackTile

func CreateTripleStackTile(id SnakeId) Tile

func (*Tile) Clear

func (t *Tile) Clear()

func (*Tile) ClearHazard

func (t *Tile) ClearHazard()

func (*Tile) GetIdx

func (t *Tile) GetIdx() uint16

func (*Tile) GetSnakeId

func (t *Tile) GetSnakeId() (SnakeId, bool)

func (*Tile) IsDoubleStack

func (t *Tile) IsDoubleStack() bool

func (*Tile) IsEmpty

func (t *Tile) IsEmpty() bool

func (*Tile) IsFood

func (t *Tile) IsFood() bool

func (*Tile) IsHazard

func (t *Tile) IsHazard() bool

func (*Tile) IsNonHeadSegment

func (t *Tile) IsNonHeadSegment() bool

func (*Tile) IsSnakeBody

func (t *Tile) IsSnakeBody() bool

func (*Tile) IsSnakeBodyPart

func (t *Tile) IsSnakeBodyPart() bool

func (*Tile) IsSnakeHead

func (t *Tile) IsSnakeHead() bool

SNAKE RELATED

func (*Tile) IsSnakeSegment

func (t *Tile) IsSnakeSegment() bool

func (*Tile) IsStacked

func (t *Tile) IsStacked() bool

func (*Tile) IsTripleStack

func (t *Tile) IsTripleStack() bool

func (*Tile) SetBodyPart

func (t *Tile) SetBodyPart(id SnakeId, nextIdx uint16)

func (*Tile) SetDoubleStack

func (t *Tile) SetDoubleStack(id SnakeId, nextIdx uint16)

func (*Tile) SetFood

func (t *Tile) SetFood()

func (*Tile) SetHazard

func (t *Tile) SetHazard()

func (*Tile) SetHead

func (t *Tile) SetHead(id SnakeId, tailIdx uint16)

func (*Tile) SetTripleStack

func (t *Tile) SetTripleStack(id SnakeId)

Jump to

Keyboard shortcuts

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