fn find_two_in_line(&self, value: u8) -> Option<Position> {
        // Check columns
        for x in 0..3 {
            let (val_num, empty_num, empty_pos) =
                self.check_line(value, [Position(x, 0), Position(x, 1), Position(x, 2)]);
            if val_num == 2 && empty_num == 1 {
                return Some(empty_pos)
            }
        }
        // Check rows
        for y in 0..3 {
            let (val_num, empty_num, empty_pos) =
                self.check_line(value, [Position(0, y), Position(1, y), Position(2, y)]);
            if val_num == 2 && empty_num == 1 {
                return Some(empty_pos)
            }
        }
        // Check diagonals
        let (val_num, empty_num, empty_pos) =
            self.check_line(value, [Position(0, 0), Position(1, 1), Position(2, 2)]);
        if val_num == 2 && empty_num == 1 {
            return Some(empty_pos)
        }
        let (val_num, empty_num, empty_pos) =
            self.check_line(value, [Position(0, 2), Position(1, 1), Position(2, 0)]);
        if val_num == 2 && empty_num == 1 {
            return Some(empty_pos)
        }
        None
    }
// Find 2 X's or O's in line and return position of 3rd cell to complete the line.
Find 2 X's or O's in line and return position of 3rd cell to complete the line.
Find 2 X ' s or O ' s in line and return position of 3rd cell to complete the line .
fn find_two_in_line(&self, value: u8) -> Option<Position> {
        // Check columns
        for x in 0..3 {
            let (val_num, empty_num, empty_pos) =
                self.check_line(value, [Position(x, 0), Position(x, 1), Position(x, 2)]);
            if val_num == 2 && empty_num == 1 {
                return Some(empty_pos)
            }
        }
        // Check rows
        for y in 0..3 {
            let (val_num, empty_num, empty_pos) =
                self.check_line(value, [Position(0, y), Position(1, y), Position(2, y)]);
            if val_num == 2 && empty_num == 1 {
                return Some(empty_pos)
            }
        }
        // Check diagonals
        let (val_num, empty_num, empty_pos) =
            self.check_line(value, [Position(0, 0), Position(1, 1), Position(2, 2)]);
        if val_num == 2 && empty_num == 1 {
            return Some(empty_pos)
        }
        let (val_num, empty_num, empty_pos) =
            self.check_line(value, [Position(0, 2), Position(1, 1), Position(2, 0)]);
        if val_num == 2 && empty_num == 1 {
            return Some(empty_pos)
        }
        None
    }
fn find_two_in_line ( & self , value : u8 ) -> Option < Position > { // Check columns for x in 0 .. 3 { let ( val_num , empty_num , empty_pos ) = self . check_line ( value , [ Position ( x , 0 ) , Position ( x , 1 ) , Position ( x , 2 ) ] ) ; if val_num == 2 && empty_num == 1 { return Some ( empty_pos ) } } // Check rows for y in 0 .. 3 { let ( val_num , empty_num , empty_pos ) = self . check_line ( value , [ Position ( 0 , y ) , Position ( 1 , y ) , Position ( 2 , y ) ] ) ; if val_num == 2 && empty_num == 1 { return Some ( empty_pos ) } } // Check diagonals let ( val_num , empty_num , empty_pos ) = self . check_line ( value , [ Position ( 0 , 0 ) , Position ( 1 , 1 ) , Position ( 2 , 2 ) ] ) ; if val_num == 2 && empty_num == 1 { return Some ( empty_pos ) } let ( val_num , empty_num , empty_pos ) = self . check_line ( value , [ Position ( 0 , 2 ) , Position ( 1 , 1 ) , Position ( 2 , 0 ) ] ) ; if val_num == 2 && empty_num == 1 { return Some ( empty_pos ) } None }
Find 2 X's or O's in line and return position of 3rd cell to complete the line.
Find 2 X ' s or O ' s in line and return position of 3rd cell to complete the line .
&self
value
u8
&self
value
u8