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
50
51
52
53
54
55
56
57
58
59
60
61
62
//! A Rust library providing a highly configurable and efficient
//! Monte Carlo Tree Search (MCTS) implementation.
//!
//! This library supports various game types and integrates with external
//! game evaluators for flexible AI development. It includes both
//! single-instance and batch-processing capabilities for MCTS.
//!
//! # Modules
//! - `tree`: Implements the core tree data structure used by MCTS.
//! - `game`: Defines traits for game logic and state evaluation.
//! - `mcts`: Provides the single-instance MCTS algorithm.
//! - `mcts_batch`: Offers an MCTS implementation capable of processing multiple
//! game instances in parallel for increased throughput.
//! - `utils`: Contains general utility functions.
//! - `test_utils`: Provides helper implementations for testing the MCTS algorithms.
//!
//! # Examples
//! ```rust
//! use simple_mcts::{Mcts, test_utils::{GameTest, GameEvaluatorTest2}, MctsError};
//!
//! fn main() -> Result<(), MctsError> {
//! let mut mcts: Mcts<GameTest, 4> = Mcts::<GameTest, 4>::new();
//! let evaluator = GameEvaluatorTest2::new();
//!
//! // Perform 100 MCTS iterations
//! for _ in 0..100 {
//! mcts.iterate(&evaluator)?;
//! }
//!
//! // Get the best action based on visit counts
//! let (score, policy) = mcts.get_result();
//! println!("Best action score: {}, Policy: {:?}", score, policy);
//!
//! // Play the best action and update the MCTS tree
//! let best_action_index = policy.iter()
//! .enumerate()
//! .max_by(|(_, &a), (_, &b)| a.partial_cmp(&b).unwrap())
//! .map(|(index, _)| index)
//! .unwrap_or(0); // Default to first action if policy is empty
//! mcts.play(best_action_index)?;
//!
//! // Continue with the next game state
//! Ok(())
//! }
//! ```
//!
//! This library aims to be a robust foundation for AI development in board games,
//! particularly those benefiting from tree search algorithms like AlphaZero.
use *;
pub use *;
pub use *;
pub use *;