Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Visualization

Forester can generate a visual diagram of any behavior tree project, rendering the full node graph as an SVG file. This makes it easy to review control flow, spot structural issues, and communicate tree logic to teammates.


Prerequisites

Visualization uses Graphviz under the hood. Install it before running the vis command:

# macOS
brew install graphviz

# Ubuntu / Debian
sudo apt-get install graphviz

# Windows
winget install graphviz

Example Output


Usage

CLI (f-tree vis)

f-tree vis --root project/ --main main.tree --tree main --output viz.svg
FlagDefaultDescription
--rootCurrent working directoryPath to the project root directory containing .tree files.
--mainmain.treeThe entry .tree file to visualize.
--treeFirst root definition foundName of the specific root tree to visualize (required if the file has multiple roots).
--output<main-filename>.svgOutput SVG file path.

From Rust

Visualization can also be triggered programmatically from Rust using the ForesterBuilder and Visualizer API:

use forester_rs::tracer::Tracer;
use forester_rs::visualizer::Visualizer;
use forester_rs::runtime::builder::ForesterBuilder;
use std::path::PathBuf;

fn main() {
    let mut fb = ForesterBuilder::from_file_system();
    fb.main_file("main.tree".to_string());

    let svg = Visualizer::build_svg(fb).expect("Visualization failed");
    std::fs::write("output.svg", svg).unwrap();
}