diff --git a/bot/src/evaluation/changed.rs b/bot/src/evaluation/changed.rs index 4041e9e..186319c 100644 --- a/bot/src/evaluation/changed.rs +++ b/bot/src/evaluation/changed.rs @@ -326,6 +326,10 @@ impl Evaluator for Standard { attack: if lock.placement_kind.is_clear() { lock.garbage_sent as i32 } else { -1 } }) } + + fn get_result(&self, v: &Self::Value) -> i32 { + v.value + } } /// Evaluates the bumpiness of the playfield. diff --git a/bot/src/evaluation/mod.rs b/bot/src/evaluation/mod.rs index 515b7ba..7055851 100644 --- a/bot/src/evaluation/mod.rs +++ b/bot/src/evaluation/mod.rs @@ -20,6 +20,8 @@ pub trait Evaluator : Send + Sync { ) -> MoveCandidate { candidates.into_iter().next().unwrap() } + + fn get_result(&self, v: &Self::Value) -> i32; } pub trait Evaluation : Eq + Ord + Default + Clone @@ -53,4 +55,8 @@ impl Evaluator for std::sync::Arc { ) -> MoveCandidate { (**self).pick_move(candidates, incoming) } + + fn get_result(&self, v: &Self::Value) -> i32 { + (**self).get_result(v) + } } \ No newline at end of file diff --git a/bot/src/evaluation/standard.rs b/bot/src/evaluation/standard.rs index 556faf4..05d2410 100644 --- a/bot/src/evaluation/standard.rs +++ b/bot/src/evaluation/standard.rs @@ -326,6 +326,10 @@ impl Evaluator for Standard { attack: if lock.placement_kind.is_clear() { lock.garbage_sent as i32 } else { -1 } }) } + + fn get_result(&self, v: &Self::Value) -> i32 { + v.value + } } /// Evaluates the bumpiness of the playfield. diff --git a/bot/src/lib.rs b/bot/src/lib.rs index e893609..b5e66b8 100644 --- a/bot/src/lib.rs +++ b/bot/src/lib.rs @@ -53,6 +53,7 @@ pub struct Info { pub nodes: u32, pub depth: u32, pub original_rank: u32, + pub evaluation_result: i32, pub plan: Vec<(FallingPiece, LockResult)> } diff --git a/bot/src/modes/normal.rs b/bot/src/modes/normal.rs index 1abaedb..ffa4da2 100644 --- a/bot/src/modes/normal.rs +++ b/bot/src/modes/normal.rs @@ -119,6 +119,7 @@ impl BotState { nodes: self.tree.nodes(), depth: self.tree.depth() as u32, original_rank: child.original_rank, + evaluation_result: eval.get_result(&child.evaluation), plan, }; diff --git a/bot/src/modes/pcloop.rs b/bot/src/modes/pcloop.rs index 4619be7..199d5b8 100644 --- a/bot/src/modes/pcloop.rs +++ b/bot/src/modes/pcloop.rs @@ -134,6 +134,7 @@ impl PcLooper { depth: self.current_pc.len() as u32 + 1, nodes: 0, original_rank: 0, + evaluation_result: self.current_pc.len() as i32, plan: vec![] }; info.plan.push((mv.expected_location, lock)); diff --git a/c-api/coldclear.h b/c-api/coldclear.h index 8bffda4..c0a4f1b 100644 --- a/c-api/coldclear.h +++ b/c-api/coldclear.h @@ -65,6 +65,11 @@ typedef struct CCMove { uint32_t nodes; uint32_t depth; uint32_t original_rank; + + /* In normal mode, this is the evaluation result. + * In PC loop mode, this is the remaining pieces to next pc + */ + int32_t evaluation_result; } CCMove; typedef struct CCOptions { diff --git a/c-api/src/lib.rs b/c-api/src/lib.rs index 8f816e9..380245b 100644 --- a/c-api/src/lib.rs +++ b/c-api/src/lib.rs @@ -98,6 +98,7 @@ struct CCMove { nodes: u32, depth: u32, original_rank: u32, + evaluation_result: i32, } #[repr(C)] @@ -325,6 +326,7 @@ fn convert(m: cold_clear::Move, info: cold_clear::Info) -> CCMove { nodes: info.nodes as u32, depth: info.depth as u32, original_rank: info.original_rank as u32, + evaluation_result: info.evaluation_result, } }