Skip to content

Commit e9f0295

Browse files
committed
add default goals
1 parent 4a32c68 commit e9f0295

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

index.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { Bot } from "mineflayer"
22
import { Heuristics, Goal } from "./src/heuristics/"
33

4-
export interface Movement {
4+
declare interface Goals {
5+
Default: Goal
6+
}
7+
8+
declare interface Movement {
59
heuristic: Heuristics
10+
goals: Goals
611
Goal: (heuristics: object) => Goal
712
setGoal: (goal: Goal) => void
813
getYaw: (fov?: number, rotations?: number, blend?: number) => number

index.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const Heuristics = require("./src/heuristics")
2+
const Goals = require("./src/goals")
23

34
module.exports.plugin = function inject(bot) {
45
bot.movement = new Plugin(bot)
@@ -12,6 +13,8 @@ function Goal(heuristicMap) {
1213

1314
function Plugin(bot) {
1415
this.heuristic = new Heuristics(bot)
16+
this.goals = new Goals(bot)
17+
1518
this.setGoal = setGoal
1619
this.getYaw = getYaw
1720
this.steer = steer

src/goals.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = function Goals(bot) {
2+
this.Default = new bot.movement.Goal({
3+
distance: bot.movement.heuristic.new('distance')
4+
.configure({
5+
weight: 0.4,
6+
radius: 10,
7+
spread: 25,
8+
offset: 1,
9+
count: 5,
10+
increment: 0.2
11+
}),
12+
danger: bot.movement.heuristic.new('danger')
13+
.configure({
14+
weight: 0.6,
15+
radius: 3,
16+
count: 6,
17+
depth: 2,
18+
descend: false,
19+
increment: 0.2
20+
}),
21+
proximity: bot.movement.heuristic.new('proximity')
22+
.configure({
23+
weight: 0.6,
24+
avoid: false
25+
}),
26+
conformity: bot.movement.heuristic.new('conformity')
27+
.configure({
28+
weight: 0.2,
29+
avoid: false
30+
})
31+
})
32+
}

0 commit comments

Comments
 (0)