1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Monte Carlo Tree Search implementation for code generation.
//!
//! # Overview
//!
//! MCTS is a heuristic search algorithm that builds a search tree iteratively
//! through four phases: Selection, Expansion, Simulation, and Backpropagation.
//!
//! For code generation:
//! - **State**: Partial AST (Abstract Syntax Tree)
//! - **Action**: Transform rules (e.g., add statement, wrap in loop)
//! - **Reward**: Compilation success (binary: 0 or 1)
//!
//! # Example
//!
//! ```rust
//! use entrenar::search::{MctsSearch, MctsConfig, State, Action};
//!
//! // Define your state and action spaces
//! #[derive(Clone, PartialEq, Eq, Hash)]
//! struct CodeState {
//! ast_tokens: Vec<String>,
//! }
//!
//! impl State for CodeState {
//! fn is_terminal(&self) -> bool {
//! self.ast_tokens.iter().any(|t| t == "EOF")
//! }
//! }
//!
//! // Create MCTS searcher with default config
//! let config = MctsConfig::default();
//! // let mcts = MctsSearch::new(initial_state, action_space, config);
//! ```
// Re-export all public types
pub use MctsConfig;
pub use ;
pub use ;
pub use ;
pub use SearchTree;
/// Type alias for reward values (typically 0.0 to 1.0)
pub type Reward = f64;