Question about the penalty with tags

There are two places to set the penalty: one is in the graph’s gridNode and the other is in the seeker.
for example:

  1. the penalty of gridNode is 100.
  2. the tag of the gridNode is (1<<0) + (1<<1) + (1<<2)
  3. the tagPenalties in seeker is [100, 200, 2000, …]
  4. the seeker’s tag is (1<<1) + (1<<2 ) which represents the value of the 200 and 2000 in the tagPenalties.

i’ve not started using the tag for now, but by reading the doc.

  1. I guess whether a seeker can pass a gridNode only when the (tag of the seeker) & (tag of the gridNode) != 0
  2. because ((1<<1) + (1<<2)) & ((1<<0) + (1<<1) + (1<<2)) = ((1<<1) + (1<<2)), so there are two penalties are available for the seeker, then I guess the seeker will choose the minimal penalty which should be 200
  3. If both of the two guesses above are correct. then the question is will the penalty of gridNode which is 100 be totally ignored or when will it be used with tags?

Want to know more about the penalty with the tag, Where can I find this information.
there are different terrains in my game, such as plains, water, trees, and snow, What penalty should I use for them?
I found some threads several years ago which says “A penalty of 10000 roughly corresponds to moving 10 world units”, which are not contained in the doc, I guess the value I set for my terrains should be related to the 10000?


A grid node only has a single tag. If you apply (1<<0) + (1<<1) + (1<<2) that means it has tag 6, and it will use the corresponding entry in the seeker component.
You can emulate the result of treating different bits separately by filling in the penalties array accordingly, but keep in mind that you only have 5 bits to work with (there’s a maximum of 32 tags in total).

Is it possible to expand max count of tags to 64 or 128? 32 tags is not enough to me.
In my game a tile controlled by a player will be marked a tag calculated by (player number, tile type). which would give more penalty to other players who enter the tile in seeker’s tagPenalties. so assuming there are total 8 players in my game then the max tile type is 32 / 8 = 4, which is not enough.


If you want more dynamic tags, I would recommend that you use an ITraversalProvider. See the bottom of this page: Utilities for turn-based games - A* Pathfinding Project

Cool, but I’ve not manually created Path yet since my movement script just extends the AIPath which created the Path internally. so how can I assign the MyCustomTraversalProvider to the inner Path created by AIPath script?
by reading the Seeker.cs I’ve found this: public OnPathDelegate preProcessPath, I guess I can register the MyCustomTraversalProvider by this delegate?

That should work just fine :slight_smile: