chess

package
v0.0.0-...-6828d5b Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicPiece

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

func (*BasicPiece) CanMoveTo

func (b *BasicPiece) CanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*BasicPiece) PostCanMoveTo

func (b *BasicPiece) PostCanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*BasicPiece) SetSide

func (b *BasicPiece) SetSide(side Side)

func (*BasicPiece) Side

func (b *BasicPiece) Side() Side

type Bishop

type Bishop struct {
	BasicPiece
}

func (*Bishop) CanMoveTo

func (b *Bishop) CanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*Bishop) Type

func (b *Bishop) Type() PieceType

type Board

type Board struct {
	Pieces [8][8]Piece
	Turn   Side

	Checkmate bool
	Check     bool
}

func NewBoard

func NewBoard() *Board

func (*Board) IsCheckMate

func (b *Board) IsCheckMate() CheckMateResult

func (*Board) IsPosCheck

func (b *Board) IsPosCheck(side Side, kingPos Pos) bool

func (*Board) Move

func (b *Board) Move(start Pos, end Pos)

func (*Board) NextTurn

func (b *Board) NextTurn()

func (*Board) Piece

func (b *Board) Piece(pos Pos) Piece

type CheckMateResult

type CheckMateResult int
const (
	CheckMateNone CheckMateResult = iota
	CheckMateCheck
	CheckMateCheckMate
)

type King

type King struct {
	BasicPiece
}

func (*King) CanMoveTo

func (k *King) CanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*King) Type

func (k *King) Type() PieceType

type Knight

type Knight struct {
	BasicPiece
}

func (*Knight) CanMoveTo

func (k *Knight) CanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*Knight) Type

func (k *Knight) Type() PieceType

type Pawn

type Pawn struct {
	BasicPiece
}

func (*Pawn) CanMoveTo

func (p *Pawn) CanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*Pawn) Type

func (p *Pawn) Type() PieceType

type Piece

type Piece interface {
	SetSide(side Side)
	Side() Side
	CanMoveTo(board *Board, currPos Pos, newPos Pos) bool
	Type() PieceType
}

type PieceType

type PieceType int
const (
	PAWN PieceType = iota
	KNIGHT
	BISHOP
	ROOK
	QUEEN
	KING
)

type Pos

type Pos struct {
	Row int
	Col int
}

func (*Pos) Sub

func (p *Pos) Sub(p2 Pos) Pos

type Queen

type Queen struct {
	BasicPiece
}

func (*Queen) CanMoveTo

func (q *Queen) CanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*Queen) Type

func (q *Queen) Type() PieceType

type Rook

type Rook struct {
	BasicPiece
}

func (*Rook) CanMoveTo

func (r *Rook) CanMoveTo(board *Board, currPos Pos, newPos Pos) bool

func (*Rook) Type

func (r *Rook) Type() PieceType

type Side

type Side int
const (
	WHITE Side = iota // White at 0, black at 8
	BLACK
)

Jump to

Keyboard shortcuts

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