position

package
v0.0.0-...-831597a Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CastlingRights

type CastlingRights []ColorSide

CastlingRights is a slice of color sides available for castling.

type ColorSide

type ColorSide uint8

ColorSide represents chess board's queen and king sides for each color.

const (
	ColorSideNil ColorSide = iota
	ColorSideBlackKing
	ColorSideBlackQueen
	ColorSideWhiteKing
	ColorSideWhiteQueen
)

func NewColorSideFromFEN

func NewColorSideFromFEN(fen string) (ColorSide, error)

NewColorSideFromFEN parses FEN to corresponding ColorSide.

FEN argument examples: "k", "q", "K", "Q".

func (ColorSide) String

func (colorSide ColorSide) String() string

String returns string representation of current color side.

type Position

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

Position represents the state of the game at a certain point in time.

func NewPosition

func NewPosition(
	board *Board,
	activeColor Color,
	castlingRights CastlingRights,
	enPassantSquare Square,
	halfMoveClock uint8,
	fullMoveNumber uint16,
) *Position

NewPosition creates a new position with passed parameters.

func NewPositionFromFEN

func NewPositionFromFEN(fen string) (*Position, error)

NewPositionFromFEN parses FEN to the Position structure.

FEN argument example: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1".

func NewPositionStart

func NewPositionStart() (*Position, error)

NewPositionStart creates game start position.

func (*Position) DeepCopy

func (position *Position) DeepCopy() (*Position, error)

Copy deeply copies current position.

func (*Position) MoveRaw

func (position *Position) MoveRaw(move Move) error

MoveRaw makes a raw move in the current position.

Note that the move is raw, so it can, for example, put the active color in check.

TODO: test.

Jump to

Keyboard shortcuts

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