https://github.com/dylanblokhuis/treebot
treebot framework to create decision trees in deno/node
https://github.com/dylanblokhuis/treebot
bot deno typescript
Last synced: 2 months ago
JSON representation
treebot framework to create decision trees in deno/node
- Host: GitHub
- URL: https://github.com/dylanblokhuis/treebot
- Owner: dylanblokhuis
- Created: 2020-04-26T22:46:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T19:21:03.000Z (about 6 years ago)
- Last Synced: 2025-07-03T22:42:41.569Z (12 months ago)
- Topics: bot, deno, typescript
- Language: TypeScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TreeBot framework for deno/node
## Example:
```typescript
import { TreeBot, TreeTask, BranchTask, LeafTask } from './mod.ts'
class IsSunday extends BranchTask {
validate() {
return (new Date().getDay()) === 0
}
successTask() {
return new LogSunday();
}
failureTask() {
return new LogNotSunday();
}
}
class LogSunday extends LeafTask {
execute() {
console.log('Its sunday today!')
}
}
class LogNotSunday extends LeafTask {
execute() {
console.log('Its not sunday today!')
}
}
class ExampleBot extends TreeBot {
createRootTask(): TreeTask {
return new IsSunday();
}
onLoop() {
console.log("Loop!!");
}
onStart() {
console.log("Started");
}
}
const bot = new ExampleBot();
bot.run();
```