Support Forum

Nodelink Cost for different agents?

Sorry if this has been asked and answered before, but Ive created a road network using a point graph and only custom connections through NodeLinks. Id like to change the connection cost for certain links in the graph depending on the agent type. For example, heavy trucks should find it unfeasible to move through roads that are smaller, so the cost for that type of agent would be much higher than a smaller vehicle agent. Ive seen that multiple graphs should be used for multiple agents, but does this even apply to point graphs? Is there any way to simply modify the NodeLinks on an agent by agent basis?

Many thanks

Bumping this. Any possibility to get something like this working? I am not sure given that these are custom connections.

I’ll do some testing in my free time on this.
penalties are usually based on the node it self, not really the connection.
I’ve looked at the source code for NodeLink2 and see this being a possibility.
I’ll get back to you on this.

Edit:
So the reason it doesn’t work out of the box is cause Connections only carry a cost. Not a tag or any other properties. Adding a tag to the connection would increase the data size for a graph already by a lot.
Though it’s not impossible.

Hey,

It’s 3.30AM, but I was able to get it working!
Here is the system in action:

The most bottom horizontal connection node can not be used by the blue agent, but can be used by the purple agent.

I have written all the code for this but I’ll have to discuss with Aron what the best way would be to share this with you.
It’s not necessarily hard to implement this, it is just a lot of changes that have to be made to the internal system of A* and it also comes at a small cost, in both performance but accuracy. (the cost of a connection got cut from 28 bits to 23 for this)

There is a lot of very small changes to be made to the entire system. I’ll discuss with Aron what the best plan of action would be. Maybe something like a git patch or so could work. Else I’ll try to do a small write up on how this could be done yourself.

Once again sorry for not getting back to your earlier forum posts.

~Wolf - Toasty

1 Like

Cool.

Adding e.g. a byte to the Connection struct for a tag would actually not increase the size of it at all. Currently it has 3 bytes at the end which are just alignment padding. So a byte could be added and then the TriangleMeshNode.Open method needs to be modified so take the cost into account.
Maybe this is what @ToastyStoemp has done?

That’s exactly what I’ve done.

I’ve made space on the connection by reducing the bit count for count, so it indeed does not increase graph size.

I’d still like to improve it a little bit by using one more bit as a ‘hasTagBeenSet’ flag.
Then there would be almost no performance hit, but could where needed.

What I meant above is that you could literally just add a new byte field in the struct without needing to use any bit twiddling at all.

But that was the trickiest part so I felt so satisfied when I finally figured out how to bit-shift correctly again :smiley: