Jump to content

Harvester AI Pathfinding - Advanced detail on innate pathfinding logic


Veyrdite

Recommended Posts

Prerequisites

First read and follow Laubi's original tutorial on "Harvester AI Pathfinding" (W3Dhub link).  This tutorial has been around for a very long time.

The attached "harvtest_paths.zip" file contains three example .mix maps for you to try out, each one is mentioned in the appropriate sections below.  To play these you need to:

  1. Extract the .mix files to your Renegade/Data/ folder (typically C:\Westwood\Renegade\Data\)
  2. Start Renegade
  3. Choose "Host a LAN game"
  4. Change the settings to be:
    1. Max players = 1
    2. Dedicated = no
    3. Map rotation = any one of these three maps

Between the buildings on the map is a flying harvester that you can enter.  Flying above the map makes it easier to see what is going on.

You should be running an up-to-date copy of TT/scripts and the latest version of Leveledit (not the version shipped by Westwood, see the TiberianTechnologies website).  It contains several fixes that may affect how well you can follow the techniques in this tutorial.

Introduction

We're on an island floating far above a lava ocean.  On one side of the island are the Nod & GDI bases, on the other far end is the tiberium field:

map00_marked.thumb.jpeg.d1a800dfb9bd7fdb97c7f071a1fbd01b.jpeg

In between the two bases is a maze with many possible routes for the harvesters to take

First: setup your map as normal (and as per Laubi's tutorial), but don't create any waypaths for the harvesters just yet.  Make sure to place the "Human" pathfind generator and generate pathfinding sectors for your map.

In LevelEdit you can show the generated sectors using the menu item Pathfinding->Display Sectors:

map02.thumb.jpeg.db7fefa007dafd870350e9b3d4794d37.jpeg

Note the greeny-blue boxes that appear.  Each one is a 'zone' that objects can travel within, and each connects to the sectors that touch it.  Objects in the game work out how to get from point A to point B by following a chain of these sectors.

You do not actually need to create waypaths for your harvesters

Despite all of the traditional advice: harvesters do NOT need waypaths.  They can find their way to the fields and back all on their own using the pathfinding sectors.  The only waypaths you need on your whole map are the short ones exiting your Weapons Factory and Airstrip, so that vehicles drive out a little after being created.

By default harvesters always start in this 'self-navigating' mode once they leave the WF/Air.  They only start using waypaths when they "accidentally" encounter one whilst driving (and several other conditions are met, described later in this tut).

If you don't believe me: try it.  According to JonWil there is no special code (in Vanilla Renegade harvesters) for handling waypaths. My understanding is that they incidentally can use waypaths because the W3D engine's normal innate pathfinding code (used by all AI) handles using waypaths.

On the example map for this tutorial: harvesters are picking a non-optimal route when left to work things out on their own:
map03.thumb.jpeg.6047edea0d64de4b496784086d299bee.jpeg
Try the map C&C_Harvpath_nopaths.mix to see this yourself.

How do harvesters "enter" a waypath?

(1) When a harvester is created: it uses the pathfinding sectors to find its own route to the tiberium field (or other destination) and starts on this route.

(2) Every time the harvester enters a new sector it checks to see if there are any waypaths that start in this sector.

A harvester will only follow one of these detected waypaths if multiples conditions are met:

  1. The path is of type 'innate'
  2. The end of the path is closer to the harvester's target than where the harvester currently is.
  3. (Possibly some distance or number-of sector metrics, unknown)

Once the harv starts following a waypath it will not leave it until the path ends.

How do I design my waypaths?

First find the path your harvesters take on their own.  Play your map in-game to find out.

Next create a path that starts from one of the sectors your harvester crosses.  End this path near (or closer to) the tib field:

map04.thumb.jpeg.718022aad6770fe61e635d63f51ed9c6.jpeg

Try the map C&C_Harvpath_Pathed.mix to see this working.  Both harvs end up getting caught by the one path in this example (but you generally want to add separate paths for each), and the path is not perfect so they start grinding against the walls.

You can use any type of waypath provided in LE, they're all the same:

pathtypes.png.c8afbb94ed5fd8873b790b4f68b5c86a.png

I actually use the 'flying vehicle only waypath' just to make people feel unsettled.

The only requirements are that you change the waypath settings to enable 'Innate Pathfind' after you create it.  You get to this dialog by double-clicking a node on the waypath (not the line part of the path):

pathsettings.thumb.png.aa1c1d588336f80f35f509f2c415bc2b.png

Two-way is an option that is legitimately accepted by the game and useful to consider.  The Human/Ground/Air fields appear to do nothing at all, you can even un-tick them and your harv will still follow the path.

You do NOT need to re-calculate pathfinding after making or changing any waypoints.  Waypoints are a separate part of the system that are handled during map export (to .MIX).  This feature may be buggy in older versions of LevelEdit.

 

Here's an example of a waypath that will NOT work.  Note that the path now starts in the doorway of the maze, rather than in the sector outside of it.  The harvesters never cross the pathfinding sectors in this doorway, so they never 'see' the path:

map05.thumb.jpeg.c5a6c48355e0a6045cddbf6a34a633fe.jpeg

They may however 'see' this path on the way back from the tiberium field, assuming the path has been marked as Two Way.


Harvesters will use your path as long as (1) you start the path in a sector the harvesters already drive over, and (2) end the path closer to the goal than it starts.  This means that you can give them really stupid long routes and they will still follow them, such as this:

map06.thumb.jpeg.b83df646ce2a02eb6dda5fe623f7b132.jpeg

Try the map C&C_Harvpath_Stupid.mix to see this yourself.  Note that one of the harvesters takes a 'shortcut', I am uncertain of the exact logic behind this, but I believe it notices the nearby waypath nodes when it crosses sectors whilst leaving the Weapons Factory.

If we were to end the path at a position further from the tib field than where we started then the path will NOT be accepted/chosen by the harvesters:

map07.thumb.jpeg.2afe566a37018042ecea06181cd39145.jpeg

(They could potentially choose this path on their way back, however, as its end may be nearer their "goal" (eg the GDI refinery) than their current position).

Conclusions

Confusions, comments or problems?  Ask below or on the main W3Dhub forums.

Areas that are still not understood:

  • Whether or not this 'innate pathfinding' is exactly the same for all AI in the game, or slightly different for harvesters.
  • What metric is used to make choices on route.  Eg minimising distance travelled OR number of sectors travelled through?
  • How harvesters start waypaths at points other than their ends (ie take shortcuts)

harvpath_tests.zip

Edited by Veyrdite
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...