Struct ChessVectorEngine

Source
pub struct ChessVectorEngine { /* private fields */ }
Expand description

Chess Vector Engine - Production-ready chess engine with hybrid evaluation

A powerful chess engine that combines vector-based pattern recognition with advanced tactical search and NNUE neural network evaluation. Features an open-core architecture with runtime license verification for premium capabilities.

§Core Capabilities

  • Position Encoding: Convert chess positions to 1024-dimensional vectors
  • Similarity Search: Find similar positions using cosine similarity
  • Tactical Search: Advanced 6-14+ ply search with PVS and sophisticated pruning
  • Opening Book: Fast lookup for 50+ openings with ECO codes
  • NNUE Evaluation: Neural network position assessment (Premium+)
  • GPU Acceleration: CUDA/Metal/CPU with automatic device detection (Premium+)
  • UCI Protocol: Complete UCI engine implementation

§Feature Tiers

  • Open Source: Basic functionality, 6-ply search, similarity search, opening book
  • Premium: GPU acceleration, NNUE networks, 10+ ply search, multi-threading
  • Enterprise: Distributed training, unlimited positions, enterprise analytics

§Examples

§Basic Usage

use chess_vector_engine::ChessVectorEngine;
use chess::Board;

let mut engine = ChessVectorEngine::new(1024);
let board = Board::default();

// Add position with evaluation
engine.add_position(&board, 0.0);

// Find similar positions
let similar = engine.find_similar_positions(&board, 5);

§With Premium Features

use chess_vector_engine::{ChessVectorEngine, FeatureTier};

// Create engine with premium features (requires license)
let mut engine = ChessVectorEngine::new_with_tier(1024, FeatureTier::Premium);

// Check GPU acceleration availability  
let _gpu_status = engine.check_gpu_acceleration();

// Premium features are now available (with valid license)
println!("Engine created with premium tier access");

Implementations§

Source§

impl ChessVectorEngine

Source

pub fn new(vector_size: usize) -> Self

Create a new chess vector engine

Source

pub fn new_with_tier(vector_size: usize, tier: FeatureTier) -> Self

Create new engine with specific feature tier

Source

pub fn get_feature_tier(&self) -> &FeatureTier

Get current feature tier

Source

pub fn upgrade_tier(&mut self, new_tier: FeatureTier)

Upgrade feature tier (for license activation)

Source

pub fn is_feature_available(&self, feature: &str) -> bool

Check if a feature is available

Source

pub fn require_feature(&self, feature: &str) -> Result<(), FeatureError>

Require a feature (returns error if not available)

Source

pub fn new_adaptive( vector_size: usize, expected_positions: usize, use_case: &str, ) -> Self

Create a new chess vector engine with intelligent architecture selection based on expected dataset size and use case

Source

pub fn new_with_lsh( vector_size: usize, num_tables: usize, hash_size: usize, ) -> Self

Create a new chess vector engine with LSH enabled

Source

pub fn enable_lsh(&mut self, num_tables: usize, hash_size: usize)

Enable LSH indexing

Source

pub fn add_position(&mut self, board: &Board, evaluation: f32)

Add a position with its evaluation to the knowledge base

Source

pub fn find_similar_positions( &self, board: &Board, k: usize, ) -> Vec<(Array1<f32>, f32, f32)>

Find similar positions to the given board

Source

pub fn find_similar_positions_with_indices( &self, board: &Board, k: usize, ) -> Vec<(usize, f32, f32)>

Find similar positions with indices for move recommendation

Source

pub fn evaluate_position(&mut self, board: &Board) -> Option<f32>

Get evaluation for a position using hybrid approach (opening book + pattern evaluation + tactical search)

Source

pub fn encode_position(&self, board: &Board) -> Array1<f32>

Encode a position to vector (public interface)

Source

pub fn calculate_similarity(&self, board1: &Board, board2: &Board) -> f32

Calculate similarity between two boards

Source

pub fn knowledge_base_size(&self) -> usize

Get the size of the knowledge base

Source

pub fn save_training_data<P: AsRef<Path>>( &self, path: P, ) -> Result<(), Box<dyn Error>>

Save engine state (positions and evaluations) to file for incremental training

Source

pub fn load_training_data_incremental<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Load training data incrementally (append to existing engine state) - OPTIMIZED

Source

pub fn save_training_data_binary<P: AsRef<Path>>( &self, path: P, ) -> Result<(), Box<dyn Error>>

Save training data in optimized binary format with compression (5-15x faster than JSON)

Source

pub fn load_training_data_binary<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Load training data from optimized binary format (5-15x faster than JSON)

