engine

package
v0.0.0-...-86aade9 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	White int8 = 1
	Black int8 = -1

	Empty int8 = 0

	Pawn   int8 = 1
	Knight int8 = 2
	Bishop int8 = 3
	Rook   int8 = 4
	Queen  int8 = 5
	King   int8 = 6

	WhitePawn   int8 = White * Pawn
	WhiteKnight int8 = White * Knight
	WhiteBishop int8 = White * Bishop
	WhiteRook   int8 = White * Rook
	WhiteQueen  int8 = White * Queen
	WhiteKing   int8 = White * King

	BlackPawn   int8 = Black * Pawn
	BlackKnight int8 = Black * Knight
	BlackBishop int8 = Black * Bishop
	BlackRook   int8 = Black * Rook
	BlackQueen  int8 = Black * Queen
	BlackKing   int8 = Black * King
)

Variables

View Source
var (
	SquareMap = map[Square]string{
		0x00: "a1", 0x01: "b1", 0x02: "c1", 0x03: "d1", 0x04: "e1", 0x05: "f1", 0x06: "g1", 0x07: "h1",
		0x10: "a2", 0x11: "b2", 0x12: "c2", 0x13: "d2", 0x14: "e2", 0x15: "f2", 0x16: "g2", 0x17: "h2",
		0x20: "a3", 0x21: "b3", 0x22: "c3", 0x23: "d3", 0x24: "e3", 0x25: "f3", 0x26: "g3", 0x27: "h3",
		0x30: "a4", 0x31: "b4", 0x32: "c4", 0x33: "d4", 0x34: "e4", 0x35: "f4", 0x36: "g4", 0x37: "h4",
		0x40: "a5", 0x41: "b5", 0x42: "c5", 0x43: "d5", 0x44: "e5", 0x45: "f5", 0x46: "g5", 0x47: "h5",
		0x50: "a6", 0x51: "b6", 0x52: "c6", 0x53: "d6", 0x54: "e6", 0x55: "f6", 0x56: "g6", 0x57: "h6",
		0x60: "a7", 0x61: "b7", 0x62: "c7", 0x63: "d7", 0x64: "e7", 0x65: "f7", 0x66: "g7", 0x67: "h7",
		0x70: "a8", 0x71: "b8", 0x72: "c8", 0x73: "d8", 0x74: "e8", 0x75: "f8", 0x76: "g8", 0x77: "h8",
	}

	SquareLookup = map[string]Square{
		"a1": A1, "a2": A2, "a3": A3, "a4": A4, "a5": A5, "a6": A6, "a7": A7, "a8": A8,
		"b1": B1, "b2": B2, "b3": B3, "b4": B4, "b5": B5, "b6": B6, "b7": B7, "b8": B8,
		"c1": C1, "c2": C2, "c3": C3, "c4": C4, "c5": C5, "c6": C6, "c7": C7, "c8": C8,
		"d1": D1, "d2": D2, "d3": D3, "d4": D4, "d5": D5, "d6": D6, "d7": D7, "d8": D8,
		"e1": E1, "e2": E2, "e3": E3, "e4": E4, "e5": E5, "e6": E6, "e7": E7, "e8": E8,
		"f1": F1, "f2": F2, "f3": F3, "f4": F4, "f5": F5, "f6": F6, "f7": F7, "f8": F8,
		"g1": G1, "g2": G2, "g3": G3, "g4": G4, "g5": G5, "g6": G6, "g7": G7, "g8": G8,
		"h1": H1, "h2": H2, "h3": H3, "h4": H4, "h5": H5, "h6": H6, "h7": H7, "h8": H8,
	}
)

Functions

func Evaluate

func Evaluate(b *Board) int

Evaluate the score of a given board

func Perft

func Perft(fen string, expected []PerftData)

Perft runs a performance test against a given FEN and expected results

Types

type Board

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

Board represents a chessboard

func NewBoard

func NewBoard(fen string) *Board

NewBoard creates a new chessboard from given fen

func (*Board) MakeMove

func (b *Board) MakeMove(m Move)

MakeMove does a move on the board

func (*Board) UndoMove

func (b *Board) UndoMove()

UndoMove undoes the last move on the board

type Game

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

Game represents a gochess game

func NewGame

func NewGame() *Game

NewGame creates a new gochess game and returns a reference

func (*Game) Run

func (g *Game) Run()

Run a given game

type Generator

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

Generator creates possible moves for a given board position

func NewGenerator

func NewGenerator(board *Board) *Generator

NewGenerator creates a new generator for a given board

func (*Generator) CheckSimple

func (g *Generator) CheckSimple() bool

CheckSimple finds possible check attacks

func (*Generator) GenerateMoves

func (g *Generator) GenerateMoves() []Move

GenerateMoves creates a list of possible moves

type HistoryItem

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

HistoryItem chess move and flags

type Move

type Move struct {
	From       Square
	To         Square
	Special    int8
	MovedPiece int8
	Content    int8
	Promoted   int8
}

Move on the board representation

func Search(board *Board) Move

Search finds the best available move

func (Move) String

func (m Move) String() string

type PerftData

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

PerftData aggregates performance test data in a structure

type Square

type Square uint8
var (
	A1      Square = 0x00
	B1      Square = 0x01
	C1      Square = 0x02
	D1      Square = 0x03
	E1      Square = 0x04
	F1      Square = 0x05
	G1      Square = 0x06
	H1      Square = 0x07
	A2      Square = 0x10
	B2      Square = 0x11
	C2      Square = 0x12
	D2      Square = 0x13
	E2      Square = 0x14
	F2      Square = 0x15
	G2      Square = 0x16
	H2      Square = 0x17
	A3      Square = 0x20
	B3      Square = 0x21
	C3      Square = 0x22
	D3      Square = 0x23
	E3      Square = 0x24
	F3      Square = 0x25
	G3      Square = 0x26
	H3      Square = 0x27
	A4      Square = 0x30
	B4      Square = 0x31
	C4      Square = 0x32
	D4      Square = 0x33
	E4      Square = 0x34
	F4      Square = 0x35
	G4      Square = 0x36
	H4      Square = 0x37
	A5      Square = 0x40
	B5      Square = 0x41
	C5      Square = 0x42
	D5      Square = 0x43
	E5      Square = 0x44
	F5      Square = 0x45
	G5      Square = 0x46
	H5      Square = 0x47
	A6      Square = 0x50
	B6      Square = 0x51
	C6      Square = 0x52
	D6      Square = 0x53
	E6      Square = 0x54
	F6      Square = 0x55
	G6      Square = 0x56
	H6      Square = 0x57
	A7      Square = 0x60
	B7      Square = 0x61
	C7      Square = 0x62
	D7      Square = 0x63
	E7      Square = 0x64
	F7      Square = 0x65
	G7      Square = 0x66
	H7      Square = 0x67
	A8      Square = 0x70
	B8      Square = 0x71
	C8      Square = 0x72
	D8      Square = 0x73
	E8      Square = 0x74
	F8      Square = 0x75
	G8      Square = 0x76
	H8      Square = 0x77
	Invalid Square = 0x80
)

type ZobristTable

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

func NewZobristTable

func NewZobristTable() *ZobristTable

Jump to

Keyboard shortcuts

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