Documentation ¶
Index ¶
- Constants
- func CartesianProduct(movesA [][]SnakeMove, movesB []SnakeMove) [][]SnakeMove
- func GetCartesianProductOfMoves(board *FastBoard) [][]SnakeMove
- func IndexInDirection(m Move, cur uint16, width, height uint16, isWrapped bool) uint16
- func MovesToMap(moves []SnakeMove) map[SnakeId]Move
- func Shuffle[T any](arr []T) []T
- func Voronoi(game *FastBoard, player SnakeId) voronoiResult
- func Voronoi2(game *FastBoard, maxId, minId SnakeId) voronoiResult
- type FastBoard
- func (b *FastBoard) AdvanceBoard(moves map[SnakeId]Move)
- func (b *FastBoard) Clone() FastBoard
- func (b *FastBoard) GetAllFood() []uint16
- func (b *FastBoard) GetHazardNeighbors(index uint16) []uint16
- func (b *FastBoard) GetLastMove(id SnakeId) Move
- func (b *FastBoard) GetMovesForSnake(id SnakeId) []SnakeMove
- func (b *FastBoard) GetMovesForSnakeNoDefault(id SnakeId) []SnakeMove
- func (b *FastBoard) GetNeighborIndices(index uint16) []uint16
- func (b *FastBoard) GetNeighbors(index uint16) []Move
- func (b *FastBoard) GetNeighborsUnsafe(index uint16) []Move
- func (b *FastBoard) GetOtherLivingSnakes() []SnakeId
- func (b *FastBoard) GetSnakeIdAtTile(index uint16) (SnakeId, bool)
- func (b *FastBoard) GetSnakeNeck(id SnakeId) uint16
- func (b *FastBoard) GetSnakeTail(id SnakeId) uint16
- func (b *FastBoard) IndexInDirection(move Move, current uint16) uint16
- func (b *FastBoard) IsGameOver() bool
- func (b *FastBoard) IsSnakeAlive(id SnakeId) bool
- func (b *FastBoard) IsTileFood(index uint16) bool
- func (b *FastBoard) IsTileSnakeHead(index uint16) bool
- func (b *FastBoard) MoveToIndex(move SnakeMove) uint16
- func (b *FastBoard) Print()
- func (b *FastBoard) RemoveSnake(id SnakeId)
- type Move
- type Point
- type SnakeId
- type SnakeMove
- type Tile
- func (t *Tile) Clear()
- func (t *Tile) ClearHazard()
- func (t *Tile) GetIdx() uint16
- func (t *Tile) GetSnakeId() (SnakeId, bool)
- func (t *Tile) IsDoubleStack() bool
- func (t *Tile) IsEmpty() bool
- func (t *Tile) IsFood() bool
- func (t *Tile) IsHazard() bool
- func (t *Tile) IsNonHeadSegment() bool
- func (t *Tile) IsSnakeBody() bool
- func (t *Tile) IsSnakeBodyPart() bool
- func (t *Tile) IsSnakeHead() bool
- func (t *Tile) IsSnakeSegment() bool
- func (t *Tile) IsStacked() bool
- func (t *Tile) IsTripleStack() bool
- func (t *Tile) SetBodyPart(id SnakeId, nextIdx uint16)
- func (t *Tile) SetDoubleStack(id SnakeId, nextIdx uint16)
- func (t *Tile) SetFood()
- func (t *Tile) SetHazard()
- func (t *Tile) SetHead(id SnakeId, tailIdx uint16)
- func (t *Tile) SetTripleStack(id SnakeId)
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 IndexInDirection ¶
func MovesToMap ¶
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 (*FastBoard) AdvanceBoard ¶
func (*FastBoard) GetAllFood ¶
func (*FastBoard) GetHazardNeighbors ¶
func (*FastBoard) GetLastMove ¶
func (*FastBoard) GetMovesForSnake ¶
func (*FastBoard) GetMovesForSnakeNoDefault ¶
func (*FastBoard) GetNeighborIndices ¶
func (*FastBoard) GetNeighbors ¶
func (*FastBoard) GetNeighborsUnsafe ¶
func (*FastBoard) GetOtherLivingSnakes ¶
func (*FastBoard) GetSnakeIdAtTile ¶
func (*FastBoard) GetSnakeNeck ¶
func (*FastBoard) GetSnakeTail ¶
func (*FastBoard) IndexInDirection ¶
func (*FastBoard) IsGameOver ¶
func (*FastBoard) IsSnakeAlive ¶
func (*FastBoard) IsTileFood ¶
func (*FastBoard) IsTileSnakeHead ¶
func (*FastBoard) MoveToIndex ¶
func (*FastBoard) RemoveSnake ¶
type Point ¶
func IndexToPoint ¶
type Tile ¶
type Tile struct {
// contains filtered or unexported fields
}
func CreateBodyTile ¶
func CreateDoubleStackTile ¶
func CreateEmptyTile ¶
func CreateEmptyTile() Tile
func CreateHeadTile ¶
func CreateTripleStackTile ¶
func (*Tile) ClearHazard ¶
func (t *Tile) ClearHazard()
func (*Tile) GetSnakeId ¶
func (*Tile) IsDoubleStack ¶
func (*Tile) IsNonHeadSegment ¶
func (*Tile) IsSnakeBody ¶
func (*Tile) IsSnakeBodyPart ¶
func (*Tile) IsSnakeSegment ¶
func (*Tile) IsTripleStack ¶
func (*Tile) SetBodyPart ¶
func (*Tile) SetDoubleStack ¶
func (*Tile) SetTripleStack ¶
Click to show internal directories.
Click to hide internal directories.