fn available_moves(
    board: &[[Option<Card>; 5]; 4],
    bombs: &mut [[u8; 5]; 4],
    deck: &Vec<Card>,
    player: u8,
) -> Vec<(usize, usize, usize, [Option<(usize, usize)>; 4])> {
    let mut moves: Vec<(usize, usize, usize, [Option<(usize, usize)>; 4])> = Default::default();

    // iterate through the boards for each card in deck
    for i in 0..4 {
        for j in 0..5 {
            for d in 0..deck.len() {
                if board[i][j].is_none() {
                    // fetch neighbours
                    let neighbours = Card::get_neighbours(board, i, j, deck[d].name);

                    // flag to determine whether the move has priority
                    let mut has_priority: bool = false;

                    if bombs[i][j] > 0 {
                        has_priority = false;
                    }

                    // iterate through neighbours to set priority when there are any oppenent card neighbours for that cell
                    for i in 0..4 {
                        // if there is a valid neighbouring cell
                        if let Some(n) = neighbours[i] {
                            // if there is a card in that cell
                            if let Some(neighbour) = board[n.0][n.1].as_ref() {
                                // if that card belongs to the opponent
                                if neighbour.player != player {
                                    has_priority = true;
                                    break;
                                }
                            }
                        }
                    }

                    // if move has priority, add it to the beginning of the list
                    if has_priority {
                        moves.insert(0, (d, i, j, neighbours));
                    }
                    // otherwise add it to the end of the list
                    else {
                        moves.push((d, i, j, neighbours));
                    }
                }
            }
        }
    }

    return moves;
}
// returns a vector of (card, row, column) of available moves
returns a vector of (card, row, column) of available moves
returns a vector of ( card row column ) of available moves
fn available_moves(
    board: &[[Option<Card>; 5]; 4],
    bombs: &mut [[u8; 5]; 4],
    deck: &Vec<Card>,
    player: u8,
) -> Vec<(usize, usize, usize, [Option<(usize, usize)>; 4])> {
    let mut moves: Vec<(usize, usize, usize, [Option<(usize, usize)>; 4])> = Default::default();
    // iterate through the boards for each card in deck
    for i in 0..4 {
        for j in 0..5 {
            for d in 0..deck.len() {
                if board[i][j].is_none() {
                    // fetch neighbours
                    let neighbours = Card::get_neighbours(board, i, j, deck[d].name);
                    // flag to determine whether the move has priority
                    let mut has_priority: bool = false;
                    if bombs[i][j] > 0 {
                        has_priority = false;
                    }
                    // iterate through neighbours to set priority when there are any oppenent card neighbours for that cell
                    for i in 0..4 {
                        // if there is a valid neighbouring cell
                        if let Some(n) = neighbours[i] {
                            // if there is a card in that cell
                            if let Some(neighbour) = board[n.0][n.1].as_ref() {
                                // if that card belongs to the opponent
                                if neighbour.player != player {
                                    has_priority = true;
                                    break;
                                }
                            }
                        }
                    }
                    // if move has priority, add it to the beginning of the list
                    if has_priority {
                        moves.insert(0, (d, i, j, neighbours));
                    }
                    // otherwise add it to the end of the list
                    else {
                        moves.push((d, i, j, neighbours));
                    }
                }
            }
        }
    }
    return moves;
}
fn available_moves ( board : & [ [ Option < Card > ; 5 ] ; 4 ] , bombs : & mut [ [ u8 ; 5 ] ; 4 ] , deck : & Vec < Card > , player : u8 , ) -> Vec < ( usize , usize , usize , [ Option < ( usize , usize ) > ; 4 ] ) > { let mut moves : Vec < ( usize , usize , usize , [ Option < ( usize , usize ) > ; 4 ] ) > = Default :: default ( ) ; // iterate through the boards for each card in deck for i in 0 .. 4 { for j in 0 .. 5 { for d in 0 .. deck . len ( ) { if board [ i ] [ j ] . is_none ( ) { // fetch neighbours let neighbours = Card :: get_neighbours ( board , i , j , deck [ d ] . name ) ; // flag to determine whether the move has priority let mut has_priority : bool = false ; if bombs [ i ] [ j ] > 0 { has_priority = false ; } // iterate through neighbours to set priority when there are any oppenent card neighbours for that cell for i in 0 .. 4 { // if there is a valid neighbouring cell if let Some ( n ) = neighbours [ i ] { // if there is a card in that cell if let Some ( neighbour ) = board [ n . 0 ] [ n . 1 ] . as_ref ( ) { // if that card belongs to the opponent if neighbour . player != player { has_priority = true ; break ; } } } } // if move has priority, add it to the beginning of the list if has_priority { moves . insert ( 0 , ( d , i , j , neighbours ) ) ; } // otherwise add it to the end of the list else { moves . push ( ( d , i , j , neighbours ) ) ; } } } } } return moves ; }
returns a vector of (card, row, column) of available moves
returns a vector of ( card row column ) of available moves
board
&[[Option<Card>; 5]; 4]
bombs
&mut [[u8; 5]; 4]
deck
&Vec<Card>
player
u8