Newer
Older
use crate::{choices::Choice, scorers::Score, thinker::ActionEnt};
#[typetag::serde]
pub trait Picker: std::fmt::Debug + Sync + Send {
fn pick(&self, _choices: &[Choice], _utilities: &Query<&Score>) -> Option<ActionEnt>;
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct FirstToScore {
pub threshold: f32,
}
#[typetag::serde]
impl Picker for FirstToScore {
fn pick(&self, choices: &[Choice], utilities: &Query<&Score>) -> Option<ActionEnt> {
for choice in choices {
let value = choice.calculate(utilities);
if value >= self.threshold {