Skip to content

Commit

Permalink
Improve efficiency for reading ship module button tooltips
Browse files Browse the repository at this point in the history
As discussed at #65, avoid the dependency on 'consecutive' readings of the tooltip: Expand the module tooltip reading function to support combining two readings even when other readings happened in between.
  • Loading branch information
Viir committed Jan 30, 2023
1 parent 2e46c38 commit 467d9cc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{- EVE Online combat anomaly bot version 2023-01-28
{- EVE Online combat anomaly bot version 2023-01-30
This bot uses the probe scanner to warp to combat anomalies and kills rats using drones and weapon modules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import EveOnline.VolatileProcessInterface as VolatileProcessInterface
import Json.Decode
import Json.Encode
import List.Extra
import Maybe.Extra
import String.Extra


Expand Down Expand Up @@ -161,7 +162,7 @@ type alias GameClientProcessSummary =

type alias ShipModulesMemory =
{ tooltipFromModuleButton : Dict.Dict String EveOnline.ParseUserInterface.ModuleButtonTooltip
, lastReadingTooltip : Maybe EveOnline.ParseUserInterface.ModuleButtonTooltip
, previousReadingTooltip : Maybe EveOnline.ParseUserInterface.ModuleButtonTooltip
}


Expand Down Expand Up @@ -219,7 +220,7 @@ getImageDataFromReadingRequestLimit =
initShipModulesMemory : ShipModulesMemory
initShipModulesMemory =
{ tooltipFromModuleButton = Dict.empty
, lastReadingTooltip = Nothing
, previousReadingTooltip = Nothing
}


Expand All @@ -231,9 +232,9 @@ integrateCurrentReadingsIntoShipModulesMemory currentReading memoryBefore =
|> EveOnline.ParseUserInterface.getAllContainedDisplayTextsWithRegion
|> List.map (Tuple.mapSecond .totalDisplayRegion)

{- To ensure robustness, we store a new tooltip only when the display texts match in two consecutive readings from the game client. -}
{- To ensure robustness, we store a new tooltip only when the display texts match in two readings from the game client. -}
tooltipAvailableToStore =
case ( memoryBefore.lastReadingTooltip, currentReading.moduleButtonTooltip ) of
case ( memoryBefore.previousReadingTooltip, currentReading.moduleButtonTooltip ) of
( Just previousTooltip, Just currentTooltip ) ->
if getTooltipDataForEqualityComparison previousTooltip == getTooltipDataForEqualityComparison currentTooltip then
Just currentTooltip
Expand Down Expand Up @@ -271,7 +272,9 @@ integrateCurrentReadingsIntoShipModulesMemory currentReading memoryBefore =
|> Dict.filter (\moduleButtonId _ -> visibleModuleButtonsIds |> List.member moduleButtonId)
in
{ tooltipFromModuleButton = tooltipFromModuleButton
, lastReadingTooltip = currentReading.moduleButtonTooltip
, previousReadingTooltip =
currentReading.moduleButtonTooltip
|> Maybe.Extra.orElse memoryBefore.previousReadingTooltip
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{- EVE Online mining bot version 2023-01-28
{- EVE Online mining bot version 2023-01-30
The bot warps to an asteroid belt, mines there until the mining hold is full, and then docks at a station or structure to unload the ore. It then repeats this cycle until you stop it.
If no station name or structure name is given with the bot-settings, the bot docks again at the station where it was last docked.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import EveOnline.VolatileProcessInterface as VolatileProcessInterface
import Json.Decode
import Json.Encode
import List.Extra
import Maybe.Extra
import String.Extra


Expand Down Expand Up @@ -161,7 +162,7 @@ type alias GameClientProcessSummary =

type alias ShipModulesMemory =
{ tooltipFromModuleButton : Dict.Dict String EveOnline.ParseUserInterface.ModuleButtonTooltip
, lastReadingTooltip : Maybe EveOnline.ParseUserInterface.ModuleButtonTooltip
, previousReadingTooltip : Maybe EveOnline.ParseUserInterface.ModuleButtonTooltip
}


Expand Down Expand Up @@ -219,7 +220,7 @@ getImageDataFromReadingRequestLimit =
initShipModulesMemory : ShipModulesMemory
initShipModulesMemory =
{ tooltipFromModuleButton = Dict.empty
, lastReadingTooltip = Nothing
, previousReadingTooltip = Nothing
}


Expand All @@ -231,9 +232,9 @@ integrateCurrentReadingsIntoShipModulesMemory currentReading memoryBefore =
|> EveOnline.ParseUserInterface.getAllContainedDisplayTextsWithRegion
|> List.map (Tuple.mapSecond .totalDisplayRegion)

{- To ensure robustness, we store a new tooltip only when the display texts match in two consecutive readings from the game client. -}
{- To ensure robustness, we store a new tooltip only when the display texts match in two readings from the game client. -}
tooltipAvailableToStore =
case ( memoryBefore.lastReadingTooltip, currentReading.moduleButtonTooltip ) of
case ( memoryBefore.previousReadingTooltip, currentReading.moduleButtonTooltip ) of
( Just previousTooltip, Just currentTooltip ) ->
if getTooltipDataForEqualityComparison previousTooltip == getTooltipDataForEqualityComparison currentTooltip then
Just currentTooltip
Expand Down Expand Up @@ -271,7 +272,9 @@ integrateCurrentReadingsIntoShipModulesMemory currentReading memoryBefore =
|> Dict.filter (\moduleButtonId _ -> visibleModuleButtonsIds |> List.member moduleButtonId)
in
{ tooltipFromModuleButton = tooltipFromModuleButton
, lastReadingTooltip = currentReading.moduleButtonTooltip
, previousReadingTooltip =
currentReading.moduleButtonTooltip
|> Maybe.Extra.orElse memoryBefore.previousReadingTooltip
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{- EVE Online warp-to-0 auto-pilot version 2023-01-28
{- EVE Online warp-to-0 auto-pilot version 2023-01-30
This bot makes your travels faster and safer by directly warping to gates/stations. It follows the route set in the in-game autopilot and uses the context menu to initiate jump and dock commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import EveOnline.VolatileProcessInterface as VolatileProcessInterface
import Json.Decode
import Json.Encode
import List.Extra
import Maybe.Extra
import String.Extra


Expand Down Expand Up @@ -161,7 +162,7 @@ type alias GameClientProcessSummary =

type alias ShipModulesMemory =
{ tooltipFromModuleButton : Dict.Dict String EveOnline.ParseUserInterface.ModuleButtonTooltip
, lastReadingTooltip : Maybe EveOnline.ParseUserInterface.ModuleButtonTooltip
, previousReadingTooltip : Maybe EveOnline.ParseUserInterface.ModuleButtonTooltip
}


Expand Down Expand Up @@ -219,7 +220,7 @@ getImageDataFromReadingRequestLimit =
initShipModulesMemory : ShipModulesMemory
initShipModulesMemory =
{ tooltipFromModuleButton = Dict.empty
, lastReadingTooltip = Nothing
, previousReadingTooltip = Nothing
}


Expand All @@ -231,9 +232,9 @@ integrateCurrentReadingsIntoShipModulesMemory currentReading memoryBefore =
|> EveOnline.ParseUserInterface.getAllContainedDisplayTextsWithRegion
|> List.map (Tuple.mapSecond .totalDisplayRegion)

{- To ensure robustness, we store a new tooltip only when the display texts match in two consecutive readings from the game client. -}
{- To ensure robustness, we store a new tooltip only when the display texts match in two readings from the game client. -}
tooltipAvailableToStore =
case ( memoryBefore.lastReadingTooltip, currentReading.moduleButtonTooltip ) of
case ( memoryBefore.previousReadingTooltip, currentReading.moduleButtonTooltip ) of
( Just previousTooltip, Just currentTooltip ) ->
if getTooltipDataForEqualityComparison previousTooltip == getTooltipDataForEqualityComparison currentTooltip then
Just currentTooltip
Expand Down Expand Up @@ -271,7 +272,9 @@ integrateCurrentReadingsIntoShipModulesMemory currentReading memoryBefore =
|> Dict.filter (\moduleButtonId _ -> visibleModuleButtonsIds |> List.member moduleButtonId)
in
{ tooltipFromModuleButton = tooltipFromModuleButton
, lastReadingTooltip = currentReading.moduleButtonTooltip
, previousReadingTooltip =
currentReading.moduleButtonTooltip
|> Maybe.Extra.orElse memoryBefore.previousReadingTooltip
}


Expand Down

0 comments on commit 467d9cc

Please sign in to comment.