Documentation
¶
Index ¶
- Constants
- Variables
- func BFS(board *BitBoard, startIndex int, testerFn func(int) bool) int
- func CartesianProduct(movesA [][]SnakeMoveSet, movesB []SnakeMoveSet) [][]SnakeMoveSet
- type BasicStateWeights
- type BitBoard
- func (bb *BitBoard) AdvanceTurn(allMoves []SnakeMoveSet)
- func (bb *BitBoard) AreaControlScore(snakeId string) float64
- func (bb *BitBoard) BasicStateScore(snakeId string, depth int, weights BasicStateWeights) float64
- func (bb *BitBoard) Clone() *BitBoard
- func (bb *BitBoard) FoodScore(snakeId string) float64
- func (bb *BitBoard) GetCartesianProductOfMoves() [][]SnakeMoveSet
- func (bb *BitBoard) GetLastSnakeMoveFromExternal(snake api.Battlesnake) Dir
- func (bb *BitBoard) GetMoves(snakeId string) SnakeMoveSet
- func (bb *BitBoard) GetMovesNoDefault(snakeId string) SnakeMoveSet
- func (bb *BitBoard) GetNeighbors(index int) moveset.MoveSet
- func (bb *BitBoard) GetOpponents() []*snake
- func (bb *BitBoard) GetSnake(id string) *snake
- func (bb *BitBoard) GetZobristKey(zh ZobristTable) Key
- func (bb *BitBoard) InitializeZobristTable() ZobristTable
- func (bb *BitBoard) IsEqual(board *BitBoard) bool
- func (bb *BitBoard) IsGameOver() bool
- func (bb *BitBoard) IsIndexFood(i int) bool
- func (bb *BitBoard) IsIndexHazard(i int) bool
- func (bb *BitBoard) IsIndexOccupied(i int) bool
- func (bb *BitBoard) IsSnakeAlive(id string) bool
- func (bb *BitBoard) IsSnakeOnWall(snakeId string) bool
- func (bb *BitBoard) KillScore(snakeId string) float64
- func (bb *BitBoard) Print()
- func (bb *BitBoard) RandomMove(snakeId string, rand *rand.Rand) SnakeMoveSet
- func (bb *BitBoard) RandomPlayout(length int, rand *rand.Rand)
- func (bb *BitBoard) RandomPlayoutMonte(length int, rand *rand.Rand) Dir
- func (bb *BitBoard) SpawnFood()
- func (bb *BitBoard) SpawnHazardsRoyale()
- func (bb *BitBoard) SplitMoves(mset SnakeMoveSet) []SnakeMoveSet
- func (bb *BitBoard) TailPathScore(snakeId string) float64
- func (bb *BitBoard) Update(new *BitBoard)
- func (bb *BitBoard) Voronoi() VoronoiResult
- type Dir
- type Key
- type SnakeMove
- type SnakeMoveSet
- type VoronoiResult
- type ZobristTable
Constants ¶
View Source
const ( Left Dir = "left" Right = "right" Up = "up" Down = "down" )
Variables ¶
View Source
var BOTTOM_MASK = num.U128FromRaw(
0b0000000000000000000000000000000000000000000000000000000000000000,
0b0000000000000000000000000000000000000000000000000000011111111111,
)
View Source
var LEFT_MASK = num.U128FromRaw(
0b0000000000000000010000000000100000000001000000000010000000000100,
0b0000000010000000000100000000001000000000010000000000100000000001,
)
View Source
var RIGHT_MASK = num.U128FromRaw(
0b0000000100000000001000000000010000000000100000000001000000000010,
0b0000000001000000000010000000000100000000001000000000010000000000,
)
View Source
var TOP_MASK = num.U128FromRaw(
0b1111111111111111110000000000000000000000000000000000000000000000,
0b0000000000000000000000000000000000000000000000000000000000000000,
)
This is the 11 most sig bits + 7 unused bits
Functions ¶
func CartesianProduct ¶
func CartesianProduct(movesA [][]SnakeMoveSet, movesB []SnakeMoveSet) [][]SnakeMoveSet
Types ¶
type BasicStateWeights ¶
type BitBoard ¶
type BitBoard struct { // I need to makes Snakes a map so that I can remove snakes when they die. // Currently, removing a snake from the array could cause the ids of other snakes to change, since it's an array. // By converting to a map, I can just use the ID from the API // This way, when a snake dies and the API does not send that snake in the request, the state will match up with what I have in my tree since it is also being removed Snakes map[string]*snake Turn int ShouldSpawnFood bool // contains filtered or unexported fields }
func CreateBitBoard ¶
func (*BitBoard) AdvanceTurn ¶
func (bb *BitBoard) AdvanceTurn(allMoves []SnakeMoveSet)
func (*BitBoard) AreaControlScore ¶
func (*BitBoard) BasicStateScore ¶
func (bb *BitBoard) BasicStateScore(snakeId string, depth int, weights BasicStateWeights) float64
TODO: factor in depth for use during tree search
func (*BitBoard) GetCartesianProductOfMoves ¶
func (bb *BitBoard) GetCartesianProductOfMoves() [][]SnakeMoveSet
func (*BitBoard) GetLastSnakeMoveFromExternal ¶
func (bb *BitBoard) GetLastSnakeMoveFromExternal(snake api.Battlesnake) Dir
func (*BitBoard) GetMoves ¶
func (bb *BitBoard) GetMoves(snakeId string) SnakeMoveSet
func (*BitBoard) GetMovesNoDefault ¶
func (bb *BitBoard) GetMovesNoDefault(snakeId string) SnakeMoveSet
func (*BitBoard) GetOpponents ¶
func (bb *BitBoard) GetOpponents() []*snake
func (*BitBoard) GetZobristKey ¶
func (bb *BitBoard) GetZobristKey(zh ZobristTable) Key
func (*BitBoard) InitializeZobristTable ¶
func (bb *BitBoard) InitializeZobristTable() ZobristTable
func (*BitBoard) IsGameOver ¶
func (*BitBoard) IsIndexFood ¶
func (*BitBoard) IsIndexHazard ¶
func (*BitBoard) IsIndexOccupied ¶
func (*BitBoard) IsSnakeAlive ¶
func (*BitBoard) IsSnakeOnWall ¶
func (*BitBoard) RandomMove ¶
func (bb *BitBoard) RandomMove(snakeId string, rand *rand.Rand) SnakeMoveSet
func (*BitBoard) RandomPlayoutMonte ¶
func (*BitBoard) SpawnHazardsRoyale ¶
func (bb *BitBoard) SpawnHazardsRoyale()
func (*BitBoard) SplitMoves ¶
func (bb *BitBoard) SplitMoves(mset SnakeMoveSet) []SnakeMoveSet
func (*BitBoard) TailPathScore ¶
func (*BitBoard) Voronoi ¶
func (bb *BitBoard) Voronoi() VoronoiResult
type Dir ¶
type Dir string
func MoveSetToDir ¶
returns the Dir version ("left", "right", "up", "down") of the moveset. If more than one is set, it returns the first found in the order displayed above.
type SnakeMoveSet ¶
func SplitSnakeMoveSet ¶
func SplitSnakeMoveSet(moves SnakeMoveSet) []SnakeMoveSet
type VoronoiResult ¶
type ZobristTable ¶
type ZobristTable [][]Key
Click to show internal directories.
Click to hide internal directories.