Class Navigator<T>

Type Parameters

  • T = number

Hierarchy

  • Navigator

Constructors

Properties

Methods

Constructors

  • The constructor initializes the Navigator object with the given parameters and sets the current position as visited in the matrix.

    Type Parameters

    • T = number

    Parameters

    • -: {
          init: {
              VISITED: T;
              charDir: Direction;
              cur: [number, number];
          };
          matrix: T[][];
          onMove: ((cur) => void);
          turning: Turning;
      }

      matrix: a 2D array representing the grid or map

      • init: {
            VISITED: T;
            charDir: Direction;
            cur: [number, number];
        }
        • VISITED: T
        • charDir: Direction
        • cur: [number, number]
      • matrix: T[][]
      • onMove: ((cur) => void)
          • (cur): void
          • Parameters

            • cur: [number, number]

            Returns void

      • turning: Turning

    Returns Navigator<T>

Properties

_VISITED: T
_character: Character
_cur: [number, number]
_matrix: T[][]
onMove: ((cur) => void)

Type declaration

    • (cur): void
    • Parameters

      • cur: [number, number]

      Returns void

Methods

  • The function checks if there is a valid move in the specified direction in a matrix.

    Parameters

    • direction: Direction

      The direction parameter is a string that represents the direction in which to check. It can be one of the following values: 'up', 'right', 'down', or 'left'.

    Returns boolean

    a boolean value.

  • The move function updates the current position based on the given direction and updates the matrix accordingly.

    Parameters

    • direction: Direction

      The direction parameter is a string that represents the direction in which to move. It can have one of the following values: 'up', 'right', 'down', or 'left'.

    Returns void

  • The "start" function moves the character in its current direction until it encounters an obstacle, then it turns the character and repeats the process.

    Returns void

Generated using TypeDoc