Package com.kraken.api.simulation
Class SimulationEngine
- java.lang.Object
-
- com.kraken.api.simulation.SimulationEngine
-
public final class SimulationEngine extends java.lang.ObjectGeneric Old School RuneScape simulation engine designed for high-frequency decision search.
-
-
Constructor Summary
Constructors Constructor Description SimulationEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanApplyPlayerAction(SimulationState state, SimulationAction action)Returns true when a single player step/run action is currently legal.intcountNpcsWithLineOfSightToPlayer(SimulationState state)Counts currently active NPCs that have line of sight to the player.SimulationStatecreateState(SimulationSnapshot snapshot)Creates a fresh mutable simulation state from an immutable snapshot.java.util.List<net.runelite.api.coords.WorldPoint>getNpcLineOfSightTiles(SimulationState state, int npcSlot)Returns the line-of-sight tile set for the specified NPC using its configured attack range.java.util.List<net.runelite.api.coords.WorldPoint>getNpcLineOfSightTiles(SimulationState state, int npcSlot, int range)Returns the line-of-sight tile set for the specified NPC using an explicit range override.booleanhasLineOfSight(SimulationState state, net.runelite.api.coords.WorldPoint source, int sourceSize, net.runelite.api.coords.WorldPoint target, int range, boolean sourceIsNpc)World-point overload for line-of-sight checks.booleanhasNpcLineOfSightToPlayer(SimulationState state, int npcSlot)Returns true when the given NPC currently has line of sight to the local simulated player.booleanisPlayerTileSafe(SimulationState state)java.util.List<net.runelite.api.coords.WorldPoint>predictNpcGreedyPathToPlayer(SimulationState state, int npcSlot, int maxSteps)Predicts the NPC's greedy movement path toward the simulated player without mutating the state.SimulationStatesimulateTick(SimulationState state, SimulationAction playerAction)Simulates one game tick in-place: apply player action, then move NPCs.SimulationStatesimulateTickCopy(SimulationState state, SimulationAction playerAction)Copies the provided state and simulates a single tick on the copy.SimulationStatesimulateTicks(SimulationState state, java.util.List<SimulationAction> playerActions, int ticks)Simulates many ticks using an ordered action list.
-
-
-
Method Detail
-
createState
public SimulationState createState(SimulationSnapshot snapshot)
Creates a fresh mutable simulation state from an immutable snapshot.- Parameters:
snapshot- immutable simulation input.- Returns:
- mutable state for stepping and branching.
-
simulateTickCopy
public SimulationState simulateTickCopy(SimulationState state, SimulationAction playerAction)
Copies the provided state and simulates a single tick on the copy.- Parameters:
state- The state to copyplayerAction- The player action to simulate- Returns:
- SimulationState the copied simulation state
-
simulateTick
public SimulationState simulateTick(SimulationState state, SimulationAction playerAction)
Simulates one game tick in-place: apply player action, then move NPCs.- Parameters:
state- The current state of the simulationplayerAction- The player action to simulate- Returns:
- SimulationState the simulation state after the single tick
-
simulateTicks
public SimulationState simulateTicks(SimulationState state, java.util.List<SimulationAction> playerActions, int ticks)
Simulates many ticks using an ordered action list. If actions run out, WAIT is used.- Parameters:
state- The current state of the simulationplayerActions- The list of player action to simulateticks- The number of ticks to simulate- Returns:
- SimulationState the simulation state after the ticks have been simulated
-
canApplyPlayerAction
public boolean canApplyPlayerAction(SimulationState state, SimulationAction action)
Returns true when a single player step/run action is currently legal.- Parameters:
state- The state of the simulationaction- The action to simulate- Returns:
- Boolean true when a single player step/run action is currently legal.
-
hasNpcLineOfSightToPlayer
public boolean hasNpcLineOfSightToPlayer(SimulationState state, int npcSlot)
Returns true when the given NPC currently has line of sight to the local simulated player.- Parameters:
state- The state of the simulationnpcSlot- The npc slot to check line of sight for- Returns:
- Boolean, true when the given NPC currently has line of sight to the local simulated player.
-
countNpcsWithLineOfSightToPlayer
public int countNpcsWithLineOfSightToPlayer(SimulationState state)
Counts currently active NPCs that have line of sight to the player.- Parameters:
state- simulation state.- Returns:
- number of threatening NPCs with current LoS.
-
getNpcLineOfSightTiles
public java.util.List<net.runelite.api.coords.WorldPoint> getNpcLineOfSightTiles(SimulationState state, int npcSlot)
Returns the line-of-sight tile set for the specified NPC using its configured attack range.- Parameters:
state- The state of the simulationnpcSlot- The npc slot to check line of sight for- Returns:
- List, the tiles that the NPC has line of sight to
-
getNpcLineOfSightTiles
public java.util.List<net.runelite.api.coords.WorldPoint> getNpcLineOfSightTiles(SimulationState state, int npcSlot, int range)
Returns the line-of-sight tile set for the specified NPC using an explicit range override.- Parameters:
state- The state of the simulationnpcSlot- The npc slot to check line of sight forrange- The range of the NPC (how far it can see)- Returns:
- List The tiles that the NPC has line of sight to
-
isPlayerTileSafe
public boolean isPlayerTileSafe(SimulationState state)
- Parameters:
state- simulation state.- Returns:
- true when no active NPC has current line of sight to the player.
-
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 overload for line-of-sight checks.- Parameters:
state- simulation state.source- source tile.sourceSize- source footprint size.target- target tile.range- max allowed LoS range.sourceIsNpc- true when source is an NPC footprint anchor.- Returns:
- true when LoS exists under range/footprint constraints.
-
predictNpcGreedyPathToPlayer
public java.util.List<net.runelite.api.coords.WorldPoint> predictNpcGreedyPathToPlayer(SimulationState state, int npcSlot, int maxSteps)
Predicts the NPC's greedy movement path toward the simulated player without mutating the state.- Parameters:
state- The current state of the simulationnpcSlot- The NPC to predict pathing formaxSteps- The maximum number of pathing steps to predict- Returns:
- List of points for the NPC's greedy path toward the simulated player
-
-