public final class Navigation
extends Object
Note that navigation is one of the most computationally expensive functions the bot will likely use. You can limit the search by specifying a low maxSteps. When using the IPredicate function variants, efficient implementation of the predicate is crucial.
By default the functions will automatically make use of safe items like a pick-axe or rings of levitation. Furthermore:
isEnteringShop(IGame)
)
NavOption
when using navigate(bothack.bot.IGame, bothack.bot.IPosition, bothack.actions.NavOption...)
.
Exploration and seeking will however always use the listed behaviors.
When seeking/searching, the bot will generally:
Seaching in sokoban levels is not recommended and may get the bot stuck.
You should use ActionsComplex.doSokoban(IGame)
in sokoban.
All level navigation functions automatically choose A* or Dijkstra's algorithm depending on the number of targets. The step cost function currently can't be influenced by the user.
Modifier and Type | Class and Description |
---|---|
static interface |
Navigation.IPath
Representation of a navigation result.
|
Modifier and Type | Method and Description |
---|---|
static IAction |
branchEntrance(IGame game,
Branch branch)
Return Dlvl of
Branch.MAIN containing the entrance to branch, if static or already visited |
static IAction |
explore(IGame game,
Branch branch)
Returns an action to explore the dungeon up to and including end of the given branch.
|
static IAction |
explore(IGame game,
Branch branch,
LevelTag tag)
Returns an action to explore the dungeon up to and including the specified level.
|
static IAction |
exploreCurrentLevel(IGame game)
Returns an action to explore the current level and items or null if it seems fully explored.
|
static IAction |
exploreLevel(IGame game,
Branch branch,
LevelTag tag)
Unless the specified level already seems fully explored, returns an
action to go to that level or explore it.
|
static IAction |
exploreLevel(IGame game,
Branch branch,
String dlvl)
Unless the specified level already seems fully explored, returns an
action to go to that level or explore it.
|
static Boolean |
isEnteringShop(IGame game)
Returns true if the player is just about to enter a shop and should not pick up pickaxes.
|
static List<IPosition> |
lastPath(IGame game)
Returns the intended path of the last performed action – if it was
generated by some of the methods of this class.
|
static Navigation.IPath |
navigate(IGame game,
IPosition target,
long maxSteps,
NavOption... opts)
Returns the shortest path to the given target and an action to perform to move along it.
|
static Navigation.IPath |
navigate(IGame game,
IPosition target,
NavOption... opts)
Returns the shortest path to the given target and an action to perform to move along it.
|
static Navigation.IPath |
navigate(IGame game,
IPredicate<ITile> target,
long maxSteps,
NavOption... opts)
Returns the shortest path to a matching target and an action to perform to move along it.
|
static Navigation.IPath |
navigate(IGame game,
IPredicate<ITile> target,
NavOption... opts)
Returns the shortest path to a matching target and an action to perform to move along it.
|
static IAction |
searchCurrentLevel(IGame game)
Returns an action to explore or search the current level or null if the first
round of searching is already done.
|
static IAction |
searchCurrentLevelRepeatedly(IGame game)
Returns an action to explore or search the current level repeatedly.
|
static IAction |
seek(IGame game,
IPosition target)
Returns an action to look for the specified tile on the current level or
null if already standing at a matching tile.
|
static IAction |
seek(IGame game,
IPredicate<ITile> target)
Returns an action to look for the specified tile on the current level or
null if already standing at a matching tile.
|
static IAction |
seekBranch(IGame game,
Branch branch)
Returns an action to look for the specified branch or null if already there.
|
static IAction |
seekInterlevel(IGame game,
IPredicate<ITile> target)
Interlevel navigation to the nearest matching tile.
|
static IAction |
seekInterlevel(IGame game,
IPredicate<ITile> target,
long maxDelta)
Intralevel navigation to the nearest matching tile.
|
static IAction |
seekInterlevelUpwards(IGame game,
IPredicate<ITile> target)
Like
seekInterlevel(IGame, IPredicate) but will only change levels
upwards and avoid subbranches. |
static IAction |
seekInterlevelUpwards(IGame game,
IPredicate<ITile> target,
long maxDelta)
Like
seekInterlevel(IGame, IPredicate) but will only change levels
upwards and avoid subbranches. |
static IAction |
seekLevel(IGame game,
Branch branch,
LevelTag tag)
Returns an action to go to the specified level or null if already there.
|
static IAction |
seekLevel(IGame game,
Branch branch,
String dlvl)
Returns an action to go to the specified level or null if already there.
|
static IAction |
visitBranch(IGame game,
Branch branch)
If the specified branch has never been visited, returns the action to navigate to it
and possibly explore it until identified.
|
static IAction |
visitLevel(IGame game,
Branch branch,
LevelTag tag)
If the specified level has never been visited, returns the action to navigate to it.
|
static IAction |
visitLevel(IGame game,
Branch branch,
String dlvl)
If the specified level has never been visited, returns the action to navigate to it.
|
public static Navigation.IPath navigate(IGame game, IPosition target, NavOption... opts)
opts
- Additional modifierspublic static Navigation.IPath navigate(IGame game, IPosition target, long maxSteps, NavOption... opts)
maxSteps
- Maximum number of stepsopts
- Additional modifierspublic static Navigation.IPath navigate(IGame game, IPredicate<ITile> target, NavOption... opts)
opts
- Additional modifierspublic static Navigation.IPath navigate(IGame game, IPredicate<ITile> target, long maxSteps, NavOption... opts)
maxSteps
- Maximum number of stepsopts
- Additional modifierspublic static IAction seek(IGame game, IPosition target)
public static IAction seek(IGame game, IPredicate<ITile> target)
public static IAction seekBranch(IGame game, Branch branch)
public static IAction seekLevel(IGame game, Branch branch, String dlvl)
public static IAction seekLevel(IGame game, Branch branch, LevelTag tag)
public static IAction exploreLevel(IGame game, Branch branch, String dlvl)
public static IAction exploreLevel(IGame game, Branch branch, LevelTag tag)
public static IAction exploreCurrentLevel(IGame game)
searchCurrentLevel(IGame)
public static IAction explore(IGame game, Branch branch, LevelTag tag)
public static IAction explore(IGame game, Branch branch)
public static IAction searchCurrentLevelRepeatedly(IGame game)
public static IAction searchCurrentLevel(IGame game)
searchCurrentLevelRepeatedly(IGame)
public static IAction visitBranch(IGame game, Branch branch)
public static IAction visitLevel(IGame game, Branch branch, String dlvl)
public static IAction visitLevel(IGame game, Branch branch, LevelTag tag)
public static IAction branchEntrance(IGame game, Branch branch)
Branch.MAIN
containing the entrance to branch, if static or already visitedpublic static IAction seekInterlevel(IGame game, IPredicate<ITile> target, long maxDelta)
maxDelta
- limits the number of traversed levelspublic static IAction seekInterlevel(IGame game, IPredicate<ITile> target)
public static IAction seekInterlevelUpwards(IGame game, IPredicate<ITile> target)
seekInterlevel(IGame, IPredicate)
but will only change levels
upwards and avoid subbranches.public static IAction seekInterlevelUpwards(IGame game, IPredicate<ITile> target, long maxDelta)
seekInterlevel(IGame, IPredicate)
but will only change levels
upwards and avoid subbranches.maxDelta
- limits the number of traversed levelspublic static List<IPosition> lastPath(IGame game)
public static Boolean isEnteringShop(IGame game)