bitboard

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: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Left  Dir = "left"
	Right     = "right"
	Up        = "up"
	Down      = "down"
)

Variables

This section is empty.

Functions

func CartesianProduct

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

Types

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
	// contains filtered or unexported fields
}

func CreateBitBoard

func CreateBitBoard(state api.GameState) *BitBoard

func (*BitBoard) AdvanceTurn

func (bb *BitBoard) AdvanceTurn(moves []SnakeMove)

func (*BitBoard) Clone

func (bb *BitBoard) Clone() *BitBoard

func (*BitBoard) GetCartesianProductOfMoves

func (bb *BitBoard) GetCartesianProductOfMoves() [][]SnakeMove

func (*BitBoard) GetLastSnakeMoveFromExternal

func (bb *BitBoard) GetLastSnakeMoveFromExternal(snake api.Battlesnake) Dir

func (*BitBoard) GetMoves

func (bb *BitBoard) GetMoves(snakeId string) []SnakeMove

func (*BitBoard) GetOpponents

func (bb *BitBoard) GetOpponents() []*snake

func (*BitBoard) GetSnake

func (bb *BitBoard) GetSnake(id string) *snake

func (*BitBoard) GetZobristKey

func (bb *BitBoard) GetZobristKey(zh ZobristTable) Key

func (*BitBoard) InitializeZobristTable

func (bb *BitBoard) InitializeZobristTable() ZobristTable

func (*BitBoard) IsEqual

func (bb *BitBoard) IsEqual(board *BitBoard) bool

func (*BitBoard) IsGameOver

func (bb *BitBoard) IsGameOver() bool

func (*BitBoard) IsIndexFood

func (bb *BitBoard) IsIndexFood(i int) bool

func (*BitBoard) IsIndexHazard

func (bb *BitBoard) IsIndexHazard(i int) bool

func (*BitBoard) IsIndexOccupied

func (bb *BitBoard) IsIndexOccupied(i int) bool

func (*BitBoard) Print

func (bb *BitBoard) Print()

func (*BitBoard) RandomPlayout

func (bb *BitBoard) RandomPlayout(length int, rand *rand.Rand)

func (*BitBoard) SpawnFood

func (bb *BitBoard) SpawnFood()

func (*BitBoard) SpawnHazardsRoyale

func (bb *BitBoard) SpawnHazardsRoyale()

func (*BitBoard) Update

func (bb *BitBoard) Update(new *BitBoard)

updates without removing snakes

type Dir

type Dir string

type Key

type Key uint64

type SnakeMove

type SnakeMove struct {
	Id  string
	Dir Dir
}

type ZobristTable

type ZobristTable [][]Key

Jump to

Keyboard shortcuts

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