Implement a Reactive Behavior Tree Tick With Preemption

Last updated: November 29, 2026

Quick Overview

Implement Condition, Action, Sequence and Fallback nodes for a behavior tree that returns SUCCESS, FAILURE or RUNNING, re-evaluates conditions on every tick, and halts a running action when a higher-priority branch takes over.

Shield AI
Software Engineering Fundamentals
Software Engineer
Shield AI
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement Condition, Action, Sequence and Fallback nodes for a behavior tree that returns SUCCESS, FAILURE or RUNNING, re-evaluates conditions on every tick, and halts a running action when a higher-priority branch takes over.

Mission autonomy such as Hivemind's is commonly expressed as behaviors that preempt each other: a low-battery condition must interrupt a search pattern and trigger return to base. The interviewer checks that you understand tick semantics, the RUNNING state, and the often-missed halt step that lets an interrupted action clean up.

What the Interviewer Expects
  • Defines the three statuses and the tick contract clearly
  • Sequence stops at the first non-SUCCESS child, Fallback at the first non-FAILURE
  • Re-evaluates from the first child each tick so conditions can preempt
  • Halts children after the one that returned, so a preempted action can release resources
  • Explains the difference between reactive and memory (non-reactive) composites
Key Topics to Cover
Behavior trees
State machines
Preemption
Composite pattern
Mission autonomy
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • When would you want a memory Sequence that resumes at the running child instead?
  • How would you add a Parallel node with a success threshold?
  • How do you unit test a tree whose actions depend on simulator time?
  • How would you log ticks so a flight test engineer can see why the aircraft switched behavior?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Every node exposes tick(blackboard) returning a status and halt(). Leaves read and write a shared blackboard (battery level, mission progress). Sequence succeeds only if all children succeed. Fall...

High-Level Design

A composite base class holds children and knows how to halt them. Actions remember whether they were RUNNING, so halt only calls their cleanup hook when needed. When a composite returns early at chi...


Submit Your Answer
Markdown supported

Related Questions