validated the incense stick pipeline after refactor

This commit is contained in:
dtookey 2023-08-05 07:42:31 -04:00
parent a39268a7fc
commit 333872f5bb
3 changed files with 19 additions and 19 deletions

View File

@ -33,7 +33,7 @@ import kotlin.random.Random
* @constructor Creates a Doer instance with a Robot. * @constructor Creates a Doer instance with a Robot.
*/ */
open class Doer(private val robot: Robot = Robot()) { open class Doer(private val robot: Robot = Robot()) {
companion object{ companion object {
/** /**
* The duration in milliseconds of one "tick". The duration of 600ms matches the tick duration of game servers. * The duration in milliseconds of one "tick". The duration of 600ms matches the tick duration of game servers.
* *
@ -48,7 +48,6 @@ open class Doer(private val robot: Robot = Robot()) {
} }
/** /**
* Extra padding in milliseconds added before actions to account for latency. 500ms is entirely arbitrary. It is * Extra padding in milliseconds added before actions to account for latency. 500ms is entirely arbitrary. It is
* simply a value that works well during high-load periods. Better to be conservative than lossy. * simply a value that works well during high-load periods. Better to be conservative than lossy.
@ -283,6 +282,9 @@ open class Doer(private val robot: Robot = Robot()) {
* @param variance The amount of random variance to add in milliseconds. * @param variance The amount of random variance to add in milliseconds.
*/ */
fun sleep(dur: Long, variance: Long) { fun sleep(dur: Long, variance: Long) {
if (dur < 0 || variance <= 1) {
return
}
val dSize = (variance) / 2 val dSize = (variance) / 2
val r1 = Random.nextLong(dSize) val r1 = Random.nextLong(dSize)
val r2 = Random.nextLong(dSize) val r2 = Random.nextLong(dSize)

View File

@ -1,7 +1,7 @@
import java.awt.Point import java.awt.Point
fun main() { fun main() {
// Routines.fullRunIncense(0, 8916, 9462, 4808) Routines.fullRunIncense(29, 29, 29, 29)
Routines.processInventoryAtFurnace(100) // Routines.processInventoryAtFurnace(100)
} }

View File

@ -1,5 +1,4 @@
import java.awt.Point import java.awt.Point
import java.awt.event.InputEvent
import java.awt.event.KeyEvent import java.awt.event.KeyEvent
/** /**
@ -35,40 +34,39 @@ object Routines {
* actions at the bank. The bank location is prompted from the user. * actions at the bank. The bank location is prompted from the user.
* *
* Progress is printed after each step. Total elapsed time is printed at the end. * Progress is printed after each step. Total elapsed time is printed at the end.
* @deprecated Needs validation before using for real, as sawmill points are hardcoded
*/ */
fun fullRunIncense(volHerbs: Int, volLogs: Int, volAshes: Int, volCleanHerbs: Int) { fun fullRunIncense(volHerbs: Int, volLogs: Int, volAshes: Int, volCleanHerbs: Int) {
val start = System.currentTimeMillis() val start = System.currentTimeMillis()
//initialize the shared agent and chest point //initialize the shared agent and chest point
val agent = Agent() val agent = Agent()
val chest = agent.getBankPoint() val bankPoint = agent.getBankPoint()
// Loop to clean grimy herbs: // Loop to clean grimy herbs:
// Withdraw herb preset, clean without dialog at bank // Withdraw herb preset, clean without dialog at bank
if (volHerbs > 0) { if (volHerbs > 0) {
cleanHerbs(volHerbs) cleanHerbs(volHerbs, agent, bankPoint)
} }
println("\rHerbs cleaned") println("\rHerbs cleaned")
// Loop to cut magic logs into sticks: // Loop to cut magic logs into sticks:
// Withdraw log preset, cut logs using hotkey at bank // Withdraw log preset, cut logs using hotkey at bank
if (volLogs > 0) { if (volLogs > 0) {
cutIncenseSticks(volLogs) cutIncenseSticks(volLogs, agent, bankPoint)
} }
println("\rLogs cut into sticks") println("\rLogs cut into sticks")
// Loop to coat sticks in ashes: // Loop to coat sticks in ashes:
// Withdraw ash preset, coat sticks using hotkey at bank // Withdraw ash preset, coat sticks using hotkey at bank
if (volAshes > 0) { if (volAshes > 0) {
coatIncenseSticks(volAshes) coatIncenseSticks(volAshes, agent, bankPoint)
} }
println("\rSticks coated in ashes") println("\rSticks coated in ashes")
// Loop to infuse clean herbs into sticks: // Loop to infuse clean herbs into sticks:
// Withdraw herb preset, infuse sticks using hotkey at bank // Withdraw herb preset, infuse sticks using hotkey at bank
if (volCleanHerbs > 0) { if (volCleanHerbs > 0) {
infuseIncenseSticks(volCleanHerbs) infuseIncenseSticks(volCleanHerbs, agent, bankPoint)
} }
println("\rClean herbs infused") println("\rClean herbs infused")
@ -77,11 +75,11 @@ object Routines {
println("Entire chain finished in ${agent.prettyTimeString(finish - start)}") println("Entire chain finished in ${agent.prettyTimeString(finish - start)}")
} }
@Deprecated("Needs validation before you use it for realsies")
fun cleanHerbs(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { fun cleanHerbs(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
volume, volume,
28, CommonVolumesPerStep.FullInventory,
agent, agent,
bankPoint, bankPoint,
KeyEvent.VK_F1, KeyEvent.VK_F1,
@ -96,7 +94,7 @@ object Routines {
fun cutIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { fun cutIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
volume, volume,
28, CommonVolumesPerStep.FullInventory,
agent, agent,
bankPoint, bankPoint,
KeyEvent.VK_F2, KeyEvent.VK_F2,
@ -112,7 +110,7 @@ object Routines {
fun coatIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { fun coatIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
volume, volume,
28, CommonVolumesPerStep.CoatingIncenseWithAsh,
agent, agent,
bankPoint, bankPoint,
KeyEvent.VK_F3, KeyEvent.VK_F3,
@ -127,7 +125,7 @@ object Routines {
fun infuseIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { fun infuseIncenseSticks(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
volume, volume,
28, CommonVolumesPerStep.InfusingIncenseWithHerb,
agent, agent,
bankPoint, bankPoint,
KeyEvent.VK_F4, KeyEvent.VK_F4,
@ -142,7 +140,7 @@ object Routines {
fun craftPotionAtBank(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) { fun craftPotionAtBank(volume: Int, agent: Agent = Agent(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
volume, volume,
28, CommonVolumesPerStep.FullInventory,
agent, agent,
bankPoint, bankPoint,
KeyEvent.VK_F6, KeyEvent.VK_F6,
@ -163,7 +161,7 @@ object Routines {
val well = agent.promptUserForPoint("Put your mouse over the well...") val well = agent.promptUserForPoint("Put your mouse over the well...")
val params = TravelTaskParams( val params = TravelTaskParams(
volume, volume,
28, CommonVolumesPerStep.FullInventory,
agent, agent,
bankPoint, bankPoint,
well, well,