fn neighbours(map: &Vec<Vec<f32>>, pos: (i32, i32)) -> [f32; 9] {
    let ref tmap = *map;
    let mut iter = 0;
    let mut arr: [f32; 9] = [0.0; 9];

    for p in 0..3 {
        for q in 0..3 {
            // println!("{}{}", p, q);
            if tmap.get((pos.0 + p - 1) as usize).is_none()
                || tmap[(pos.0 + p - 1) as usize]
                    .get((pos.1 + q - 1) as usize)
                    .is_none()
            {
                arr[iter] = tmap[pos.0 as usize][pos.1 as usize];
            } else {
                arr[iter] = tmap[(pos.0 + p - 1) as usize][(pos.1 + q - 1) as usize];
            }
            iter += 1;
        }
    }
    // info!("{:?}", arr);
    arr
}
/// Finds Moore (8-Way) Neighbours for a position in a map
Finds Moore (8-Way) Neighbours for a position in a map
Finds Moore ( 8 - Way ) Neighbours for a position in a map
fn neighbours(map: &Vec<Vec<f32>>, pos: (i32, i32)) -> [f32; 9] {
    let ref tmap = *map;
    let mut iter = 0;
    let mut arr: [f32; 9] = [0.0; 9];
    for p in 0..3 {
        for q in 0..3 {
            // println!("{}{}", p, q);
            if tmap.get((pos.0 + p - 1) as usize).is_none()
                || tmap[(pos.0 + p - 1) as usize]
                    .get((pos.1 + q - 1) as usize)
                    .is_none()
            {
                arr[iter] = tmap[pos.0 as usize][pos.1 as usize];
            } else {
                arr[iter] = tmap[(pos.0 + p - 1) as usize][(pos.1 + q - 1) as usize];
            }
            iter += 1;
        }
    }
    // info!("{:?}", arr);
    arr
}
fn neighbours ( map : & Vec < Vec < f32 > > , pos : ( i32 , i32 ) ) -> [ f32 ; 9 ] { let ref tmap = * map ; let mut iter = 0 ; let mut arr : [ f32 ; 9 ] = [ 0.0 ; 9 ] ; for p in 0 .. 3 { for q in 0 .. 3 { // println!("{}{}", p, q); if tmap . get ( ( pos . 0 + p - 1 ) as usize ) . is_none ( ) || tmap [ ( pos . 0 + p - 1 ) as usize ] . get ( ( pos . 1 + q - 1 ) as usize ) . is_none ( ) { arr [ iter ] = tmap [ pos . 0 as usize ] [ pos . 1 as usize ] ; } else { arr [ iter ] = tmap [ ( pos . 0 + p - 1 ) as usize ] [ ( pos . 1 + q - 1 ) as usize ] ; } iter += 1 ; } } // info!("{:?}", arr); arr }
Finds Moore (8-Way) Neighbours for a position in a map
Finds Moore ( 8 - Way ) Neighbours for a position in a map
map
&Vec<Vec<f32>>
pos
(i32, i32)