Documentation
¶
Overview ¶
Package stockpile provides fast lookups into pre-computed chess position evaluations from the Lichess database.
Example usage:
client, err := stockpile.New(
stockpile.WithDataDir("/path/to/data"),
)
if err != nil {
log.Fatal(err)
}
defer client.Close()
eval, err := client.Lookup(ctx, "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Evaluation: %s\n", eval.Score())
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound indicates the position was not found in the database. ErrNotFound = errors.New("stockpile: position not found") // ErrClosed indicates the client has been closed. ErrClosed = errors.New("stockpile: client closed") // ErrNoStore indicates no store was provided. ErrNoStore = errors.New("stockpile: no store provided") )
Sentinel errors for well-defined error conditions.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides access to the Lichess evaluation database. A Client is safe for concurrent use by multiple goroutines.
func New ¶
New creates a new Client with the given options. If no options are provided, sensible defaults are used.
func (*Client) Close ¶
Close releases all resources associated with the client. After Close, the client should not be used.
func (*Client) Lookup ¶
Lookup returns the evaluation for a given FEN position. Returns ErrNotFound if the position is not in the database.
func (*Client) ShardStrategy ¶
ShardStrategy returns the sharding strategy used by this client.
type Eval ¶
type Eval struct {
// FEN is the position in Forsyth-Edwards Notation.
FEN string
// Depth is the search depth used to compute this evaluation.
Depth int
// Knodes is the number of kilo-nodes searched.
Knodes int
// PVs contains all principal variations from multi-PV analysis.
// The first PV is the best line.
PVs []PV
}
Eval represents a chess position evaluation from the Lichess database.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures a Client.
func WithDataDir ¶
WithDataDir configures the client from a data directory. It reads the manifest.json to auto-configure shard count and strategy, and creates a disk-based store with zstd compression. This is the recommended way to create a client for local data.
func WithLogger ¶
WithLogger sets the logger. If not set, a no-op logger is used.
func WithShardStrategy ¶
WithShardStrategy sets the sharding strategy to use. If not set, material-based sharding is used.
func WithTotalShards ¶
WithTotalShards sets the total number of shards. Default is 32768 (2^15).
type PV ¶
type PV struct {
// Centipawns is the evaluation in centipawns from White's perspective.
// Positive values favor White, negative values favor Black.
// Nil if the position has a forced mate.
Centipawns *int
// Mate is the number of moves until checkmate.
// Positive values mean White delivers mate, negative means Black.
// Nil if there is no forced mate.
Mate *int
// Line is the sequence of moves in UCI notation.
Line string
}
PV represents a principal variation (line of play) from the engine.
Directories
¶
| Path | Synopsis |
|---|---|
|
benchmark
|
|
|
analysis
Package analysis provides statistical analysis for benchmark results.
|
Package analysis provides statistical analysis for benchmark results. |
|
pgn
Package pgn provides utilities for extracting FEN positions from PGN files.
|
Package pgn provides utilities for extracting FEN positions from PGN files. |
|
reporting
Package reporting provides report generation for benchmark results.
|
Package reporting provides report generation for benchmark results. |
|
simulation
Package simulation provides tools for simulating shard access patterns.
|
Package simulation provides tools for simulating shard access patterns. |
|
cmd
|
|
|
analyze-games
command
Command analyze-games analyzes positions from a PGN file using stockpile.
|
Command analyze-games analyzes positions from a PGN file using stockpile. |
|
stockpile
command
Package main provides the stockpile CLI tool for managing and querying chess position evaluations from the Lichess database.
|
Package main provides the stockpile CLI tool for managing and querying chess position evaluations from the Lichess database. |
|
stockpile-bench
command
Package main provides the stockpile-bench CLI tool for benchmarking sharding strategies with real game data.
|
Package main provides the stockpile-bench CLI tool for benchmarking sharding strategies with real game data. |
|
examples
|
|
|
benchmark-demo
command
Package main demonstrates benchmarking sharding strategies with the stockpile library.
|
Package main demonstrates benchmarking sharding strategies with the stockpile library. |
|
game-analysis
command
Package main demonstrates analyzing a chess game with stockpile.
|
Package main demonstrates analyzing a chess game with stockpile. |
|
quickstart
command
Package main demonstrates basic stockpile usage.
|
Package main demonstrates basic stockpile usage. |
|
fx
|
|
|
diskstockpilefx
Package diskstockpilefx provides an fx module for a disk-backed stockpile client.
|
Package diskstockpilefx provides an fx module for a disk-backed stockpile client. |
|
gcpstockpilefx
Package gcpstockpilefx provides an fx module for a GCS-backed stockpile client.
|
Package gcpstockpilefx provides an fx module for a GCS-backed stockpile client. |
|
memorystockpilefx
Package memorystockpilefx provides an fx module for an in-memory stockpile client.
|
Package memorystockpilefx provides an fx module for an in-memory stockpile client. |
|
internal
|
|
|
builder
Package builder implements the data build pipeline for stockpile.
|
Package builder implements the data build pipeline for stockpile. |
|
codec
Package codec provides compression and decompression for shard data.
|
Package codec provides compression and decompression for shard data. |
|
codec/gzipcodec
Package gzipcodec provides a gzip compression codec.
|
Package gzipcodec provides a gzip compression codec. |
|
codec/noopcodec
Package noopcodec provides a no-op codec (no compression).
|
Package noopcodec provides a no-op codec (no compression). |
|
codec/zstdcodec
Package zstdcodec provides a zstd compression codec.
|
Package zstdcodec provides a zstd compression codec. |
|
fen
Package fen provides FEN (Forsyth-Edwards Notation) parsing utilities.
|
Package fen provides FEN (Forsyth-Edwards Notation) parsing utilities. |
|
search
Package search implements binary search within sorted shard data.
|
Package search implements binary search within sorted shard data. |
|
shard
Package shard defines the sharding strategy interface for distributing chess positions across multiple shard files.
|
Package shard defines the sharding strategy interface for distributing chess positions across multiple shard files. |
|
shard/fnvshard
Package fnvshard implements FNV-1a hash-based sharding for chess positions.
|
Package fnvshard implements FNV-1a hash-based sharding for chess positions. |
|
shard/materialshard
Package materialshard implements material-based sharding for chess positions.
|
Package materialshard implements material-based sharding for chess positions. |
|
stats
Package stats provides a unified interface for collecting metrics.
|
Package stats provides a unified interface for collecting metrics. |
|
stats/logger
Package logger provides a zap-based stats collector that logs metrics.
|
Package logger provides a zap-based stats collector that logs metrics. |
|
stats/prometheus
Package prometheus provides a Prometheus-based stats collector.
|
Package prometheus provides a Prometheus-based stats collector. |
|
store
Package store defines the storage backend interface for reading shard files.
|
Package store defines the storage backend interface for reading shard files. |
|
store/cachedstore
Package cachedstore provides a caching wrapper for Store implementations.
|
Package cachedstore provides a caching wrapper for Store implementations. |
|
store/cachedstore/cachestrategy
Package cachestrategy defines cache eviction strategy interfaces.
|
Package cachestrategy defines cache eviction strategy interfaces. |
|
store/cachedstore/cachestrategy/lru
Package lru implements an LRU cache eviction strategy.
|
Package lru implements an LRU cache eviction strategy. |
|
store/cachedstore/memory
Package memory implements an in-memory cache backend.
|
Package memory implements an in-memory cache backend. |
|
store/diskcache
Package diskcache implements a disk-based cache that wraps a remote store.
|
Package diskcache implements a disk-based cache that wraps a remote store. |
|
store/diskstore
Package diskstore implements a disk-based filesystem storage backend.
|
Package diskstore implements a disk-based filesystem storage backend. |
|
store/gcsstore
Package gcsstore implements a Google Cloud Storage backend.
|
Package gcsstore implements a Google Cloud Storage backend. |
|
store/memstore
Package memstore provides an in-memory store implementation for testing.
|
Package memstore provides an in-memory store implementation for testing. |
|
store/s3store
Package s3store implements an AWS S3 storage backend.
|
Package s3store implements an AWS S3 storage backend. |