Behavior trees for Elixir
Find a file
Rosa Richter af882a8c8b
All checks were successful
ci/woodpecker/push/test Pipeline was successful
chore(deps): Upgrade dependency elixir to 1.20.0
2026-06-03 14:33:27 -06:00
.woodpecker chore(deps): Upgrade dependency elixir to 1.20.0 2026-06-03 14:33:27 -06:00
lib fix: Remove unused Logger import 2026-06-03 14:33:01 -06:00
test chore: add ex_check and fix failures 2025-10-24 17:39:59 -06:00
.credo.exs chore: add ex_check and fix failures 2025-10-24 17:39:59 -06:00
.formatter.exs New Mix project 2024-09-26 23:19:15 -06:00
.gitignore New Mix project 2024-09-26 23:19:15 -06:00
LICENSE.md Prep for release 2024-10-02 18:39:50 -06:00
mise.toml chore(deps): Upgrade dependency elixir to 1.20.0 2026-06-03 14:33:27 -06:00
mix.exs chore: add ex_check and fix failures 2025-10-24 17:39:59 -06:00
mix.lock chore(deps): update dependency ex_doc to v0.40.3 2026-05-28 12:07:00 +00:00
README.md fix(docs): update CI badge [ci skip] 2026-05-27 11:33:36 -06:00
renovate.json Update renovate.json 2026-05-27 16:03:19 +00:00

Taido

status-badge

Behavior trees for Elixir.

Installation

If available in Hex, the package can be installed by adding taido to your list of dependencies in mix.exs:

def deps do
  [
    {:taido, "~> 0.1.0"}
  ]
end

The docs can be found at https://hexdocs.pm/taido.

Usage

Here's an example tree that undocks a spaceship from a station and then navigates to another waypoint.

defmodule SpaceshipBehaviors do
  alias Taido.Node

  def navigate(waypoint) do
    Node.sequence([
      Node.select([
        Node.invert(
          Node.condition(fn state ->
            state.ship.docked?
          end)
        ),

        Node.action(fn state ->
          {:ok, ship} = Spaceships.undock(state.ship)

          {:success, Map.put(state, :ship, ship)}
        end)
      ]),

      Node.action(fn state ->
        {:ok, ship} = Spaceships.navigate(state.ship, waypoint)

        {:success, Map.put(state, :ship, ship)}
      end)
    ])
  end
end

Then evaluate the tree like this:

state = %{ship: Spaceships.new()}

{status, updated_tree, updated_state} = Taido.tick(tree, state)

For details, see the HexDocs.

License

Copyright © 2025 Rosa Richter

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.