uci

package
v0.0.0-...-9a4bc7e Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package uci describes the Universal Chess Interface (UCI) protocol.

Index

Constants

View Source
const (
	ScoreTypeCentipawn = "cp"
	ScoreTypeMate      = "mate"
)

Score types used in ResponseInfo.

Variables

View Source
var ErrEngineClosed = errors.New("engine closed")

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// Do blocks until the request is completed or an error occurs.
	Do(req Request) error

	// Respond returns and consumes the oldest response from the engine.
	// It blocks until a response is available or an error occurs.
	Respond() (Response, error)

	// Close closes the engine. Any blocked Do or Respond calls will be
	// unblocked and return ErrEngineClosed.
	Close() error
}

type Request

type Request interface {
	encoding.TextUnmarshaler
}

A Request is a command sent from the client to the engine.

func Parse

func Parse(line string) (Request, error)

type RequestGo

type RequestGo struct {
	SearchMoves []string // Restrict search to these moves only. Ignore if empty.

	Ponder   bool // Search in pondering mode.
	Infinite bool // Search until interrupted.
	MoveTime int  // If > 0, search for this many milliseconds.

	WhiteTime      int // If > 0, white's remaining time in milliseconds.
	BlackTime      int // If > 0, black's remaining time in milliseconds.
	WhiteIncrement int // If > 0, white's increment in milliseconds.
	BlackIncrement int // If > 0, black's increment in milliseconds.

	Depth     int // If > 0, search this many plies only.
	Nodes     int // If > 0, search this many nodes only.
	Mate      int // If > 0, search for a mate in this many moves.
	MovesToGo int // If > 0, there are this many moves until the next time control.
}

RequestGo represents the "go" command.

func (*RequestGo) UnmarshalText

func (req *RequestGo) UnmarshalText(text []byte) error

type RequestIsReady

type RequestIsReady struct{}

RequestIsReady represents the "isready" command.

func (*RequestIsReady) UnmarshalText

func (req *RequestIsReady) UnmarshalText(text []byte) error

type RequestPosition

type RequestPosition struct {
	FEN   string
	Moves []string
}

RequestPosition represents the "position" command.

func (*RequestPosition) UnmarshalText

func (req *RequestPosition) UnmarshalText(text []byte) error

type RequestUCI

type RequestUCI struct{}

RequestUCI represents the "uci" command.

func (*RequestUCI) UnmarshalText

func (req *RequestUCI) UnmarshalText(text []byte) error

type Response

type Response interface {
	encoding.TextMarshaler
}

A Response is a command sent from the engine to the client.

type ResponseBestMove

type ResponseBestMove struct {
	Move   string
	Ponder string
}

ResponseBestMove represents the "bestmove" command.

func (ResponseBestMove) MarshalText

func (resp ResponseBestMove) MarshalText() ([]byte, error)

type ResponseID

type ResponseID struct {
	Name   string
	Author string
}

ResponseID represents the "id" command.

func (ResponseID) MarshalText

func (resp ResponseID) MarshalText() ([]byte, error)

type ResponseInfo

type ResponseInfo struct {
	Depth     int      // Search depth in plies.
	PV        []string // Moves in the principal variation.
	Score     int      // Score from the engine's point of view.
	ScoreType string   // Either ScoreTypeCentipawn or ScoreTypeMate.
}

ResponseInfo represents the "info" UCI command.

Jump to

Keyboard shortcuts

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