battle

package
v0.0.0-...-3f73ffe Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Battle

type Battle struct {
	White   EnginePool
	Black   EnginePool
	Book    opening.Book
	Options Options
}

func (*Battle) Do

func (b *Battle) Do(ctx context.Context, watcher Watcher) (*GameExt, Warnings, error)

type EnginePool

type EnginePool interface {
	AcquireEngine(ctx context.Context) (*uci.Engine, error)
	ReleaseEngine(e *uci.Engine)
	Name() string
	Close()
}

func NewEnginePool

func NewEnginePool(ctx context.Context, log *slog.Logger, o EnginePoolOptions) (EnginePool, error)

type EnginePoolOptions

type EnginePoolOptions struct {
	ShortName     string
	ExeName       string
	Args          []string
	Options       map[string]uci.OptValue
	EngineOptions uci.EngineOptions
	CreateTimeout maybe.Maybe[time.Duration]
}

func (EnginePoolOptions) Clone

func (*EnginePoolOptions) FillDefaults

func (o *EnginePoolOptions) FillDefaults()

type GameExt

type GameExt struct {
	Game        *chess.Game
	Scores      []maybe.Maybe[uci.Score]
	WhiteName   string
	BlackName   string
	Round       int
	TimeControl maybe.Maybe[clock.Control]
	FixedTime   maybe.Maybe[time.Duration]
}

func (*GameExt) PGN

func (g *GameExt) PGN() (string, error)

func (*GameExt) SGS

func (g *GameExt) SGS() string

type Options

type Options struct {
	TimeControl maybe.Maybe[clock.Control]
	FixedTime   maybe.Maybe[time.Duration]

	DeadlineMargin   maybe.Maybe[time.Duration]
	MaxWaitGameStart maybe.Maybe[time.Duration]
	MaxWaitStop      maybe.Maybe[time.Duration]
	OutcomeFilter    maybe.Maybe[chess.VerdictFilter]

	// Terminate the game when both sides agree that one of them wins with Score >= ScoreThreshold.
	// Must be set to zero for no threshold.
	ScoreThreshold int32
}

func (Options) Clone

func (o Options) Clone() Options

func (*Options) FillDefaults

func (o *Options) FillDefaults()

type Warnings

type Warnings []string

type Watcher

type Watcher interface {
	OnGameInited(game *GameExt)
	OnGameUpdated(game *GameExt, clk maybe.Maybe[clock.Clock])
	OnGameFinished(game *GameExt, warn Warnings)
	OnEngineInfo(color chess.Color, status uci.SearchStatus)
}

Jump to

Keyboard shortcuts

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