fn rand_step(rng: &mut ThreadRng, x: i32, target: i32, band: u32) -> i32 {
    if band == 0 || rng.gen_range(0, 3) <= 1 { // 2 in 3 doesn't move
        return 0;
    }
    let half_band = (band as i32) / 2;
    if x > target + half_band {
        return -1;
    }
    if x < target - half_band {
        return 1;
    }
    if rng.gen_ratio((target + half_band - x) as u32, band) {
        return 1;
    }
    -1
}
////////////////////////////////////////////////////////////////////////
/// random walk, band is centred on target, probability of step towards target
/// increases nearer x is to the edge. returns -1, 0 or +1
random walk, band is centred on target, probability of step towards target
increases nearer x is to the edge.
random walk band is centred on target probability of step towards target increases nearer x is to the edge .
fn rand_step(rng: &mut ThreadRng, x: i32, target: i32, band: u32) -> i32 {
    if band == 0 || rng.gen_range(0, 3) <= 1 { // 2 in 3 doesn't move
        return 0;
    }
    let half_band = (band as i32) / 2;
    if x > target + half_band {
        return -1;
    }
    if x < target - half_band {
        return 1;
    }
    if rng.gen_ratio((target + half_band - x) as u32, band) {
        return 1;
    }
    -1
}
fn rand_step ( rng : & mut ThreadRng , x : i32 , target : i32 , band : u32 ) -> i32 { if band == 0 || rng . gen_range ( 0 , 3 ) <= 1 { // 2 in 3 doesn't move return 0 ; } let half_band = ( band as i32 ) / 2 ; if x > target + half_band { return - 1 ; } if x < target - half_band { return 1 ; } if rng . gen_ratio ( ( target + half_band - x ) as u32 , band ) { return 1 ; } - 1 }
random walk, band is centred on target, probability of step towards target
increases nearer x is to the edge.
random walk band is centred on target probability of step towards target increases nearer x is to the edge .
rng
&mut ThreadRng
x
i32
target
i32
band
u32
rng
&mut ThreadRng
x
i32
target
i32
band
u32