EVE Anomaly Undock delaytimer after neutral enters the system

Hi everyone,

I’m completely new here and trying to understand all the things BotLab can be used for. Yesterday, I successfully ran one of the Anomaly Combat BOTs, but I couldn’t find an option to set a delay for undocking after a neutral enters the system and my ship docks. I often hunt bots this way, calculating how long it takes them to warp. If I could set, for example, a 5-minute delay, I probably wouldn’t wait. I’m trying to understand the code to implement this delay.

Hey, welcome @Goaulds!

I have not seen an example that has already implemented such a delay in response to the appearance of a neutral in the system.
However, there are already some other timers for other events, and we can copy their implementation and adapt it to your use case.
To set a delay for undocking, you can add a new field to the bot memory record: https://github.com/Viir/bots/blob/d1893841744bf2cfbda2fd28cb57c769b032d923/implement/applications/eve-online/eve-online-combat-anomaly-bot/Bot.elm#L255-L263
In that example linked above, some fields already model a time, like in the droneBandwidthLimitatatinEvents field. Typically, these use the number of milliseconds or seconds relative to the start of the session.

The new field in the memory record containing the time then enables you to branch into the undocking in the function that selects the next action. For example, you can store the time that the neutral appeared in the system in that field. In the function that decides your next action, you add your delay (which might come from the settings record) and compare that to the eventContext.timeInMilliseconds for the branch.
One example of a timer already implemented this way is for the anomalyWaitTimeSeconds/anomaly-wait-time setting:

[...]

    arrivalInAnomalyAgeSeconds =
        (context.eventContext.timeInMilliseconds - memoryOfAnomaly.arrivalTime.milliseconds) // 1000

[...]

        waitTimeRemainingSeconds =
            context.eventContext.botSettings.anomalyWaitTimeSeconds - arrivalInAnomalyAgeSeconds

        decisionIfNoEnemyToAttack =
            if overviewEntriesToAttack |> List.isEmpty then
                if waitTimeRemainingSeconds <= 0 then
                    returnDronesToBay context
                        |> Maybe.withDefault
                            (describeBranch "No drones to return." continueIfCombatComplete)
[...]

To set your timer, you check for the transition in the updateMemoryForNewReadingFromGame function. To be able to derive a list of all newly arrived pilots, you can add another field to the bot memory that only stores the names of all pilots in the system in the last step. This is analogous to how the linked example bot uses the shipWarpingInLastReading field to detect whether it just stopped warping.

You might also expand that feature to avoid undocking if the neutral is not in the system anymore when the timer expires. To do that, expand the type of the timer field to also store the name of the pilot. For example, it could look like this:

neutralEnteredSystem : Maybe { timeInSeconds : Int, pilotName : String }

You could use the name to compare it with the current list of pilots in the action selection. But it might be even better to reset the timer as soon as the pilot leaves the system in the updateMemoryForNewReadingFromGame function.