alloc test
This commit is contained in:
44
src/allocs.rs
Normal file
44
src/allocs.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use crate::{
|
||||
logic::{ChildrenEvalMethod, FutureMoveConfig, FutureMoves},
|
||||
repr::{Board, Piece, Winner},
|
||||
};
|
||||
use allocative::FlameGraphBuilder;
|
||||
use rand::seq::IteratorRandom;
|
||||
|
||||
pub fn run() {
|
||||
let mut flamegraph = FlameGraphBuilder::default();
|
||||
let mut fut = FutureMoves::new(
|
||||
Piece::Black,
|
||||
FutureMoveConfig {
|
||||
max_depth: 20,
|
||||
min_arena_depth: 14,
|
||||
top_k_children: 2,
|
||||
up_to_minus: 10,
|
||||
max_arena_size: 100_000_000,
|
||||
do_prune: true,
|
||||
print: true,
|
||||
children_eval_method: ChildrenEvalMethod::AverageDivDepth,
|
||||
},
|
||||
);
|
||||
|
||||
let mut board = Board::new().starting_pos();
|
||||
let mut rng = rand::rng();
|
||||
let mut i = 0;
|
||||
while board.game_winner() == Winner::None && i < 2 {
|
||||
fut.update_from_board(&board);
|
||||
flamegraph.visit_root(&fut);
|
||||
fut.generate();
|
||||
flamegraph.visit_root(&fut);
|
||||
|
||||
if let Some(m) = fut.best_move().expect("FutureMoves has no move?") {
|
||||
board.place(m, Piece::Black).expect("failed move");
|
||||
}
|
||||
|
||||
if let Some(m) = board.possible_moves(Piece::White).choose(&mut rng) {
|
||||
board.place(m, Piece::White).expect("enemy failed move");
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
println!("{}", flamegraph.finish_and_write_flame_graph());
|
||||
}
|
||||
Reference in New Issue
Block a user