Symphony

System for Yielding Multi-dimensional Problem Heuristic Optimization & Navigation

A small C++20 framework for search over rational-agent problems — define a State, an actions() successor function, and a goal test, then solve it with BFS, DFS, UCS, Greedy, A*, or Beam search.

View source →

Interactive visualizer

The same six algorithms, running in your browser. Click & drag to draw walls; drag the green start and red goal. Then press Run.

start goal wall expanded frontier path
Pick an algorithm and press Run.

The framework

Implement three things and any algorithm can solve your problem:

#include "symphony/symphony.h"
using namespace symphony;

struct MyState : State {
  std::string key() const override;   // canonical id for de-duplication
};

struct MyProblem : Problem {
  std::shared_ptr<State> initial_state() const override;
  bool goal_test(const State&) const override;
  std::vector<std::shared_ptr<Action>> actions(const std::shared_ptr<State>&) const override;
  double heuristic(const State&) const override;   // optional; 0 = uninformed
};

MyProblem p;
auto s = create_search(Algorithm::ASTAR, &p);
auto goal = s->search();
reconstruct(goal).print(std::cout);
std::cout << s->stats().expanded << " nodes expanded\n";