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 Voronoi(game *FastBoard, player SnakeId) voronoiResult
- type Battlesnake
- type BattlesnakeInfoResponse
- type BattlesnakeMoveResponse
- type Board
- type Coord
- type Customizations
- type FastBoard
- func (b *FastBoard) AdvanceBoard(moves map[SnakeId]Move)
- func (b *FastBoard) AdvanceBoardTB(move SnakeMove)
- func (b *FastBoard) Clone() FastBoard
- func (b *FastBoard) GetMovesForSnake(id SnakeId) []SnakeMove
- func (b *FastBoard) GetMovesForSnakeNoDefault(id SnakeId) []SnakeMove
- func (b *FastBoard) GetMovesForSnakeTB(id SnakeId) []SnakeMove
- func (b *FastBoard) GetNeighbors(index uint16) []Move
- func (b *FastBoard) GetNeighborsTB(index uint16) []Move
- func (b *FastBoard) IsGameOver() bool
- func (b *FastBoard) IsSnakeAlive(id SnakeId) bool
- func (b *FastBoard) IsTileFood(index uint16) bool
- func (b *FastBoard) Print()
- func (b *FastBoard) RandomRollout()
- func (b *FastBoard) RandomRolloutTB()
- type Game
- type GameState
- type Move
- type Point
- type Royale
- type Ruleset
- type Settings
- type SnakeId
- type SnakeMove
- type Squad
- 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) IsHeadTail() 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) SetBodyTail(bodyId SnakeId, bodyTail uint16, tailId SnakeId, bodyNext 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) SetHeadTail(headSnakeId SnakeId, headSnakeTail uint16, tailSnakeId SnakeId, ...)
- 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 ¶
Types ¶
type Battlesnake ¶
type Battlesnake struct { ID string `json:"id"` Name string `json:"name"` Health int32 `json:"health"` Body []Coord `json:"body"` Head Coord `json:"head"` Length int32 `json:"length"` Latency string `json:"latency"` Customizations Customizations `json:"customizations"` // Used in non-standard game modes Shout string `json:"shout"` Squad string `json:"squad"` }
type BattlesnakeInfoResponse ¶
type BattlesnakeMoveResponse ¶
type Board ¶
type Board struct { Height int `json:"height"` Width int `json:"width"` Food []Coord `json:"food"` Snakes []Battlesnake `json:"snakes"` // Used in non-standard game modes Hazards []Coord `json:"hazards"` }
type Customizations ¶
type FastBoard ¶
type FastBoard struct { List []Tile Heads headsMap Lengths lengthsMap Healths healthsMap Width uint16 Height uint16 // contains filtered or unexported fields }
func BuildBoard ¶
func (*FastBoard) AdvanceBoard ¶
func (*FastBoard) AdvanceBoardTB ¶
Advances the board, for use with a turn based board
func (*FastBoard) GetMovesForSnake ¶
func (*FastBoard) GetMovesForSnakeNoDefault ¶
func (*FastBoard) GetMovesForSnakeTB ¶
Gets moves for a particular snake, for use with a turn based board Will return an empty array if there are no possible moves
func (*FastBoard) GetNeighbors ¶
func (*FastBoard) GetNeighborsTB ¶
Gets neighboring tiles, for use with a turn based board Does not return tiles that are off the board, insta kill hazards, and snake bodies
func (*FastBoard) IsGameOver ¶
func (*FastBoard) IsSnakeAlive ¶
func (*FastBoard) IsTileFood ¶
func (*FastBoard) RandomRollout ¶
func (b *FastBoard) RandomRollout()
func (*FastBoard) RandomRolloutTB ¶
func (b *FastBoard) RandomRolloutTB()
Runs a random game till completion, for use with a turn based board
type GameState ¶
type GameState struct { Game Game `json:"game"` Turn int `json:"turn"` Board Board `json:"board"` You Battlesnake `json:"you"` }
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) IsHeadTail ¶
func (*Tile) IsNonHeadSegment ¶
func (*Tile) IsSnakeBody ¶
func (*Tile) IsSnakeBodyPart ¶
func (*Tile) IsSnakeSegment ¶
func (*Tile) IsTripleStack ¶
func (*Tile) SetBodyPart ¶
func (*Tile) SetBodyTail ¶
func (*Tile) SetDoubleStack ¶
func (*Tile) SetHeadTail ¶
func (*Tile) SetTripleStack ¶
Click to show internal directories.
Click to hide internal directories.