Documentation
¶
Overview ¶
This package implements a 10x10 bitboard for Amazons.
Index ¶
- Constants
- Variables
- func Coords(pos Position) (row, col int)
- type BitBoard
- func (a BitBoard) And(b BitBoard) BitBoard
- func (a BitBoard) AndNot(b BitBoard) BitBoard
- func (a *BitBoard) AssignAnd(b BitBoard)
- func (a *BitBoard) AssignAndNot(b BitBoard)
- func (a *BitBoard) AssignNot()
- func (a *BitBoard) AssignOr(b BitBoard)
- func (a *BitBoard) AssignXor(b BitBoard)
- func (bb BitBoard) Count() int
- func (bb *BitBoard) Empty() bool
- func (bb *BitBoard) Flag(pos Position)
- func (bb *BitBoard) Flagged(pos Position) bool
- func (bb *BitBoard) Lsb() Position
- func (bb *BitBoard) Msb() Position
- func (bb *BitBoard) Next() Position
- func (a BitBoard) Not() BitBoard
- func (bb *BitBoard) NotEmpty() bool
- func (a BitBoard) Or(b BitBoard) BitBoard
- func (bb *BitBoard) Unflag(pos Position)
- func (a BitBoard) Xor(b BitBoard) BitBoard
- type Position
Constants ¶
const ( W int = iota // West NW // Northwest N // North NE // Northeast E // East SE // Southeast S // South SW // Southwest )
const NUMBER_OF_DIRECTIONS = 8
If you want to iterate over all directions, you can iterate over range NUMBER_OF_DIRECTIONS.
Variables ¶
var KAdj = [100]BitBoard{}
For each position index p, KAdj[p] stores a precomputed bitboard that has each square q flagged if and only if a chess king on p could get to q in a single move.
var RayExc = [100][8]BitBoard{}
For each position index p and each direction d, RayExc[p][d] stores a precomputed bitboard such that each position is flagged if and only if it lies on a ray projected from p in the direction of d. This ray will exclude p (see RayInc for one that includes it).
var RayInc = [100][8]BitBoard{}
For each position index p and each direction d, RayInc[p][d] stores a precomputed bitboard such that each position is flagged if and only if it lies on a ray projected from p in the direction of d. This ray will include p (see RayExc for one that excludes it).
Functions ¶
Types ¶
type BitBoard ¶
type BitBoard struct {
// contains filtered or unexported fields
}
Represents a board where each position index (0-99, since Amazons is played on a 10x10 board) is either 0 or 1, which we refer to as "unflagged" and "flagged," respectively.
func (*BitBoard) AssignAndNot ¶
Performs a bitwise AND-NOT operation (a &^ b) and assigns the result to a.
func (*BitBoard) AssignNot ¶
func (a *BitBoard) AssignNot()
Performs a bitwise NOT operation (a ^ b) and assigns the result to a.
func (*BitBoard) Lsb ¶
Returns the greatest flagged position index on the board. If the board is empty, then the null position (NULL_POS) is returned.
func (*BitBoard) Msb ¶
Returns the position index of the most-significant bit in the board. If the board is empty, then the null position (NULL_POS) is returned .
func (*BitBoard) Next ¶
Returns the "lowest" position on the board, meaning that which is the closest to the bottom-right corner, and unflags it. If the bitboard is empty, then NULL_POS is returned.
type Position ¶
type Position uint8
Represents a position on the 10x10 Amazons board with an index from 0 to 99. We use row-major ordering, so you can get the row index with position / 10 and the column with position % 10.
const NULL_POS Position = 100
Represents a null position. I.e., for functions that return a position, the null position should be returned if no valid position exists.