Giter Site home page Giter Site logo

bhouston / behave-graph Goto Github PK

View Code? Open in Web Editor NEW
281.0 281.0 25.0 6.27 MB

Open, extensible, small and simple behaviour-graph execution engine. Discord here: https://discord.gg/mrags8WyuH

License: Other

JavaScript 1.62% TypeScript 97.46% CSS 0.84% HTML 0.09%

behave-graph's Introduction

Ben's GitHub stats Top Langs

behave-graph's People

Contributors

aitorllj93 avatar arodic avatar beeglebug avatar bhouston avatar evilfant avatar kayhhh avatar oveddan avatar sybiote avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

behave-graph's Issues

Enable custom events.

It should be possible to listen to any event by a string identifier. And it should be possible to call any custom event by string identifier.

dist has two copies of the library and type definitions

this is causing vscode to show everything twice in autocomplete, possibly no other side effects, but should tidy up anyway

i think this was introduced when the examples got bundled, the del commands probably need double checking

image

saveGraph to JSON

Implement a means to save in a JSON format compatible with the readGraph call.

nodes attempting to set output values on flow sockets

Several flow nodes are throwing errors when you attempt to run a graph, complaining about attempting to set output values on flow sockets.

I think i've fixed flipflop, as that was the one I was attempting to use when I saw the issue, but I suspect some of the others are still doing it (I was hesitant to touch things like "flow/sequence" which seem incomplete anyway)

Make sure state get/set is type safe.

Right now state is stored in the graph without any type information. Thus it can pass out a number to a getString state node. This is unsafe. The state store should be typed and enforce those types at run-time.

Enable library users to add SocketValueTypes

The types that flow through the graph should not be limited to only those pre-defined in this library. This probably means we have to move away from an enum and towards a list of registered types.

Maybe easier to use a stack to manage execution rather than work queue?

I am starting to wonder if the main method of evaluating these behavior graphs is actually a stack rather than a work queue.

The reason why a stack would be easier is:

  • The sequence node would just put its children on the stack in reverse order.
  • The for-loop would put itself on the stack and then its loopBody. When it gets executed again after the loopBody is done, it will put itself again on the stack and then the next iteration of loopBody.

I think that once the stack is completed, you go back to look for new events?

I think this doesn't handle the case where you want to "break" a for-loop. In those cases you either need a loop in the graph (non-DAG) or as Unity does it, it has an event that is raised in the loopBody and then executes and sets a "break" flow socket on the for-loop (but this violates the stack execution model, as the events wouldn't be fired until the for-loop is done.)

Thus this isn't yet sufficient.

Create reusable library form.

Currently this is not in a true library form, rather it just allows for local tests to be run. For this to be truly usable, it needs to be converted and published to an npm accessible library.

Support event/stateChanged event - when state changes

It should be possible to listen to state identifiers and have an event fire when the state is changed.

Q: Should there be a central registry of state data? Like a list of member variables, or should I keep the very arbitrary map-based method? The central registry on a per graph basis may lead to better type checking.

Allow an upstream node to "wait" for a downstream subgraph to complete execution.

This is required for the "for loop" node in Unreal Engine and Unity Visual Scripting.

https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/Blueprints/UserGuide/FlowControl/

Also required by "Sequence". These nodes wait for the subgraph connected to their output flow socket to execute and then they will pass execution to either to the same output flow socket (loopBody) or to another flow output socket (complete.).

Instead of relying on Events being triggered externally, allow them to self-register

In the current implementation, it is required that one trigger Events explicitly. You can see this in all of the examples where after loading the graph, one triggers the "events/start" event explicitly.

Instead, one could have all events in the graph execute immediately upon startup and they all return promises, which means that they are pending. And then when they fire, they resolve their promises. This would make it much simpler to add new event types to the system.

remove .vscode directory

Having this checked in makes it a bit tougher for other developers to use their own workspace settings when working on the project, it should probably be removed and gitignored.

how does a graph connect to an external environment?

This is a larger question about how a behave-graph graph interacts/binds itself to some external environment, be it a threejs scene or something else.

This codesandbox is me experimenting with a simple connection between a graph and a threejs scene, but at the moment the connection is very manual.

https://codesandbox.io/s/behave-graph-three-test-ijdzj6

What i'm wondering, is what do we think that connection will eventually look like? I imagine a node such as my test "input/mouseClick" would also have an input of some sort to select a mesh in the scene (in this case the cube), and then would only be triggered by clicks on that cube.

We would then also want a way to transmit effects back into the scene, for example I might want a graph which looks like the following:

const graphDef: GraphJSON = {
  nodes: [
    {
      id: "1",
      type: "input/mouseClick",
    },
    {
      id: "2",
      type: "material/setColor",
      inputs: {
        text: {
          value: "#0000FF",
        },
        flow: {
          links: [
            {
              nodeId: "1",
              socket: "flow",
            },
          ],
        },
      },
    },
  ],
};

ie, when the user clicks on the cube, the material changes colour to blue.

I think it would be really useful to sketch out some more "real world" examples of graphs which actually do something in a less abstract environment to get an idea of what changes might be required in the core library to support the required nodes.

Need a logo

Something to use on the website, discord, etc.

Implement assertion nodes for unit testing.

It would be nice to have Assert nodes that check for a specific input and fail otherwise. This would allow one to create a large series of graphs that if they run successful are basically unit tests for the system.

Add types for json data.

At the moment, readGraphFromJSON and writeGraphToJSON both deal with a type of any, which is fine, but open to errors.

For better interoperability with other code, it would be good to specify a type for the JSON version of a graph.

Create Three.js example.

It should be relatively easy to create a Three.jS example once we have it running in the browser via #3.

Validate Graph: Type alignment

Enforcing typing alignment:

  • Connected Input and Output Sockets agree on their type.
  • Input Socket types align with the type of their constant values.

Support multi-outputs per node execution

In order to support for-loops and delayed sequences, I need to be able to return outputs multiple times so that the downstream graph executes multiple times.

How should this be done?

I think at minimum a promise should be returned and then it will resolve when the next set of outputs are ready. And part of that response will be another promise if there are subsequent outputs that should be waited upon.

This needs a nice API.

eslint fails to run

ESLint couldn't find the plugin "eslint-plugin-react". looks like a dependency of eslint-config-airbnb?

add prettier config

From experience, prettier is the nicest solution to keeping a clean, consistently formatted codebase while removing any possible arguments about the details. It's used by thousands of other open source JS projects, so contributors will be familiar with it.

We could auto format everything once in a single cleanup commit and be done with it, most modern IDE's will handle prettier automatically and format on save.

We can then strip out most of the eslint config (certainly any bits pertaining to code formatting).

Setup package alias so one can import in examples easily.

it would be nice to see in the examples this:

import { Node } from 'behaviour-graph';

Rather than:

import { Node } from '../../../dist/lib/index';

I think this can be done with some config variables in the tsconfig.json file...

Create web browser example.

Right now I only have command line examples. Having an example that runs in the web browser would be very nice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.