Trait emergent::consideration::Consideration
source · pub trait Consideration<M = ()>: Send + Sync {
// Required method
fn score(&self, memory: &M) -> Scalar;
// Provided method
fn remap<T>(self, mapping: T) -> ConsiderationRemap<M, T>
where T: ScoreMapping,
Self: Sized + 'static { ... }
}
Expand description
Consideration represent the score (also called weight, possibility, likeliness) of certain fact about the state of the world.
Imagine memory stores information about number of bannanas in the backpack, and you want to know how important for you is to get new one to not get hungry during the day - the more bannanas you have, the less likely it is for you to end up hungry and that score is used to decide if you need to go and get new one or even estimate how many of them you would need.
User should make considerations as lightweight and as small as possible. The reason for that is
to make them reused and combined into bigger sets of considerations using evaluators
(crate::evaluators
).
Example
use emergent::prelude::*;
struct Memory { counter: usize }
struct Hunger;
impl Consideration<Memory> for Hunger {
fn score(&self, memory: &Memory) -> Scalar {
1.0 / memory.counter as Scalar
}
}
let mut memory = Memory { counter: 10 };
assert_eq!(Hunger.score(&memory), 0.1);