AI Pathfinding: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Warn readers that the latest release has new, undocumented features. Will come back to this for a fuller update soon.)
mNo edit summary
Line 1: Line 1:
[[Category:Feature Guide]]
[[Category:Feature Guide]]
{{note|AI has been recently updated and this article is a release behind. Notably, AI now is controlled by the GMs only in a hosted game, and there is now a Movement Blocking Layer which doesn't block vision. The toolbar now has an additional toggle to tell MapTool whether to consider VBL when pathfinding.
{{note|AI has been recently updated and this article is a release behind. Notably, AI now is controlled by the GMs only in a hosted game, and there is now a Movement Blocking Layer which doesn't block vision. The toolbar now has an additional toggle to tell MapTool whether to consider VBL when pathfinding.
<br><br>
 
Read on with these improvements in mind, and lookout for an updated version of this article!}}
Read on with these improvements in mind, and lookout for an updated version of this article!}}



Revision as of 04:50, 14 April 2020


AI has been recently updated and this article is a release behind. Notably, AI now is controlled by the GMs only in a hosted game, and there is now a Movement Blocking Layer which doesn't block vision. The toolbar now has an additional toggle to tell MapTool whether to consider VBL when pathfinding. Read on with these improvements in mind, and lookout for an updated version of this article!


MapTool has a built in AI pathfinding feature. When activated via the ‘AI’ toggle button on the toolbar, tokens will find the shortest path to its destination as you drag them on the token or hidden layers. The movement takes into account VBL and terrain modifiers configured on intervening tokens. This means your tokens will not move through walls, and will find an efficient path past obstacles and around or through difficult terrain. AI Pathfinding correctly accounts for a game's diagonal movement settings as well.

The AI setting can be toggled by clicking the 'AI' button on the toolbar so that it shows green text. When the text is gray, AI is disabled. This setting is per client only, and cannot be enforced by a game host.

Using Terrain Modifiers

Editing a stamp's terrain modifier

A stamp or token may have a Terrain Modifier assigned to it that impacts the movement of tokens that move across it. There are four types of Terrain Modifiers:

  • NONE - No change to movement cost.
  • ADD - Adds the amount to the cost to move into the cell. If the Units per Cell are set to 5 (for 5' per grid) and a stamp has ADD 3 Terrain Modifier then movement onto that stamp will cost either 8 or 10 depending on the AI Cell Rounding setting in Map Properties.
  • MULTIPLY - Multiplies the movement cost by the Terrain Modifier amount. If it would normally cost 5 to move into a cell and the Terrain Modifier is MULTIPLY 2 then the cost will be 10. Fractional modifiers are allowed and will decrease the movement cost for values less than 1.0 and increase the cost for values greater than 1.0. Costs are modified depending on the setting of the AI Cell Rounding setting for the map.
  • BLOCK - Blocks movement entirely.
  • FREE - Sets the movement cost for the cell to zero(0.0).

Using the BLOCK Terrain Modifier Type, or setting Token Modifier value for the ADD and MULTIPLY types to a sufficiently high number, will effectively block movement and make tokens go around the obstacle. This is useful for things like an arrow slit, window, lava, etc. Any token can have this modifier which means you can set NPC tokens so PCs must go around them or stamp tokens on the object layer like oil or water. You can also place tokens on the hidden layer to denote difficult terrain.

To set the terrain modifier of a token, open the Token Editor by double clicking the token or accessing it via the right-click menu. Navigate to the Config tab and set the Terrain Modifier value and type. You can also set the token opacity from here, which may be useful for creating translucent terrain markers.

Once created, tokens with Terrain Modifiers can be placed on any layer (including the hidden layer) and still affect other tokens' movement.

Ignoring Terrain Modifiers

Tokens representing characters or other things that move can also be set to ignore one or more Terrain Modifier Types. On the same Config tab, is a list of the Terrain Modifier Types that can be selected which will be ignored by that token. Hold down the Ctrl key while clicking to select more than one type to ignore.

Example map using AI

Left: Setting up a map with vision blocking and terrain modifiers for use with AI pathfinding. Right: A token being moved across the sample map with AI enabled.

The sample map pictured was created by creating a large block of VBL (the blue area) and removing squares of it by holding down the shift key while placing rectangles of VBL. There is also VBL on the stamped steps as well to make the PCs navigate them as they should.

The Map Units are set to '1' on this map to make it easy to see the multiplier at work. The staircase stamp has a terrain value of 2 as do the other steps in the horizontal corridor (note the image under 'Using Terrain Modifiers'). If the map units were set to '5', a terrain modifier of 2 would make the steps cost 10 units to enter.

With the movement AI enabled, the PC can be dragged anywhere but should go around VBL and suffer appropriate movement penalties when passing over tokens with a Movement Modifier.

Overriding AI

But I want to jump in the lava pit!

If you absolutely, positively, despite all warnings to the contrary want to enter difficult terrain, you can use the spacebar to set a waypoint to force the path. You can also use this to get into a more advantageous attack position even over difficult terrain.

Limitations

There are a few limitations to the movement AI:

  • Pathfinding only works on maps with a grid type set.
  • The token being moved cannot be free-size and must be snap to grid.
  • Tokens with Terrain Modifiers must be set to a named size (e.g. Medium or Large) and cannot be set to Free Size or they will not work.
  • No macros exist to access AI features, nor server options to force players to use this mode of moving tokens.
  • There are no fractional (e.g. 2.5x) or arbitrary (e.g. +5 units) terrain modifiers at this time, only an integer multiplier. As of 1.5.11, fractional modifiers can be used for both Multiply and Add types.
  • If your rule system states that the square on either side must be open in order to move diagonally then you will need to use the spacebar to set a waypoint to navigate corners.
  • If a token is dragged to an area to which no path can be found then no path at all will be shown. You can still move your token to the new location, but if the token is dropped by a player into such a square it might become invisible to them.
  • With MapTool allowing unbounded/nearly infinite map space, we had to include a timeout to prevent an infinite search. When moving a token on a very complex path or where no path is available, MapTool may seemingly hang several seconds as it searches for a path before placing a token.