Skip to content

Commit 9dfa487

Browse files
committed
🚀 basic core and react implementation
1 parent 803d274 commit 9dfa487

30 files changed

+8503
-1697
lines changed

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// "env": {
3+
// "browser": true,
4+
// "es6": true,
5+
// "node": true
6+
// },
7+
// "extends": [
8+
// "eslint:recommended",
9+
// "plugin:@typescript-eslint/eslint-recommended"
10+
// ],
11+
// "globals": {
12+
// "Atomics": "readonly",
13+
// "SharedArrayBuffer": "readonly"
14+
// },
15+
// "parser": "@typescript-eslint/parser",
16+
// "parserOptions": {
17+
// "ecmaFeatures": {
18+
// "jsx": true
19+
// },
20+
// "ecmaVersion": 2018,
21+
// "sourceType": "module"
22+
// },
23+
// "plugins": ["react", "@typescript-eslint"],
24+
// "rules": {}
25+
}

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"editor.formatOnSave": true
2+
"editor.formatOnSave": true,
3+
"eslint.enable": false,
4+
"typescript.tsdk": "node_modules\\typescript\\lib"
35
}

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1-
# behavior-tree
2-
1+
![](art/banner.png)
2+
3+
## Behavior Tree Toolkit
4+
5+
- [Core](packages/core/README.md) - Framework agnostic behavior trees implementation
6+
- [React](packages/react/README.md) - Hooks and docs how to use BT with React
7+
8+
## Quick start
9+
10+
> Check [Behavior Trees Documentation](packages/core/README.md) to learn the API.
11+
12+
```tsx
13+
import {nodes, tick} from '@behavior-tree/core'
14+
15+
const state = {
16+
isLoggedIn: false
17+
}
18+
19+
const tree = nodes.root<typeof state>(
20+
nodes.selector([
21+
nodes.sequence([
22+
nodes.conditional(({state}) => state.isLoggedIn)
23+
nodes.action('Redirect to dashboard', () => {
24+
navigate('/dashboard')
25+
}),
26+
]),
27+
nodes.sequence([
28+
nodes.action('Redirect to login page', () => {
29+
navigate('/login')
30+
}),
31+
]),
32+
])
33+
)
34+
35+
tick(tree, state)
36+
```
37+
38+
## Authors
39+
40+
- Kasper Mikiewicz ([@Idered](https://twitter.com/idered))
41+
42+
## License
43+
44+
The MIT License.

art/banner-core.png

17.7 KB
Loading

art/banner-react.png

18.9 KB
Loading

art/banner.png

22 KB
Loading

package.json

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,23 @@
11
{
2-
"name": "@behavior-tree/core",
3-
"version": "0.1.0",
4-
"license": "MIT",
5-
"author": "Kasper Mikiewicz",
6-
"main": "dist/index.js",
7-
"module": "dist/behavior-tree.esm.js",
8-
"typings": "dist/index.d.ts",
9-
"files": [
10-
"dist"
2+
"name": "@behavior-tree/repo",
3+
"private": true,
4+
"workspaces": [
5+
"packages/*",
6+
"packages/react/example"
117
],
12-
"publishConfig": {
13-
"access": "public"
14-
},
15-
"scripts": {
16-
"start": "tsdx watch",
17-
"build": "tsdx build",
18-
"test": "tsdx test"
19-
},
20-
"peerDependencies": {},
218
"prettier": {
22-
"printWidth": 80,
239
"bracketSpacing": false,
2410
"semi": false,
2511
"singleQuote": true,
2612
"trailingComma": "es5"
2713
},
28-
"devDependencies": {
29-
"@types/jest": "^24.0.19",
30-
"@types/uuid": "^3.4.5",
31-
"tsdx": "^0.10.5",
32-
"tslib": "^1.10.0",
33-
"typescript": "^3.6.4"
34-
},
3514
"dependencies": {
36-
"uuid": "^3.3.3"
15+
"lerna": "^3.18.3"
16+
},
17+
"devDependencies": {
18+
"@typescript-eslint/eslint-plugin": "^2.6.0",
19+
"@typescript-eslint/parser": "^2.6.0",
20+
"eslint": "^6.6.0",
21+
"eslint-plugin-react": "^7.16.0"
3722
}
3823
}

packages/core/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
![](../../art/banner-core.png)
2+
3+
## License
4+
5+
The MIT License.

packages/core/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@behavior-tree/core",
3+
"version": "0.1.0",
4+
"license": "MIT",
5+
"author": "Kasper Mikiewicz",
6+
"main": "dist/index.js",
7+
"module": "dist/core.esm.js",
8+
"typings": "dist/index.d.ts",
9+
"files": [
10+
"dist"
11+
],
12+
"publishConfig": {
13+
"access": "public"
14+
},
15+
"scripts": {
16+
"prepare": "yarn build",
17+
"start": "tsdx watch",
18+
"build": "tsdx build",
19+
"test": "tsdx test"
20+
},
21+
"peerDependencies": {},
22+
"devDependencies": {
23+
"@types/jest": "^24.0.21",
24+
"@types/uuid": "^3.4.6",
25+
"tsdx": "^0.11.0",
26+
"tslib": "^1.10.0",
27+
"typescript": "^3.9.0-beta"
28+
},
29+
"dependencies": {
30+
"immer": "^6.0.3",
31+
"nanoid": "^3.0.2"
32+
}
33+
}

0 commit comments

Comments
 (0)