put the comments on a diet

This commit is contained in:
dtookey 2023-08-15 21:16:25 -04:00
parent 0f0c343a85
commit ee9287972f
7 changed files with 23 additions and 154 deletions

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration"> <component name="FrameworkDetectionExcludesConfiguration">

View File

@ -1,7 +1,7 @@
import game_logic.runescape.RunescapeRoutines import game_logic.runescape.RunescapeRoutines
fun main() { fun main() {
// RunescapeRoutines.fullRunIncense(0, 4514, 4870, 308) // RunescapeRoutines.fullRunIncense(0, 158, 348, 0)
RunescapeRoutines.createNecromancyInk(2960) RunescapeRoutines.processInventoryAtFurnace(2500)
} }

View File

@ -29,7 +29,7 @@ interface TemporalController {
val duration = if(maxAdditionalDuration == 0L){ val duration = if(maxAdditionalDuration == 0L){
baseDuration baseDuration
}else{ }else{
baseDuration + util.HelperFunctions.getGaussianLong(maxAdditionalDuration) baseDuration + util.HelperFunctions.getApproximatelyNormalLong(maxAdditionalDuration)
} }
TimeUnit.MILLISECONDS.sleep(duration) TimeUnit.MILLISECONDS.sleep(duration)

View File

@ -79,7 +79,7 @@ interface User32 : StdCallLibrary {
* @param userData Optional user-defined data to pass to the callback. * @param userData Optional user-defined data to pass to the callback.
* @return True if successful, false otherwise. * @return True if successful, false otherwise.
*/ */
fun EnumWindows(lpEnumFunc: WNDENUMPROC?, userData: Pointer?): Boolean fun EnumWindows(lpEnumFunc: StdCallLibrary.StdCallCallback?, userData: Pointer?): Boolean
/** /**
* Gets the title text of the specified window. * Gets the title text of the specified window.

View File

@ -48,28 +48,6 @@ object RunescapeRoutines {
* @param volLogs The number of magic logs to cut into sticks. * @param volLogs The number of magic logs to cut into sticks.
* @param volAshes The number of sticks to coat in ashes. * @param volAshes The number of sticks to coat in ashes.
* @param volCleanHerbs The number of clean herbs to infuse into sticks. * @param volCleanHerbs The number of clean herbs to infuse into sticks.
*
* This handles the entire incense stick crafting process:
* - Cleaning grimy herbs
* - Cutting magic logs into sticks
* - Coating sticks in ashes
* - Infusing clean herbs into sticks
*
* It loops through each step based on the provided volumes, performing the
* actions at the bank.
*
* Usage example:
*
* ```
* val herbs = 1000
* val logs = 2000
* val ashes = 1500
* val cleanHerbs = herbs + 150
*
* Routines.fullRunIncense(herbs, logs, ashes, cleanHerbs)
* ```
*
* Progress is printed after each step. Total elapsed time is printed at the end.
*/ */
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()
@ -126,24 +104,6 @@ object RunescapeRoutines {
* @param agent Optional. The Agent instance to use for banking actions. * @param agent Optional. The Agent instance to use for banking actions.
* @param bankPoint Optional. The Point location of the bank to use. * @param bankPoint Optional. The Point location of the bank to use.
* *
* This handles the workflow of:
* - Withdrawing grimy herb preset
* - Cleaning grimy herbs without dialog
* - Depositing clean herbs
*
* It performs the actions at the bank location using the provided agent.
*
* Usage examples:
* ```
* val volume = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
* Routines.cleanHerbs(volume, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
* ```
* Routines.cleanHerbs(1000)
* ```
*/ */
fun cleanHerbs(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) { fun cleanHerbs(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
@ -166,23 +126,6 @@ object RunescapeRoutines {
* @param agent Optional. The Agent instance to use for banking actions. * @param agent Optional. The Agent instance to use for banking actions.
* @param bankPoint Optional. The Point location of the bank to use. * @param bankPoint Optional. The Point location of the bank to use.
* *
* This handles the workflow of:
* - Withdrawing magic log preset
* - Cutting magic logs into incense sticks without dialog
* - Depositing incense sticks
*
* Usage examples:
* ```
* val logs = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
*
* Routines.cutIncenseSticks(logs, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
* ```
* Routines.cutIncenseSticks(1000)
* ```
*/ */
fun cutIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) { fun cutIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
@ -205,24 +148,6 @@ object RunescapeRoutines {
* @param agent Optional Agent instance to use for banking actions. * @param agent Optional Agent instance to use for banking actions.
* @param bankPoint Optional Point location of the bank to use. * @param bankPoint Optional Point location of the bank to use.
* *
* This handles the workflow of:
* - Withdrawing incense stick preset
* - Coating incense sticks with ashes using hotkey
* - Depositing coated sticks
*
* Usage examples:
* ```
* val sticks = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
*
* Routines.coatIncenseSticks(sticks, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
*
* ```
* Routines.coatIncenseSticks(1000)
* ```
*/ */
fun coatIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) { fun coatIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
@ -243,24 +168,6 @@ object RunescapeRoutines {
* @param volume The number of incense sticks to infuse with herbs. * @param volume The number of incense sticks to infuse with herbs.
* @param agent Optional Agent instance to use for banking actions. * @param agent Optional Agent instance to use for banking actions.
* @param bankPoint Optional Point location of the bank to use. * @param bankPoint Optional Point location of the bank to use.
*
* This handles the workflow of:
* - Withdrawing incense stick preset
* - Infusing incense sticks with herbs using hotkey
* - Depositing infused incense sticks
*
* Usage examples:
* ```
* val sticks = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
*
* Routines.infuseIncenseSticks(sticks, agent, bankPoint)
* ```
* Can also omit agent and bankPoint to use defaults:
* ```
* Routines.infuseIncenseSticks(1000)
* ```
*/ */
fun infuseIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) { fun infuseIncenseSticks(volume: Int, agent: RSOrchestrator = RSOrchestrator.getInstance(), bankPoint: Point = agent.getBankPoint()) {
val params = StandingTaskParams( val params = StandingTaskParams(
@ -282,21 +189,6 @@ object RunescapeRoutines {
* @param agent The RSOrchestrator instance to use. Defaults to default instance. * @param agent The RSOrchestrator instance to use. Defaults to default instance.
* @param bankPoint The location of the bank. Defaults to agent's configured bank point. * @param bankPoint The location of the bank. Defaults to agent's configured bank point.
* *
* This method handles the workflow of crafting potions using hotkeys while standing at a bank:
*
* - It constructs a StandingTaskParams instance defining:
* - The volume, volume per trip, bank point, crafting hotkey, and other details
* - It calls the orchestrator's doStandingTask() method to execute the task.
*
* Usage example:
* ```
* val volume = 1000
* val bankPoint = Point(100, 200)
* val agent = RSAgent.getInstance()
* Routines.craftPotionsAtBank(volume, agent, bankPoint)
* ```
*
* Progress is automatically printed during execution.
* *
* @deprecated This method needs validation before use in production. * @deprecated This method needs validation before use in production.
*/ */
@ -316,32 +208,13 @@ object RunescapeRoutines {
/** /**
* Grinds potions using a well location for water. * Grinds potions using a well location for water.
* It prompts the user to position the mouse over the well location to get its coordinates.
* *
* @param volume The total number of potions to make. * @param volume The total number of potions to make.
* @param travelDurationInMillis The time in ms for the agent to travel between the bank and the well. * @param travelDurationInMillis The time in ms for the agent to travel between the bank and the well.
* @param agent The RSOrchestrator instance to use. Defaults to the default instance. * @param agent The RSOrchestrator instance to use. Defaults to the default instance.
* @param bankPoint The Point location of the bank. Defaults to the agent's configured bank point. * @param bankPoint The Point location of the bank. Defaults to the agent's configured bank point.
* *
* This method handles the workflow of grinding potions using a well as the water source.
*
* It prompts the user to position the mouse over the well location to get its coordinates.
*
* It then constructs a TravelTaskParams instance to define:
* - The volume, volume per trip, bank point, well point, and other task details.
*
* It calls the orchestrator's doTravelTask() method to execute the grinding task.
*
* Usage example:
* ```
* val volume = 1000
* val travelDuration = 5000 // 5 seconds
* val bankPoint = Point(100, 200)
* val wellPoint = Point(300, 400) // Prompted from user
* Routines.potionGrindWithWell(volume, travelDuration, bankPoint, wellPoint)
* ```
*
* Progress is automatically printed during execution.
*
* @deprecated This method needs validation before use in production. * @deprecated This method needs validation before use in production.
*/ */
@Deprecated("Needs validation before you use it for realsies") @Deprecated("Needs validation before you use it for realsies")
@ -397,7 +270,7 @@ object RunescapeRoutines {
fun processInventoryAtFurnace(volume: Int) { fun processInventoryAtFurnace(volume: Int) {
//these two points are specific to my computer. we need to export these into a file or something //these two points are specific to my computer. we need to export these into a file or something
val furnaceFromChest = Point(776, 321) val furnaceFromChest = Point(776, 321)
val chestFromFurnance = Point(1713, 843) val chestFromFurnance = Point(1813, 893)
val agent = RSOrchestrator.getInstance() val agent = RSOrchestrator.getInstance()
val params = TravelTaskParams( val params = TravelTaskParams(
volume, volume,

View File

@ -32,29 +32,26 @@ object HelperFunctions {
0 0
} }
/** /**
* Generates a random long value approximating a normal distribution. * Generates a random long that approximates a normal distribution.
* *
* Takes two random samples from 0 to upperBound/2 and adds them together. This approximates a normal distribution * Works by taking two random samples from 0 to upperBound/2 and adding them together. This tends to give a more natural
* better than a single random sample. * spread than a single random sample.
* *
* @param upperBound The upper bound to sample from * This approach relies on the Central Limit Theorem: that the sum of multiple independent random variables will
* @return A random long value following an approximate normal distribution * tend towards a normal distribution, even if the original variables themselves are not normally distributed.
*
* @param upperBound The upper bound for the random range. Must be >= 2.
* @return A random long value following an approximate normal distribution.
*/ */
fun getGaussianLong(upperBound: Long): Long { fun getApproximatelyNormalLong(upperBound: Long): Long {
// anything lower to 2 will round down to zero, so return zero. Additionally, this guarantees a positive upper // anything lower to 2 will round down to zero, so return zero. Additionally, this guarantees a positive upper
//bound in one step //bound in one step
if (upperBound <= 2L) { if (upperBound < 2L) {
return 0L return 0L
} }
// Generate two random longs from 0 to upperBound/2 and add them together to approximate a normal distribution.
// To create more natural distribution Take two random samples from 0 to upperBound/2 and add them. This return Random.nextLong(upperBound.shr(1)) + Random.nextLong(upperBound.shr(1))
// approximates a normal distribution better than single random sample.
val subBound = upperBound / 2L
val result1 = Random.nextLong(subBound)
val result2 = Random.nextLong(subBound)
return result1 + result2
} }
/** /**
@ -66,6 +63,7 @@ object HelperFunctions {
* @return A random long value * @return A random long value
*/ */
fun getNextGaussian(upperBound: Long): Long { fun getNextGaussian(upperBound: Long): Long {
require(upperBound > 0)
return java.util.Random() return java.util.Random()
.nextGaussian( .nextGaussian(
upperBound.toDouble() / 2.0, upperBound.toDouble() / 2.0,

View File

@ -2,7 +2,6 @@ package util
import kotlin.math.pow import kotlin.math.pow
import kotlin.system.measureNanoTime import kotlin.system.measureNanoTime
import kotlin.system.measureTimeMillis
import kotlin.test.Test import kotlin.test.Test
@ -16,7 +15,7 @@ class HelperFunctionsTest {
val numSamples = 10000 val numSamples = 10000
val upperBound = 1000L val upperBound = 1000L
val samples = (1..numSamples).map { val samples = (1..numSamples).map {
HelperFunctions.getGaussianLong(upperBound) HelperFunctions.getApproximatelyNormalLong(upperBound)
} }
// Calculate mean and standard deviation // Calculate mean and standard deviation
@ -40,7 +39,7 @@ class HelperFunctionsTest {
val samples = ArrayList<Long>(iterations) val samples = ArrayList<Long>(iterations)
val time = doBenchmark(iterations, upperBound) { val time = doBenchmark(iterations, upperBound) {
val v = HelperFunctions.getGaussianLong(it) val v = HelperFunctions.getApproximatelyNormalLong(it)
samples.add(v) samples.add(v)
v v
} }
@ -105,7 +104,7 @@ class HelperFunctionsTest {
println("Warming up for a few iterations") println("Warming up for a few iterations")
val consumer = ArrayList<Long>(iterations) val consumer = ArrayList<Long>(iterations)
repeat(iterations){ repeat(iterations){
consumer.add(HelperFunctions.getGaussianLong(upperBound)) consumer.add(HelperFunctions.getApproximatelyNormalLong(upperBound))
consumer.add(HelperFunctions.getNextGaussian(upperBound)) consumer.add(HelperFunctions.getNextGaussian(upperBound))
} }
@ -114,7 +113,7 @@ class HelperFunctionsTest {
var total = 0L var total = 0L
val time1 = measureNanoTime { val time1 = measureNanoTime {
repeat(iterations) { repeat(iterations) {
total += HelperFunctions.getGaussianLong(upperBound) total += HelperFunctions.getApproximatelyNormalLong(upperBound)
} }
} }