testing
This commit is contained in:
parent
d48670dbdb
commit
e8521ac96d
47
src/elo.rs
47
src/elo.rs
@ -17,16 +17,12 @@ pub fn run() {
|
|||||||
min_arena_depth: 14,
|
min_arena_depth: 14,
|
||||||
top_k_children: 2,
|
top_k_children: 2,
|
||||||
up_to_minus: 10,
|
up_to_minus: 10,
|
||||||
max_arena_size: usize::MAX,
|
max_arena_size: 1_000_000,
|
||||||
do_not_prune: true,
|
do_not_prune: true,
|
||||||
print: false,
|
print: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut arena = PlayerArena::new(vec![
|
let mut arena = PlayerArena::new(vec![
|
||||||
// (
|
|
||||||
// "RandomAgent".into(),
|
|
||||||
// Box::new(|piece| Box::new(RandomAgent::new(piece))),
|
|
||||||
// ),
|
|
||||||
(
|
(
|
||||||
"ComplexAgentD1".into(),
|
"ComplexAgentD1".into(),
|
||||||
Box::new(|piece| {
|
Box::new(|piece| {
|
||||||
@ -39,6 +35,18 @@ pub fn run() {
|
|||||||
))
|
))
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"ComplexAgentD2".into(),
|
||||||
|
Box::new(|piece| {
|
||||||
|
Box::new(ComplexAgent::new(
|
||||||
|
piece,
|
||||||
|
FutureMoveConfig {
|
||||||
|
max_depth: 2,
|
||||||
|
..FMV_BASE
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"ComplexAgentD3".into(),
|
"ComplexAgentD3".into(),
|
||||||
Box::new(|piece| {
|
Box::new(|piece| {
|
||||||
@ -52,24 +60,24 @@ pub fn run() {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"ComplexAgentD8".into(),
|
"ComplexAgentD4".into(),
|
||||||
Box::new(|piece| {
|
Box::new(|piece| {
|
||||||
Box::new(ComplexAgent::new(
|
Box::new(ComplexAgent::new(
|
||||||
piece,
|
piece,
|
||||||
FutureMoveConfig {
|
FutureMoveConfig {
|
||||||
max_depth: 8,
|
max_depth: 4,
|
||||||
..FMV_BASE
|
..FMV_BASE
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
// (
|
// (
|
||||||
// "ComplexAgent5M".into(),
|
// "ComplexAgentD8".into(),
|
||||||
// Box::new(|piece| {
|
// Box::new(|piece| {
|
||||||
// Box::new(ComplexAgent::new(
|
// Box::new(ComplexAgent::new(
|
||||||
// piece,
|
// piece,
|
||||||
// FutureMoveConfig {
|
// FutureMoveConfig {
|
||||||
// max_arena_size: 5_000_000,
|
// max_depth: 8,
|
||||||
// ..FMV_BASE
|
// ..FMV_BASE
|
||||||
// },
|
// },
|
||||||
// ))
|
// ))
|
||||||
@ -77,17 +85,9 @@ pub fn run() {
|
|||||||
// ),
|
// ),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// arena.play(
|
arena.prop_arena(1000);
|
||||||
// &(0..arena.players.len())
|
|
||||||
// .zip([0].into_iter().cycle())
|
|
||||||
// .filter(|(i, j)| i != j)
|
|
||||||
// .collect::<Vec<_>>()
|
|
||||||
// .repeat(1000),
|
|
||||||
// );
|
|
||||||
for _ in 0..10 {
|
|
||||||
arena.prop_arena(2);
|
|
||||||
println!("{}", arena);
|
println!("{}", arena);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PlayerArena {
|
pub struct PlayerArena {
|
||||||
@ -176,8 +176,13 @@ impl PlayerArena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn play_two_inner(player_1: Box<dyn Agent>, player_2: Box<dyn Agent>) -> Outcomes {
|
fn play_two_inner(player_1: Box<dyn Agent>, player_2: Box<dyn Agent>) -> Outcomes {
|
||||||
let result =
|
let result = GameInner::new(
|
||||||
GameInner::new(player_1, player_2, false, Board::random(5)).loop_until_result();
|
player_1,
|
||||||
|
player_2,
|
||||||
|
false,
|
||||||
|
Board::random(rand::random_range(3..8)),
|
||||||
|
)
|
||||||
|
.loop_until_result();
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Winner::Player(piece) => match piece {
|
Winner::Player(piece) => match piece {
|
||||||
|
|||||||
@ -123,13 +123,39 @@ impl FutureMoves {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.prune_bad_children();
|
self.prune_bad_children();
|
||||||
self.current_depth += 1;
|
|
||||||
if cf.is_break() {
|
if cf.is_break() {
|
||||||
|
// pruning unfinished level
|
||||||
|
let by_depth = self.by_depth(0..self.arena.len());
|
||||||
|
let mut bdh = HashMap::new();
|
||||||
|
for (a, b) in by_depth {
|
||||||
|
bdh.insert(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
for &i in bdh.get(&(self.current_depth + 1)).unwrap_or(&Vec::new()) {
|
||||||
|
self.remove(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for &i in bdh.get(&self.current_depth).unwrap_or(&Vec::new()) {
|
||||||
|
self.arena[i].tried_children = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.refocus_tree();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
self.current_depth += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove(&mut self, index: usize) {
|
||||||
|
if let Some(parent) = self.arena[index].parent {
|
||||||
|
self.arena[parent].children.retain(|&j| j != index);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.arena[index].parent = None;
|
||||||
|
}
|
||||||
|
|
||||||
/// Determines if a [`Move`] at index `idx` is connected to `self.current_root`
|
/// Determines if a [`Move`] at index `idx` is connected to `self.current_root`
|
||||||
/// Returns `false` if `self.current_root` is None
|
/// Returns `false` if `self.current_root` is None
|
||||||
fn is_connected_to_root(&self, idx: usize) -> bool {
|
fn is_connected_to_root(&self, idx: usize) -> bool {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user