Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tree visualization #3

Open
sv-gray opened this issue Nov 10, 2023 · 0 comments
Open

Add tree visualization #3

sv-gray opened this issue Nov 10, 2023 · 0 comments

Comments

@sv-gray
Copy link

sv-gray commented Nov 10, 2023

Could we get some way of visualizing the current tree? For example:

.selector('wander around')
  .do('do nothing if unit is already moving', CheckMotion.checkIfMoving())
  .sequence('perform wander sequence')
    .do('wait for some time', Wait.wait())
    .do('locate a fitting tile', Tile.locateFitting())
    .do('go to tile', Tile.goToPoint())
    .do('reset wait cycle', Wait.reset())
  .end()
.end()
.build();
const tree = wanderBehavior.tick();
const treeLooksLike = {
  'wander around': {
    name: 'wander around',
    result: 'RUNNING',
    children: {
      'do nothing if already moving': {
        name: 'do nothing if already moving',
        result: 'FAILURE'
      },
      'perform wander sequence': {
        name: 'perform wander sequence',
        result: 'RUNNING',
        children: {
          'wait for some time': {
             name: 'wait for some time',
             result: 'SUCCESS'
          },
          'locate fitting tile': {
             ...,
             result: 'SUCCESS'
          },
          'go to tile': {
            ...,
            result: 'RUNNING'
          },
          'reset wait cycle': {
            ...,
            result: 'SUCCESS' //or maybe 'UNREACHED'? since the tree hasn't reached this point yet, as the previous action is still RUNNING
          }
        }
      }
    }
  }
}

Then you can feed this into your console.log or your tree visualizer package.

I'll see if I can put together a PR if you're interested in having this in the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant