VEX pathfinding problem

   894   6   1
User Avatar
Member
385 posts
Joined: July 2018
Offline
i have an image on a grid. part of the grid gets colored and the rest stays black.

i shuffle the colored points position and then try to make them find their target position eventually forming the original image again.

Everything happens on the same grid by transferring the Cd and id attributes to the next chosen point based on a simple pathfinding algorithm.

The problem is they keep overriding each other and in the end not all points make it to the end.

cant really find the problem in the code, or in the method.

Any ideas or tips?

Attachments:
pathfinding.hiplc (202.7 KB)

User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
Didn't look too closely at your hip, but it looks like your issue is because you are running over points in a wrangle, setting values.
When you run over points/primitives/vertexes and are setting values at the same time referring to those values; Because the wrangle parallel processes your data won't come out as expected.
You could try running your code while in detail mode - holding values with local variables until after all target data has been processed and only then run code to set values.

Also could be how you are incorporating your for each nodes.
You may also want to look at using a solver.
Edited by BabaJ - Nov. 28, 2023 09:03:12
User Avatar
Member
385 posts
Joined: July 2018
Offline
BabaJ
Didn't look too closely at your hip, but it looks like your issue is because you are running over points in a wrangle, setting values.
When you run over points/primitives/vertexes and are setting values at the same time referring to those values; Because the wrangle parallel processes your data won't come out as expected.
You could try running your code while in detail mode - holding values with local variables until after all target data has been processed and only then run code to set values.

Also could be how you are incorporating your for each nodes.
You may also want to look at using a solver.


yeah thought about values overriding each other because of parallel process, but I get the same result in a detail wrangle though. i also have a locking mechanism so that when one point selects the next point it locks it so that others wont be able to select it.
i've been searching for the bug for some time now and its hard to spot something out of place.
there is probably something very obvious that i can't see

Attachments:
pathfinding_detail.hiplc (223.6 KB)

User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
papsphilip
but I get the same result in a detail wrangle though

Are you sure?
Even in detail mode and if you use attributes, you can still trip yourself up; that's why I suggest you hold values to local defined variables, and do all the work on them first before setting the final attribute settings that should be separate(generally)and at the end of your code window in detail mode.

Otherwise, yes there may just be something amiss in the logic.
Again I haven't taken the time to look more closely on what you are doing but it does seem your code may just be a bit overly complicated.(no criticsim intended).

Perhaps if you attempt to redo your process in a more simplified way and post that - you might get better feedback.
You also might come up with something yourself that works better, or find your 'error', if that's the case.
User Avatar
Member
385 posts
Joined: July 2018
Offline
fixed it! The code is actually very simple if you take a look.
Nothing fancy, logic is simple, just finding my neighbors, picking the one that gets me closer to my end target and then setting some attributes.
i had to store my next points in a detail array and set the attributes in an entirely different detail wrangle for this to work.
i don't know why, but setting the attributes at the end of the same detail wrangle i am doing the calculations on didn't work.
thank you for your help!i will post the final thing when i finish it
User Avatar
Member
4516 posts
Joined: Feb. 2012
Offline
I think it's because the result of your locking mechanism won't be available to other points in the same for loop network iteration.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
385 posts
Joined: July 2018
Offline
animatrix_
I think it's because the result of your locking mechanism won't be available to other points in the same for loop network iteration.

yeah i figured that must be the problem, so instead of the locking mechanism i just append each point in an array and access it after everything has been calculated and then set the correct attributes
  • Quick Links