Multiple grid graphs, masks and penalties

multiple gridgraphs, aiLerp:

I need different “nations” on my map to have different “territories” restricted to travel/traversal if “borders” are closed.

I thought I would use tags for this, thinking tags were flags. So I find out they aren’t. No biggy. (I found out they are actually four flags, 19 - 23, in a node’s flags, but you know what I mean, I think). A tag system would not work for this.

Plan B: multiple graphs for different nations with different political rules as to where their units can travel. I am trying to create a Civilization like map, where some area are walkable to some nations, some not, with up to 16 “nations” at once, but, not turn based.

Do the NNConstraint masks just determine what is and what is not walkable?

Do they combine gridNodeBase penalties and tags if nodes from both graphs are walkable? (just add penalties and tag penalties together?)

…I feel like I cant get my question clear…
Try this: How do penalties/tags get applied/analyzed when a seeker is scanning multiple graphs at once using a mask?

Should I have a base terrain penalty gridgraph, and just layer on top of that a gridgraph with no tags or penalties just walkable/uwalkable to get the political restrictions? (ie cant walk through territories without open borders treaties) .

…or would I be better off with each nation getting its own “personal” graph, with identical terrain penalties to all the other graphs, just different areas turned on/off as walkable as necessary.

As far as I understand it, a political gridgraph mask on top of base terrain graph may be simpler.

Performance cost, (compared to a single/“personal” graph) not really noticeable, due to the “area” components thing, (very impressive, BTW, much wikipedia read on the topics now, little understanding, but I am impressed with this package yet again).

If there is noticeable performance costs, I prefer performance over simplicity/manageability. Graphs are 256 x 256 to 1024 x 1024, with at most 1 other graph layer, and seeker using tags.

Also, I am struggling to make copies of graphs via code. I am trying to make an instance of the original (terrain) graph, and then copy it to, but I cant really find a constructor/method that takes a graph and makes a new copy of it. So would it be simpler to rescan, retag, and reapply penalties to the nations “personal” graphs?


You may be interested in the ITraversalProvider. See the bottom of this page: Utilities for turn-based games - A* Pathfinding Project
That allows you to implement completely custom traversal rules for your graph.

ItTraversalProvider has a mutithread / threadsafe warning.

If done correctly, would it be more performant than each nation just getting its own Grid graph? (Using AILerp)

I am not worried about generation time of up to 16 gridgraphs.

I dont really understand multithreading / threadsafe. Not asking for a lesson, i understand some theory of it, at least JOBS which I think is similar.

Bit I am wondering if it could seriously hamper performance if not thread safe / multithreaded, with hundreds of simultaneous agents on a 512 x 512 gg with AILerp.

The warning just means that your code that you include in the ITraversalProvider has to be thread safe, as it may be called from multiple threads simultaneously. It will not disable multithreading or anything like that.