Class SimulationEngine


  • public final class SimulationEngine
    extends java.lang.Object
    Core simulation engine for snapshot-driven tree generation.
    • Constructor Detail

      • SimulationEngine

        public SimulationEngine()
    • Method Detail

      • createState

        public SimulationState createState​(SimulationScenario scenario)
        Creates a root state.
        Parameters:
        scenario - simulation scenario.
        Returns:
        mutable state.
      • createState

        public SimulationState createState​(SimulationSnapshot snapshot,
                                           java.util.Map<java.lang.Integer,​SimulationNpcProfile> npcProfilesById)
        Creates a root state.
        Parameters:
        snapshot - snapshot input.
        npcProfilesById - npc profile map.
        Returns:
        mutable state.
      • simulateTickCopy

        public SimulationState simulateTickCopy​(SimulationState state,
                                                SimulationAction action)
        Simulates one tick on a copied state.
        Parameters:
        state - source state.
        action - action to apply.
        Returns:
        copied state after one tick.
      • generateOutcomeTree

        public SimulationTree generateOutcomeTree​(SimulationScenario scenario)
        Generates an outcome tree using defaults.
        Parameters:
        scenario - scenario input.
        Returns:
        generated tree.
      • generateCandidateActions

        public java.util.List<SimulationAction> generateCandidateActions​(SimulationState state,
                                                                         int depthRemaining,
                                                                         SimulationTreeOptions options,
                                                                         SimulationEngine.ActionProvider actionProvider)
        Generates legal candidate actions for a node.
        Parameters:
        state - state input.
        depthRemaining - depth remaining.
        options - tree options.
        actionProvider - optional provider.
        Returns:
        legal action list.
      • canApplyPlayerAction

        public boolean canApplyPlayerAction​(SimulationState state,
                                            SimulationAction action)
        Checks whether an action is currently legal.
        Parameters:
        state - state.
        action - action.
        Returns:
        true when legal.
      • countNpcsWithLineOfSightToPlayer

        public int countNpcsWithLineOfSightToPlayer​(SimulationState state)
        Counts active NPC line-of-sight threats.
        Parameters:
        state - state.
        Returns:
        count.
      • countNpcsAbleToAttackPlayer

        public int countNpcsAbleToAttackPlayer​(SimulationState state)
        Counts active NPCs able to attack now.
        Parameters:
        state - state.
        Returns:
        count.
      • countUnprotectedNpcThreats

        public int countUnprotectedNpcThreats​(SimulationState state)
        Counts active threats not covered by active prayer.
        Parameters:
        state - state.
        Returns:
        count.
      • recommendProtectionPrayer

        public net.runelite.api.Prayer recommendProtectionPrayer​(SimulationState state)
        Returns the best overhead prayer based on the incoming hit.
        Parameters:
        state - state.
        Returns:
        prayer or null.
      • isPlayerTileSafe

        public boolean isPlayerTileSafe​(SimulationState state)
        Parameters:
        state - state.
        Returns:
        true when no npc currently has line of sight.
      • hasNpcLineOfSightToPlayer

        public boolean hasNpcLineOfSightToPlayer​(SimulationState state,
                                                 int npcSlot)
        Checks whether an npc has line of sight to the player.
        Parameters:
        state - state.
        npcSlot - npc slot.
        Returns:
        true when line of sight exists.
      • getNpcLineOfSightTiles

        public java.util.List<net.runelite.api.coords.WorldPoint> getNpcLineOfSightTiles​(SimulationState state,
                                                                                         int npcSlot)
        Returns npc-visible tiles using configured range.
        Parameters:
        state - state.
        npcSlot - npc slot.
        Returns:
        tiles.
      • getNpcLineOfSightTiles

        public java.util.List<net.runelite.api.coords.WorldPoint> getNpcLineOfSightTiles​(SimulationState state,
                                                                                         int npcSlot,
                                                                                         int range)
        Returns npc-visible tiles using explicit range.
        Parameters:
        state - state.
        npcSlot - npc slot.
        range - range.
        Returns:
        tiles.
      • predictNpcGreedyPathToPlayer

        public java.util.List<net.runelite.api.coords.WorldPoint> predictNpcGreedyPathToPlayer​(SimulationState state,
                                                                                               int npcSlot,
                                                                                               int maxSteps)
        Predicts npc pathing toward the player.
        Parameters:
        state - state.
        npcSlot - npc slot.
        maxSteps - max steps.
        Returns:
        path.
      • hasLineOfSight

        public boolean hasLineOfSight​(SimulationState state,
                                      net.runelite.api.coords.WorldPoint source,
                                      int sourceSize,
                                      net.runelite.api.coords.WorldPoint target,
                                      int range,
                                      boolean sourceIsNpc)
        World point line-of-sight overload.
        Parameters:
        state - state.
        source - source.
        sourceSize - source size.
        target - target.
        range - range.
        sourceIsNpc - true if source is npc footprint.
        Returns:
        true when line of sight exists.