Package com.kraken.api.simulation
Class SimulationEngine
- java.lang.Object
-
- com.kraken.api.simulation.SimulationEngine
-
public final class SimulationEngine extends java.lang.ObjectCore simulation engine for snapshot-driven tree generation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSimulationEngine.ActionProviderProvides extra actions while building a simulation tree.
-
Constructor Summary
Constructors Constructor Description SimulationEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanApplyPlayerAction(SimulationState state, SimulationAction action)Checks whether an action is currently legal.intcountNpcsAbleToAttackPlayer(SimulationState state)Counts active NPCs able to attack now.intcountNpcsWithLineOfSightToPlayer(SimulationState state)Counts active NPC line-of-sight threats.intcountUnprotectedNpcThreats(SimulationState state)Counts active threats not covered by active prayer.SimulationStatecreateState(SimulationScenario scenario)Creates a root state.SimulationStatecreateState(SimulationSnapshot snapshot, java.util.Map<java.lang.Integer,SimulationNpcProfile> npcProfilesById)Creates a root state.java.util.List<SimulationAction>generateCandidateActions(SimulationState state, int depthRemaining, SimulationTreeOptions options, SimulationEngine.ActionProvider actionProvider)Generates legal candidate actions for a node.SimulationTreegenerateOutcomeTree(SimulationScenario scenario)Generates an outcome tree using defaults.SimulationTreegenerateOutcomeTree(SimulationScenario scenario, SimulationTreeOptions options, SimulationEngine.ActionProvider actionProvider)Generates an outcome tree.java.util.List<net.runelite.api.coords.WorldPoint>getNpcLineOfSightTiles(SimulationState state, int npcSlot)Returns npc-visible tiles using configured range.java.util.List<net.runelite.api.coords.WorldPoint>getNpcLineOfSightTiles(SimulationState state, int npcSlot, int range)Returns npc-visible tiles using explicit range.booleanhasLineOfSight(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.booleanhasNpcLineOfSightToPlayer(SimulationState state, int npcSlot)Checks whether an npc has line of sight to the player.booleanisPlayerTileSafe(SimulationState state)java.util.List<net.runelite.api.coords.WorldPoint>predictNpcGreedyPathToPlayer(SimulationState state, int npcSlot, int maxSteps)Predicts npc pathing toward the player.net.runelite.api.PrayerrecommendProtectionPrayer(SimulationState state)Returns the best overhead prayer based on the incoming hit.SimulationStatesimulateTick(SimulationState state, SimulationAction action)Simulates one tick in place.SimulationStatesimulateTickCopy(SimulationState state, SimulationAction action)Simulates one tick on a copied state.
-
-
-
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.
-
simulateTick
public SimulationState simulateTick(SimulationState state, SimulationAction action)
Simulates one tick in place.- Parameters:
state- source state.action- action to apply.- Returns:
- same state instance.
-
generateOutcomeTree
public SimulationTree generateOutcomeTree(SimulationScenario scenario)
Generates an outcome tree using defaults.- Parameters:
scenario- scenario input.- Returns:
- generated tree.
-
generateOutcomeTree
public SimulationTree generateOutcomeTree(SimulationScenario scenario, SimulationTreeOptions options, SimulationEngine.ActionProvider actionProvider)
Generates an outcome tree.- Parameters:
scenario- scenario input.options- tree options.actionProvider- optional action provider.- 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.
-
-