fn default_policy<PS: planner::ProblemSpace + planner::Anytime>(
    ps: &PS,
    v: PS::State,
    parents: &mut collections::HashMap<PS::State, PS::State>,
) -> f64 {
    let mut s = v;
    let mut reward = 0.0;
    // This policy currently takes a greedy approach - random might be better in certain cases e.g.
    // if initially the cost of going one way is cheaper then a detour, but the way is blocked down
    // the road.
    while ps.succ(&s).count() != 0 {
        let mut min_val = f64::INFINITY;
        let mut tmp = s;
        for next_child in ps.succ(&s) {
            if next_child.1 <= min_val {
                min_val = next_child.1;
                tmp = next_child.0;
            }
        }
        parents.insert(tmp, s);
        s = tmp;
        reward += min_val;
    }

    // TODO: Check this - currently solution with lowest cost to get there is best.
    reward = 1.0 + (1.0 / reward);
    reward
}
/// Simulate what would happen if you play from this state to the end.
// TODO: check if to make this part of the trait - would allow for multi-player games etc.
Simulate what would happen if you play from this state to the end.
TODO: check if to make this part of the trait - would allow for multi-player games etc.
Simulate what would happen if you play from this state to the end . TODO : check if to make this part of the trait - would allow for multi - player games etc .
fn default_policy<PS: planner::ProblemSpace + planner::Anytime>(
    ps: &PS,
    v: PS::State,
    parents: &mut collections::HashMap<PS::State, PS::State>,
) -> f64 {
    let mut s = v;
    let mut reward = 0.0;
    // This policy currently takes a greedy approach - random might be better in certain cases e.g.
    // if initially the cost of going one way is cheaper then a detour, but the way is blocked down
    // the road.
    while ps.succ(&s).count() != 0 {
        let mut min_val = f64::INFINITY;
        let mut tmp = s;
        for next_child in ps.succ(&s) {
            if next_child.1 <= min_val {
                min_val = next_child.1;
                tmp = next_child.0;
            }
        }
        parents.insert(tmp, s);
        s = tmp;
        reward += min_val;
    }
    // TODO: Check this - currently solution with lowest cost to get there is best.
    reward = 1.0 + (1.0 / reward);
    reward
}
fn default_policy < PS : planner :: ProblemSpace + planner :: Anytime > ( ps : & PS , v : PS :: State , parents : & mut collections :: HashMap < PS :: State , PS :: State > , ) -> f64 { let mut s = v ; let mut reward = 0.0 ; // This policy currently takes a greedy approach - random might be better in certain cases e.g. // if initially the cost of going one way is cheaper then a detour, but the way is blocked down // the road. while ps . succ ( & s ) . count ( ) != 0 { let mut min_val = f64 :: INFINITY ; let mut tmp = s ; for next_child in ps . succ ( & s ) { if next_child . 1 <= min_val { min_val = next_child . 1 ; tmp = next_child . 0 ; } } parents . insert ( tmp , s ) ; s = tmp ; reward += min_val ; } // TODO: Check this - currently solution with lowest cost to get there is best. reward = 1.0 + ( 1.0 / reward ) ; reward }
Simulate what would happen if you play from this state to the end.
Simulate what would happen if you play from this state to the end .
ps
&PS
v
PS::State
parents
&mut collections::HashMap<PS::State, PS::State>
ps
&PS
v
PS::State
parents
&mut collections::HashMap<PS::State, PS::State>