AI Scripting: Pathfinding and Enemy Behavior Quiz Quiz

Sharpen your understanding of AI scripting by exploring core principles of pathfinding algorithms, enemy behaviors, and movement logic. Evaluate your skills in applying AI concepts to interactive environments, dynamic obstacle handling, and enemy state management.

  1. Understanding Pathfinding Algorithms

    Which pathfinding algorithm is best known for efficiently finding the shortest path on a grid with obstacles, such as guiding an enemy through a maze-like environment?

    1. Breadth-Depth Search
    2. Greedy Depth Search
    3. Dijkstra's Tree
    4. A* (A Star)

    Explanation: A* (A Star) combines the benefits of Dijkstra’s algorithm and a heuristic to efficiently find the shortest path, making it ideal for grid-based pathfinding with obstacles. Dijkstra’s Tree is not a standard term; the correct reference is Dijkstra’s algorithm, which does not use heuristics, making it less efficient in certain cases. Breadth-Depth Search is a mix-up of two terms and is not a recognized algorithm. Greedy Depth Search prioritizes the heuristic only and may miss optimal paths in complex environments.

  2. Basic Enemy Behavior States

    Which behavior state is most commonly used for enemies that patrol between set points until they spot the player?

    1. Chasing
    2. Fleeing
    3. Patrol
    4. Idleing

    Explanation: Patrol is the term for enemy AI moving between predefined points, which is standard until the player is detected. Chasing begins only after spotting the player. Fleeing describes enemies trying to escape rather than guard. Idleing contains a typographical error and refers to a stationary, inactive state, not movement between points.

  3. Navigating Dynamic Obstacles

    When scripting enemies to avoid dynamically moving obstacles in real time, which approach is most effective for smooth navigation?

    1. Continuously updating the navigation mesh
    2. Using random walk algorithms exclusively
    3. Precomputing paths only at game start
    4. Disabling obstacle detection for performance

    Explanation: Continuously updating the navigation mesh allows the AI to account for new or moved obstacles, ensuring smooth navigation. Precomputing paths at the start doesn’t account for changes and leads to errors. Random walk algorithms do not guarantee purposeful, smooth movement. Disabling obstacle detection may improve performance but results in unnatural and failing navigation.

  4. Enemy Line-of-Sight Logic

    An enemy should only initiate pursuit when the player is both within a detection radius and not concealed by walls. Which logic checks are essential for this scenario?

    1. Checking only the distance between enemy and player
    2. Raycasting for clear line of sight
    3. Using collision only when already chasing
    4. Ignoring all obstacles in detection

    Explanation: Raycasting enables the AI to detect if obstacles like walls block the view, ensuring enemies only react appropriately. Simply checking distance ignores obstacles and causes unrealistic behavior. Ignoring obstacles undermines the stealth aspects of gameplay. Relying on collision after chasing begins will miss the opportunity to trigger pursuit correctly.

  5. Optimizing Performance with Multiple Enemies

    What is a practical method to reduce computational load when updating pathfinding for numerous enemies simultaneously?

    1. Removing all pathfinding from AI scripts
    2. Running all pathfinding computations every frame
    3. Increasing pathfinding complexity per enemy
    4. Staggering path updates across several frames

    Explanation: Staggering updates helps distribute the processing cost, keeping performance stable when managing many enemies. Running all calculations each frame puts unnecessary strain on resources. Removing pathfinding would make enemies ineffective. Increasing complexity per enemy worsens performance rather than improving it.