victoria

package module
Version: v0.0.0-...-3491d9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 4 Imported by: 0

README

Victoria

(WIP) Chess engine

Documentation

Index

Constants

View Source
const (
	BoardGroupFileA = 72340172838076673
	BoardGroupFileB = 144680345676153346
	BoardGroupFileC = 289360691352306692
	BoardGroupFileD = 578721382704613384
	BoardGroupFileE = 1157442765409226768
	BoardGroupFileF = 2314885530818453536
	BoardGroupFileG = 4629771061636907072
	BoardGroupFileH = 9259542123273814144

	BoardGroupNotFileAB = BoardGroupFileC | BoardGroupFileD | BoardGroupFileE | BoardGroupFileF | BoardGroupFileG | BoardGroupFileH
	BoardGroupNotFileGH = BoardGroupFileA | BoardGroupFileB | BoardGroupFileC | BoardGroupFileD | BoardGroupFileE | BoardGroupFileF
)

Board files

View Source
const (
	PieceWhiteKingInitialPos   = 16
	PieceWhiteQueenInitialPos  = 8
	PieceWhiteRookInitialPos   = 129
	PieceWhiteBishopInitialPos = 36
	PieceWhiteKnightInitialPos = 66
	PieceWhitePawnInitialPos   = 65280

	PieceBlackKingInitialPos   = 1152921504606846976
	PieceBlackQueenInitialPos  = 576460752303423488
	PieceBlackRookInitialPos   = 9295429630892703744
	PieceBlackBishopInitialPos = 2594073385365405696
	PieceBlackKnightInitialPos = 4755801206503243776
	PieceBlackPawnInitialPos   = 71776119061217280
)

Caclculated initial 64-bit values for pieces

View Source
const (
	BoardSquareA1 = iota
	BoardSquareB1
	BoardSquareC1
	BoardSquareD1
	BoardSquareE1
	BoardSquareF1
	BoardSquareG1
	BoardSquareH1

	BoardSquareA2
	BoardSquareB2
	BoardSquareC2
	BoardSquareD2
	BoardSquareE2
	BoardSquareF2
	BoardSquareG2
	BoardSquareH2

	BoardSquareA3
	BoardSquareB3
	BoardSquareC3
	BoardSquareD3
	BoardSquareE3
	BoardSquareF3
	BoardSquareG3
	BoardSquareH3

	BoardSquareA4
	BoardSquareB4
	BoardSquareC4
	BoardSquareD4
	BoardSquareE4
	BoardSquareF4
	BoardSquareG4
	BoardSquareH4

	BoardSquareA5
	BoardSquareB5
	BoardSquareC5
	BoardSquareD5
	BoardSquareE5
	BoardSquareF5
	BoardSquareG5
	BoardSquareH5

	BoardSquareA6
	BoardSquareB6
	BoardSquareC6
	BoardSquareD6
	BoardSquareE6
	BoardSquareF6
	BoardSquareG6
	BoardSquareH6

	BoardSquareA7
	BoardSquareB7
	BoardSquareC7
	BoardSquareD7
	BoardSquareE7
	BoardSquareF7
	BoardSquareG7
	BoardSquareH7

	BoardSquareA8
	BoardSquareB8
	BoardSquareC8
	BoardSquareD8
	BoardSquareE8
	BoardSquareF8
	BoardSquareG8
	BoardSquareH8
)

Board location values

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Pieces []*Piece
}

Options are the options you can pass to New

type Piece

type Piece struct {
	Name, Color string
	// contains filtered or unexported fields
}

Piece represents a specific color and type of piece.

func NewPiece

func NewPiece(color, name string, squares ...uint64) *Piece

NewPiece creates a new piece

func NewPieceFromBits

func NewPieceFromBits(color, name string, bits uint64) *Piece

NewPieceFromBits creates a new piece from the specified bits

func (*Piece) Move

func (p *Piece) Move(state *State, from, to uint64) (string, error)

Move moves the piece from `from` to `to` based on state.

func (*Piece) String

func (p *Piece) String() string

type State

type State struct {
	// contains filtered or unexported fields
}

State represents the game state

func (*State) GetPiece

func (s *State) GetPiece(color, name string) *Piece

GetPiece returns a piece matching color and name

func (*State) String

func (s *State) String() string

type Victoria

type Victoria struct {
	State *State
}

Victoria represents the Chess engine

func New

func New(opts *Options) *Victoria

New creates a new instance of the engine with specified options

func (*Victoria) AddPiece

func (v *Victoria) AddPiece(piece *Piece)

AddPiece adds piece to the current engine state. If the specified color name and of piece already exists, it is overridden by the new piece.

func (*Victoria) RemovePiece

func (v *Victoria) RemovePiece(color, name string)

RemovePiece removes the piece with color name name from the board.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL