Skip to content

Commit

Permalink
assign a cost to jump
Browse files Browse the repository at this point in the history
  • Loading branch information
aesthetic0001 committed Feb 1, 2024
1 parent 80de39c commit 46e8914
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ function inject (bot) {
// console.log(`Treating as regular goal node: ${nextPoint.x}, ${nextPoint.y}, ${nextPoint.z}`)

bot.look(Math.atan2(-dx, -dz), 0)

bot.setControlState('forward', true)
bot.setControlState('jump', false)

Expand All @@ -626,6 +627,7 @@ function inject (bot) {
bot.setControlState('jump', true)
bot.setControlState('sprint', false)
} else {
console.log("STOPPING???")
bot.setControlState('forward', false)
bot.setControlState('sprint', false)
}
Expand Down
4 changes: 3 additions & 1 deletion lib/movements.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Movements {
this.placeCost = 1
this.liquidCost = 1
this.entityCost = 1
this.jumpCost = 3
this.sameDirectionReduction = 0.5

this.dontCreateFlow = true
Expand Down Expand Up @@ -461,7 +462,7 @@ class Movements {
if (blockC.height - block0.height > 1.2) return // Too high to jump
cost += this.safeOrBreak(this.getBlock(node, 0, 2, 0), toBreak)
if (cost > 100) return
cost += 1
cost += 1 + this.jumpCost
if (currentXDirection === dir.x) cost *= this.sameDirectionReduction
neighbors.push(new Move(blockC.position.x, blockC.position.y + 1, blockC.position.z, node.remainingBlocks, cost, toBreak))
} else if (blockD.physical || blockC.liquid) {
Expand Down Expand Up @@ -565,6 +566,7 @@ class Movements {
cost += this.exclusionPlace(block1)
toPlace.push({ x: node.x, y: node.y - 1, z: node.z, dx: 0, dy: 1, dz: 0, jump: true })
cost += this.placeCost // additional cost for placing a block
cost += this.jumpCost // additional cost for jumping
}

if (cost > 100) return
Expand Down

0 comments on commit 46e8914

Please sign in to comment.