public static int bfs ( String [ ] [ ] cource , Queue < Point > points , Point goal ) {
  Point point = points . poll ( ) ;
  int count = point . count ;
  if ( point . x == goal . x && point . y == goal . y ) {
    return count ;
  }
  int [ ] [ ] move = {
    {
      - 1 , 0 }, {
        1 , 0 }, {
          0 , - 1 }, {
            0 , 1 }
          };
          count ++ ;
          for ( int i = 0 ;
          i < move . length ;
          i ++ ) {
            Point nextPoint = new Point ( point . y + move [ i ] [ 0 ] , point . x + move [ i ] [ 1 ] , count ) ;
            if ( cource [ nextPoint . y ] [ nextPoint . x ] . equals ( "." ) ) {
              cource [ nextPoint . y ] [ nextPoint . x ] = "!" ;
              points . add ( nextPoint ) ;
            }
          }
          return bfs ( cource , points , goal ) ;
        }
        
public static int bfs ( String [ ] [ ] cource , Queue < Point > points , Point goal ) { Point point = points . poll ( ) ; int count = point . count ; if ( point . x == goal . x && point . y == goal . y ) { return count ; } int [ ] [ ] move = { { - 1 , 0 } , { 1 , 0 } , { 0 , - 1 } , { 0 , 1 } } ; count ++ ; for ( int i = 0 ; i < move . length ; i ++ ) { Point nextPoint = new Point ( point . y + move [ i ] [ 0 ] , point . x + move [ i ] [ 1 ] , count ) ; if ( cource [ nextPoint . y ] [ nextPoint . x ] . equals ( " . " ) ) { cource [ nextPoint . y ] [ nextPoint . x ] = " ! " ; points . add ( nextPoint ) ; } } return bfs ( cource , points , goal ) ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) consequence: (block (return_statement (identifier)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (array_initializer (unary_expression operand: (decimal_integer_literal)) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal))) (array_initializer (decimal_integer_literal) (decimal_integer_literal))))) (expression_statement (update_expression (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal))) (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal))) (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (array_access array: (identifier) index: (field_access object: (identifier) field: (identifier))) index: (field_access object: (identifier) field: (identifier))) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (field_access object: (identifier) field: (identifier))) index: (field_access object: (identifier) field: (identifier))) right: (string_literal))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))))