From b88c998c0ab1de75cf4a685d164c607e157d918c Mon Sep 17 00:00:00 2001 From: dtookey Date: Sat, 5 Aug 2023 08:04:53 -0400 Subject: [PATCH] better docs regarding the new params and agent changes --- src/main/kotlin/Agent.kt | 17 ++++-- src/main/kotlin/TaskParams.kt | 104 +++++++++++++++++++++++++++++----- 2 files changed, 103 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/Agent.kt b/src/main/kotlin/Agent.kt index b011342..7addf57 100644 --- a/src/main/kotlin/Agent.kt +++ b/src/main/kotlin/Agent.kt @@ -2,14 +2,21 @@ import java.awt.Point import java.awt.event.KeyEvent /** - * Agent represents an autonomous agent that can simulate mouse and keyboard actions. + * Agent handles lower level actions like banking, navigation, and timing + * to support automation routines. * - * This class provides methods for the agent to perform actions like moving the mouse, - * clicking, pressing keys, prompting the user, and looping through repetitive tasks. + * This provides a common set of primitive actions that can be used across + * different automation workflows. Routines build on top of these actions. * - * The Agent uses a Doer instance internally to execute low-level keyboard and mouse operations. + * The agent handles things like: + * - Bank interaction (presets, deposits, withdrawals) + * - Navigation points and travel + * - Timing actions with randomness + * - Progress reporting and logging * - * @property doer The Doer used by this Agent for simulating user input. + * By encapsulating these common actions, routines can focus on their + * specific workflow logic and leverage the agent for the lower level + * activities needed to craft, cook, etc. */ class Agent: Doer() { diff --git a/src/main/kotlin/TaskParams.kt b/src/main/kotlin/TaskParams.kt index 6dba5ef..2c91e1d 100644 --- a/src/main/kotlin/TaskParams.kt +++ b/src/main/kotlin/TaskParams.kt @@ -1,37 +1,95 @@ import java.awt.Point /** - * Configuration parameters for routines. + * Interface for common task parameters used across automation routines. * - * @param totalVolume The total number of items to process in the routine. - * @param volumePerStep The volume of items to process per loop iteration. - * @param agent The Agent instance to use for actions like banking. - * @param chest The Point location of the bank chest to use. + * This defines standard fields needed by most routines like total volume, + * volume per step, and the Agent instance. + * + * By extending this interface, routine parameter classes get these + * common fields for free. + * + * @property totalVolume The total number of items to process in the routine. + * @property volumePerStep The volume of items to process per step. + * @property agent The Agent instance that will run the routine. */ interface TaskParams { val totalVolume: Int val volumePerStep: Int val agent: Agent - } -interface BankParams{ +/** + * Interface for bank related parameters used in automation routines. + * + * Routines that involve banking items will need bank specific + * configuration like location and preset hotkeys. + * + * This interface encapsulates those common bank parameters. Classes + * that represent task params should implement this if banking is required. + * + * @property bankPoint The Point location of the bank to use. + * @property bankPresetHotkey The bank preset hotkey to withdraw/deposit items. + */ +interface BankParams { val bankPoint: Point val bankPresetHotkey: Int } -interface CraftingParams{ +/** + * Interface for crafting related parameters used in automation routines. + * + * Routines that involve a crafting action like fletching, cooking, etc will + * need crafting specific configuration like hotkeys and timing. + * + * This interface encapsulates those common crafting parameters. Classes + * that represent task params should implement this if they involve crafting. + * + * @property craftingDialogHotkey The hotkey used to open the crafting dialog. + * @property craftingWaitDurationMillis Base time in ms to wait after crafting. + * @property craftingWaitDurationVarianceMillis Random variance added to wait. + */ +interface CraftingParams { val craftingDialogHotkey: Int val craftingWaitDurationMillis: Long val craftingWaitDurationVarianceMillis: Long } -interface TravelParams{ +/** + * Interface for travel related parameters used in automation routines. + * + * Routines that involve traveling between a bank and activity area (e.g. + * crafting, cooking) will need travel related configuration. + * + * This interface encapsulates those common travel params. Classes that + * represent travel task params should implement this interface. + * + * @property travelPoint The Point destination to travel to. + * @property travelDurationMillis The expected travel time in milliseconds. + * @property travelDurationVarianceMillis Random variance to apply to the + * travel time. This helps simulate human-like travel. + */ +interface TravelParams { val travelPoint: Point val travelDurationMillis: Long val travelDurationVarianceMillis: Long } +/** + * Task parameters for routines performed while standing in one spot. + * + * This represents routines like fletching, cooking, etc. that are done + * without traveling between a bank and activity area. + * + * @param totalVolume Total number of items to process. + * @param volumePerStep The volume of items to process per iteration. + * @param agent The Agent instance. + * @param bankPoint Location of the bank. + * @param bankPresetHotkey Bank preset hotkey to use. + * @param craftingDialogHotkey Hotkey to open crafting dialog. + * @param craftingWaitDurationMillis Crafting action duration. + * @param craftingWaitDurationVarianceMillis Random variance for duration. + */ data class StandingTaskParams( override val totalVolume: Int, override val volumePerStep: Int, @@ -41,9 +99,29 @@ data class StandingTaskParams( override val craftingDialogHotkey: Int, override val craftingWaitDurationMillis: Long, override val craftingWaitDurationVarianceMillis: Long -): TaskParams, BankParams, CraftingParams - +) : TaskParams, BankParams, CraftingParams +/** + * Task parameters for routines that involve traveling. + * + * This encapsulates all the configuration needed for routines where the + * player travels between a bank and activity area for crafting, cooking, etc. + * + * It brings together the common [TaskParams], bank [BankParams], crafting + * [CraftingParams], and travel [TravelParams] parameters into one data class. + * + * @param totalVolume Total number of items to process. + * @param volumePerStep The volume of items per crafting iteration. + * @param agent The Agent instance. + * @param bankPoint The bank location. + * @param travelPoint The travel destination. + * @param bankPresetHotkey Hotkey for bank preset. + * @param craftingDialogHotkey Hotkey to open crafting dialog. + * @param craftingWaitDurationMillis Base crafting action time. + * @param craftingWaitDurationVarianceMillis Crafting time variance. + * @param travelDurationMillis Expected travel time. + * @param travelDurationVarianceMillis Travel time variance. + */ data class TravelTaskParams( override val totalVolume: Int, override val volumePerStep: Int, @@ -51,12 +129,12 @@ data class TravelTaskParams( override val bankPoint: Point, override val travelPoint: Point, override val bankPresetHotkey: Int, - override val craftingDialogHotkey: Int = -1, + override val craftingDialogHotkey: Int = -1, //all current travel tasks click the thing that starts the crafting dialogue override val craftingWaitDurationMillis: Long, override val craftingWaitDurationVarianceMillis: Long, override val travelDurationMillis: Long, override val travelDurationVarianceMillis: Long -): TaskParams, BankParams, CraftingParams, TravelParams +) : TaskParams, BankParams, CraftingParams, TravelParams /** * CommonVolumesPerStep provides constants for common inventory volumes used during routines.