- Elixir 100%
|
|
||
|---|---|---|
| .woodpecker | ||
| lib | ||
| test | ||
| .credo.exs | ||
| .formatter.exs | ||
| .gitignore | ||
| LICENSE.md | ||
| mise.toml | ||
| mix.exs | ||
| mix.lock | ||
| README.md | ||
| renovate.json | ||
Taido
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/.