Source

pub fn load_training_data_mmap<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Ultra-fast memory-mapped loading for instant startup Uses memory-mapped files to load training data with zero-copy access (PREMIUM FEATURE)

Source

pub fn load_training_data_msgpack<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Ultra-fast MessagePack binary format loading MessagePack is typically 10-20% faster than bincode

Source

pub fn load_training_data_streaming_json<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Ultra-fast streaming JSON loader with parallel processing Processes JSON in chunks with multiple threads for better performance

Source

pub fn load_training_data_compressed<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Ultra-fast compressed loading with zstd Zstd typically provides better compression ratios than LZ4 with similar speed

Source

pub fn train_from_dataset_incremental(&mut self, dataset: &TrainingDataset)

Train from dataset incrementally (preserves existing engine state)

Source

pub fn training_stats(&self) -> TrainingStats

Get current training statistics

Source

pub fn auto_load_training_data(&mut self) -> Result<Vec<String>, Box<dyn Error>>

Auto-load training data from common file names if they exist

Source

pub fn load_lichess_puzzles_premium<P: AsRef<Path>>( &mut self, csv_path: P, ) -> Result<(), Box<dyn Error>>

Load Lichess puzzle database with premium features (Premium+)

Source

pub fn load_lichess_puzzles_basic<P: AsRef<Path>>( &mut self, csv_path: P, max_puzzles: usize, ) -> Result<(), Box<dyn Error>>

Load limited Lichess puzzle database (Open Source)

Source

pub fn new_with_auto_load(vector_size: usize) -> Result<Self, Box<dyn Error>>

Create a new chess vector engine with automatic training data loading

Source

pub fn new_with_fast_load(vector_size: usize) -> Result<Self, Box<dyn Error>>

Create a new chess vector engine with fast loading optimized for gameplay Prioritizes binary formats and skips expensive model rebuilding

Source

pub fn new_with_auto_discovery( vector_size: usize, ) -> Result<Self, Box<dyn Error>>

Create a new engine with automatic file discovery and smart format selection Automatically discovers training data files and loads the optimal format

Source

pub fn new_with_instant_load(vector_size: usize) -> Result<Self, Box<dyn Error>>

Ultra-fast instant loading - loads best available format without consolidation This is the fastest possible loading method for production use

Source

pub fn new_with_license(vector_size: usize, license_url: String) -> Self

Create engine with license verification system

Source

pub fn new_with_offline_license(vector_size: usize) -> Self

Create engine with offline license verification

Source

pub async fn activate_license( &mut self, key: &str, ) -> Result<FeatureTier, LicenseError>

Activate license key

Source

pub async fn check_licensed_feature( &mut self, feature: &str, ) -> Result<(), FeatureError>

Check if feature is licensed (async version with license verification)

Source

pub fn load_license_cache<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Load license cache from disk

Source

pub fn save_license_cache<P: AsRef<Path>>( &self, path: P, ) -> Result<(), Box<dyn Error>>

Save license cache to disk

Source

pub fn check_gpu_acceleration(&self) -> Result<(), Box<dyn Error>>

Check if GPU acceleration feature is available

Source

pub fn load_starter_dataset(&mut self) -> Result<(), Box<dyn Error>>

Load starter dataset for open source users

Source

pub fn ultra_fast_load_any_format<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Ultra-fast loader for any format - optimized for massive datasets (PREMIUM FEATURE)

Source

pub fn load_training_data_streaming_binary<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Ultra-fast streaming binary loader for massive datasets (900k+ positions) Uses streaming processing to handle arbitrarily large datasets

Source

pub fn load_training_data_streaming_json_v2<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), Box<dyn Error>>

Ultra-fast streaming JSON loader for massive datasets (900k+ positions) Uses streaming processing with minimal memory footprint

Source

pub fn new_for_massive_datasets( vector_size: usize, ) -> Result<Self, Box<dyn Error>>

Create engine optimized for massive datasets (100k-1M+ positions) Uses streaming loading and minimal memory footprint

Source

pub fn convert_to_msgpack() -> Result<(), Box<dyn Error>>

Convert existing JSON training data to ultra-fast MessagePack format MessagePack is typically 10-20% faster than bincode with smaller file sizes

Source

pub fn convert_a100_binary_to_json() -> Result<(), Box<dyn Error>>

Convert A100 binary training data to JSON format for use with other converters

Source

pub fn convert_to_zstd() -> Result<(), Box<dyn Error>>

Convert existing training data to ultra-compressed Zstd format Zstd provides excellent compression with fast decompression

Source

