diff --git a/src/evaluators.rs b/src/evaluators.rs index 8758544659c04809afce4e60eef805a3f4a4718f..1760d5ef7a32267324edfe381a102339ee6282a2 100644 --- a/src/evaluators.rs +++ b/src/evaluators.rs @@ -22,10 +22,10 @@ pub struct LinearEvaluator { impl LinearEvaluator { pub fn new() -> Self { - Self::new_full(0.0, 0.0, 100.0, 100.0) + Self::new_full(0.0, 0.0, 1.0, 1.0) } pub fn new_ranged(min: f32, max: f32) -> Self { - Self::new_full(min, 0.0, max, 100.0) + Self::new_full(min, 0.0, max, 1.0) } fn new_full(xa: f32, ya: f32, xb: f32, yb: f32) -> Self { Self { @@ -67,10 +67,10 @@ pub struct PowerEvaluator { impl PowerEvaluator { pub fn new(power: f32) -> Self { - Self::new_full(power, 0.0, 0.0, 100.0, 100.0) + Self::new_full(power, 0.0, 0.0, 1.0, 1.0) } pub fn new_ranged(power: f32, min: f32, max: f32) -> Self { - Self::new_full(power, min, 0.0, max, 100.0) + Self::new_full(power, min, 0.0, max, 1.0) } fn new_full(power: f32, xa: f32, ya: f32, xb: f32, yb: f32) -> Self { Self { @@ -115,11 +115,11 @@ pub struct SigmoidEvaluator { impl SigmoidEvaluator { pub fn new(k: f32) -> Self { - Self::new_full(k, 0.0, 0.0, 100.0, 100.0) + Self::new_full(k, 0.0, 0.0, 1.0, 1.0) } pub fn new_ranged(k: f32, min: f32, max: f32) -> Self { - Self::new_full(k, min, 0.0, max, 100.0) + Self::new_full(k, min, 0.0, max, 1.0) } fn new_full(k: f32, xa: f32, ya: f32, xb: f32, yb: f32) -> Self { diff --git a/src/pickers.rs b/src/pickers.rs index 3a39e47ac3ba8105eb3bef1140d89785367a1507..a83e160309a62b7627018de6f85c89ff835a5534 100644 --- a/src/pickers.rs +++ b/src/pickers.rs @@ -22,7 +22,7 @@ Picker that chooses the first `Choice` with a [`Score`] higher than its configur ```no_run Thinker::build() - .picker(FirstToScore::new(80.)) + .picker(FirstToScore::new(.8)) // .when(...) ``` */ diff --git a/src/scorers.rs b/src/scorers.rs index ba098f80dfb7cc4f7aaae3a4c1b11909b5c72364..39d2980a8167635ae9fb9305ac0a02b2b5b2942a 100644 --- a/src/scorers.rs +++ b/src/scorers.rs @@ -1,5 +1,5 @@ /*! -Scorers look at the world and boil down arbitrary characteristics into a range of 0.0..=100.0. This module includes the ScorerBuilder trait and some built-in Composite Scorers. +Scorers look at the world and boil down arbitrary characteristics into a range of 0.0..=1.0. This module includes the ScorerBuilder trait and some built-in Composite Scorers. */ use std::sync::Arc; @@ -9,7 +9,7 @@ use bevy::prelude::*; use crate::thinker::{Actor, ScorerEnt}; /** -Score value between `0.0..=100.0` associated with a Scorer. +Score value between `0.0..=1.0` associated with a Scorer. */ #[derive(Debug, Clone, Default)] pub struct Score(pub(crate) f32); @@ -26,11 +26,11 @@ impl Score { ### Panics - Panics if `value` isn't within `0.0..=100.0`. + Panics if `value` isn't within `0.0..=1.0`. */ pub fn set(&mut self, value: f32) { - if !(0.0..=100.0).contains(&value) { - panic!("Score value must be between 0.0 and 100.0"); + if !(0.0..=1.0).contains(&value) { + panic!("Score value must be between 0.0 and 1.0"); } self.0 = value; } @@ -150,7 +150,7 @@ pub fn all_or_nothing_system(query: Query<(Entity, &AllOrNothing)>, mut scores: } } let mut score = scores.get_mut(aon_ent).expect("where did it go?"); - score.set(crate::evaluators::clamp(sum, 0.0, 100.0)); + score.set(crate::evaluators::clamp(sum, 0.0, 1.0)); } } #[derive(Debug, Clone)] @@ -234,7 +234,7 @@ pub fn sum_of_scorers_system(query: Query<(Entity, &SumOfScorers)>, mut scores: sum = 0.0; } let mut score = scores.get_mut(sos_ent).expect("where did it go?"); - score.set(crate::evaluators::clamp(sum, 0.0, 100.0)); + score.set(crate::evaluators::clamp(sum, 0.0, 1.0)); } }