Class PatternPredictor


  • @Singleton
    public class PatternPredictor
    extends java.lang.Object
    Predicts the next interaction from the ones observed before it.

    Repetitive tasks such as mining, woodcutting or dropping items follow a steady sequence. Counting which action tends to follow which lets the cursor start moving toward the likely next target before the plugin asks for it.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear learned transitions.
      void confirmTransition​(java.lang.String context, java.lang.String from, java.lang.String to, long durationMs)
      Learn only after the caller observes completion, never from a submitted click.
      PatternPredictor.InventoryPattern detectInventoryPattern​(java.util.List<java.lang.Integer> slotHistory)
      Detect inventory pattern from a sequence of recent clicked slots.
      long getConfirmedSamples()  
      java.lang.String predictNext​(java.lang.String from)
      Predict the most probable next state from the given state.
      PatternPredictor.Prediction predictNext​(java.lang.String context, java.lang.String from)
      Two matching outcomes seed prediction; uncertain transitions remain unlearned.
      java.lang.String predictNextAction()
      Predict the next action given the most recent action.
      int predictNextInventorySlot​(int currentSlot, PatternPredictor.InventoryPattern pattern)
      Predict the next inventory slot in sequence (0-27).
      net.runelite.api.Point projectHeading​(net.runelite.api.Point current, double headingRad, double speedPxTick, double leadTicks)
      Project a spatial lead point along the player's current heading vector.
      void recordAction​(java.lang.String action)
      Record an action and update the transition counts.
      void recordTransition​(java.lang.String from, java.lang.String to)
      Record an observed interaction transition.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PatternPredictor

        public PatternPredictor()
    • Method Detail

      • confirmTransition

        public void confirmTransition​(java.lang.String context,
                                      java.lang.String from,
                                      java.lang.String to,
                                      long durationMs)
        Learn only after the caller observes completion, never from a submitted click.
      • predictNext

        public PatternPredictor.Prediction predictNext​(java.lang.String context,
                                                       java.lang.String from)
        Two matching outcomes seed prediction; uncertain transitions remain unlearned.
      • getConfirmedSamples

        public long getConfirmedSamples()
      • recordTransition

        public void recordTransition​(java.lang.String from,
                                     java.lang.String to)
        Record an observed interaction transition.
        Parameters:
        from - previous action or target descriptor
        to - subsequent action or target descriptor
      • recordAction

        public void recordAction​(java.lang.String action)
        Record an action and update the transition counts.
      • predictNextAction

        public java.lang.String predictNextAction()
        Predict the next action given the most recent action.
        Returns:
        predicted next action label, or null if insufficient data
      • predictNext

        public java.lang.String predictNext​(java.lang.String from)
        Predict the most probable next state from the given state.
      • predictNextInventorySlot

        public int predictNextInventorySlot​(int currentSlot,
                                            PatternPredictor.InventoryPattern pattern)
        Predict the next inventory slot in sequence (0-27).
        Parameters:
        currentSlot - current slot index (0 to 27)
        pattern - inventory traversal strategy
        Returns:
        next slot index (0 to 27), or -1 if sequence finished
      • detectInventoryPattern

        public PatternPredictor.InventoryPattern detectInventoryPattern​(java.util.List<java.lang.Integer> slotHistory)
        Detect inventory pattern from a sequence of recent clicked slots.
      • projectHeading

        public net.runelite.api.Point projectHeading​(net.runelite.api.Point current,
                                                     double headingRad,
                                                     double speedPxTick,
                                                     double leadTicks)
        Project a spatial lead point along the player's current heading vector.
        Parameters:
        current - current screen coordinate
        headingRad - angle in radians (0 = East, PI/2 = South, etc.)
        speedPxTick - movement speed in pixels per client tick
        leadTicks - number of ticks to project ahead
        Returns:
        anticipated lead point
      • clear

        public void clear()
        Clear learned transitions.