Skip to content

Refactoring Strategies & Selectors (EAP-version)

Pre-release
Pre-release
Compare
Choose a tag to compare
@Hotzkow Hotzkow released this 25 Jul 13:46

Refactoring of the previous design of Exploration-Strategies and Strategy-Selector to get rid of necessary base strategies like Back, Terminate etc. Basically all previously default 'selectors' were invoking some exploration action and are thus now inheriting from AExplorationStrategy instead.

Note: this is an eap version, it contains many deprecation annotations which can be used for easy migration before switching to the newer version of DM-2.

Changelog:

  • all old classes and interfaces for strategies and selectors were replaced by
    IActionSelector parent interface used in the exploration loop to abstract away if the next action is determined by a selector or a strategy directly

    AExplorationStrategy all strategies should inherit from this class. Strategies are assumed to always have a next action, if this is not the case for yours you should overwrite hasNext(eContext): Boolean. By default the very first action of any exploration is going to be an app launch, if you want to differ from this behavior you have to overwrite nextAction(eContext):ExplorationAction
    A strategy has to implement the methods

    • getPriority() : Int // this value is ranked against all other strategies and selectors to decide who is going to deliver the next exploration action
    • computeNextAction(eContext) : ExplorationAction // the next action to be executed

    AStrategySelector can be used if you want to 'switch' between different strategies depending on the current exploration context (e.g. to implement some fallback to random).
    You have to implement the method selectStrategy(eContext):AExplorationStrategy. The returned strategy is used to determine the next action by calling its nextAction method.

  • all previous default 'selectors' (now strategies) can be retrieved by accessing the respective function in the new object DefaultStrategies

  • the Exploration-API was extended with some convenience function to directly pass lists of strategies and selectors, such that it is no longer mandatory to use a command builder. However when using these function, no default strategies or selectors are going to be used.