Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bot/src/evaluation/changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions bot/src/evaluation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub trait Evaluator : Send + Sync {
) -> MoveCandidate<Self::Value> {
candidates.into_iter().next().unwrap()
}

fn get_result(&self, v: &Self::Value) -> i32;
}

pub trait Evaluation<R> : Eq + Ord + Default + Clone
Expand Down Expand Up @@ -53,4 +55,8 @@ impl<T: Evaluator> Evaluator for std::sync::Arc<T> {
) -> MoveCandidate<Self::Value> {
(**self).pick_move(candidates, incoming)
}

fn get_result(&self, v: &Self::Value) -> i32 {
(**self).get_result(v)
}
}
4 changes: 4 additions & 0 deletions bot/src/evaluation/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions bot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>
}

Expand Down
1 change: 1 addition & 0 deletions bot/src/modes/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl<E: Evaluator> BotState<E> {
nodes: self.tree.nodes(),
depth: self.tree.depth() as u32,
original_rank: child.original_rank,
evaluation_result: eval.get_result(&child.evaluation),
plan,
};

Expand Down
1 change: 1 addition & 0 deletions bot/src/modes/pcloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions c-api/coldclear.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions c-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct CCMove {
nodes: u32,
depth: u32,
original_rank: u32,
evaluation_result: i32,
}

#[repr(C)]
Expand Down Expand Up @@ -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,
}
}

Expand Down