pub fn convert_to_mmap() -> Result<(), Box<dyn Error>>

Convert existing training data to memory-mapped format for instant loading This creates a file that can be loaded with zero-copy access

Source

pub fn convert_json_to_binary() -> Result<Vec<String>, Box<dyn Error>>

Convert existing JSON training files to binary format for faster loading

Source

pub fn is_lsh_enabled(&self) -> bool

Check if LSH is enabled

Source

pub fn lsh_stats(&self) -> Option<LSHStats>

Get LSH statistics if enabled

Source

pub fn enable_manifold_learning( &mut self, compression_ratio: f32, ) -> Result<(), String>

Enable manifold learning with specified compression ratio

Source

pub fn train_manifold_learning(&mut self, epochs: usize) -> Result<(), String>

Train manifold learning on existing positions

Source

pub fn enable_manifold_lsh( &mut self, num_tables: usize, hash_size: usize, ) -> Result<(), String>

Enable LSH for manifold space

Source

pub fn is_manifold_enabled(&self) -> bool

Check if manifold learning is enabled and trained

Source

pub fn manifold_compression_ratio(&self) -> Option<f32>

Get manifold learning compression ratio

Source

pub fn load_manifold_models(&mut self) -> Result<(), Box<dyn Error>>

Load pre-trained manifold models from database This enables compressed similarity search without retraining

Source

pub fn enable_opening_book(&mut self)

Enable opening book with standard openings

Source

pub fn set_opening_book(&mut self, book: OpeningBook)

Set custom opening book

Source

pub fn is_opening_position(&self, board: &Board) -> bool

Check if position is in opening book

Source

pub fn get_opening_entry(&self, board: &Board) -> Option<&OpeningEntry>

Get opening book entry for position

Source

pub fn opening_book_stats(&self) -> Option<OpeningBookStats>

Get opening book statistics

Source

pub fn add_position_with_move( &mut self, board: &Board, evaluation: f32, chess_move: Option<ChessMove>, move_outcome: Option<f32>, )

Add a move played from a position with its outcome

Source

pub fn recommend_moves( &mut self, board: &Board, num_recommendations: usize, ) -> Vec<MoveRecommendation>

Get move recommendations based on similar positions and opening book

Generate legal move recommendations (filters recommendations by legal moves)

Source

pub fn enable_persistence<P: AsRef<Path>>( &mut self, db_path: P, ) -> Result<(), Box<dyn Error>>

Enable persistence with database

Source

pub fn save_to_database(&self) -> Result<(), Box<dyn Error>>

Save engine state to database using high-performance batch operations

Source

pub fn load_from_database(&mut self) -> Result<(), Box<dyn Error>>

Load engine state from database

Source

pub fn new_with_persistence<P: AsRef<Path>>( vector_size: usize, db_path: P, ) -> Result<Self, Box<dyn Error>>

Create engine with persistence enabled and auto-load from database

Source

pub fn auto_save(&self) -> Result<(), Box<dyn Error>>

Auto-save to database (if persistence is enabled)

Source

pub fn is_persistence_enabled(&self) -> bool

Check if persistence is enabled

Source

pub fn database_position_count(&self) -> Result<i64, Box<dyn Error>>

Get database position count

Enable tactical search with the given configuration

Source

pub fn enable_tactical_search_default(&mut self)

Enable tactical search with default configuration

Source

pub fn configure_hybrid_evaluation(&mut self, config: HybridConfig)

Configure hybrid evaluation settings

Source

pub fn is_tactical_search_enabled(&self) -> bool

Check if tactical search is enabled

Enable parallel tactical search with specified number of threads

Source

pub fn is_parallel_search_enabled(&self) -> bool

Check if parallel search is enabled

Source

pub fn hybrid_config(&self) -> &HybridConfig

Get current hybrid configuration

Source

pub fn is_opening_book_enabled(&self) -> bool

Check if opening book is enabled

Source

pub fn self_play_training( &mut self, config: SelfPlayConfig, ) -> Result<usize, Box<dyn Error>>

Run self-play training to generate new positions

Source

pub fn continuous_self_play( &mut self, config: SelfPlayConfig, iterations: usize, save_path: Option<&str>, ) -> Result<usize, Box<dyn Error>>

Run continuous self-play training with periodic saving

Source

pub fn adaptive_self_play( &mut self, base_config: SelfPlayConfig, target_strength: f32, ) -> Result<usize, Box<dyn Error>>

Self-play with adaptive difficulty (engine gets stronger as it learns)

Trait Implementations§

Source§

impl Clone for ChessVectorEngine

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,