mod informed;
mod uniform_box;
pub use informed::ProlateHyperspheroid;
use rand_core::Rng;
pub use uniform_box::{INFORMED_BOX_ATTEMPTS, UniformBox};
use crate::StateSpace;
pub trait Sampler<S> {
fn sample<R: Rng + ?Sized>(&mut self, rng: &mut R) -> S;
fn sample_informed<Sp, R>(
&mut self,
space: &Sp,
rng: &mut R,
start: &S,
goal: &S,
max_cost: f64,
) -> Option<S>
where
Sp: StateSpace<State = S>,
R: Rng + ?Sized,
{
let _ = (space, rng, start, goal, max_cost);
None
}
}
pub fn unit_f64<R: Rng + ?Sized>(rng: &mut R) -> f64 {
const ONE: u64 = 0x3FF0_0000_0000_0000;
f64::from_bits(ONE | (rng.next_u64() >> 12)) - 1.0
}
#[cfg(test)]
mod tests {
use super::*;
use rand_core::SeedableRng;
#[test]
fn unit_f64_stays_in_half_open_unit_interval() {
let mut rng = rand_pcg::Pcg64Mcg::seed_from_u64(1);
for _ in 0..10_000 {
let x = unit_f64(&mut rng);
assert!((0.0..1.0).contains(&x));
}
}
}