871
DF Suggestions / Re: Easy solution to the main pathing problem.
« on: October 12, 2009, 09:15:58 am »The problem arises when the dwarf walks over or around the work tile because the left side is the first priority tile to work from. It would be far easier simply to have the dwarf start building on the first adjacent tile it encounters, because it's reasonably safe to assume that if the dwarf could reach that tile without first crossing the work tile, then it's probably possible to leave when the work is done - with the exception of whether the dwarf walked over other work tiles to get to this one, but as long as they are always starting with the closest work tiles this problem should be avoided... unless new wall designations are added after the pathfinding.This wont necessarily work if the dwarf approaches diagonally. Rotating around the work tile can still leave him on the wrong side.
To do this, a simple check could be added to see which direction the dwarf needs to approach the tile from (N, E, S, W), and then end the pathing on the square adjacent the work tile that is in the same direction as the approach. There's no need for an additional pathfinding check to see whether the tile it's standing on will still be pathable after construction, because of our assumption above.
The dwarf should find the path directly to the work tile, not beside it. Then, do the following:
-Cut off the very last step so that the dwarf ends its path in any of the eight tiles surrounding the designation.
-If the path ends on one of the adjacents, you're done.
-If the path ends on one of the diagonals, unfortunately you have no choice but to arbitrarily pick a side. Use the following map to point the dwarf to the nearest adjacent tile.Code: [Select]>Nv
WXE
^S<
X: Designated work tile.
N/E/S/W: North/East/South/West-facing tile a dwarf can work from to build the wall.
>/v/</^: Arrows pointing to the tile the dwarf should move to.
The result should look like this:Code: [Select]nnnnnne
wnnnnee
wwnNeee
wwWXEee
wwwSsee
wwsssse
wssssss
X: Designated work tile.
N/E/S/W: North/East/South/West-facing tile a dwarf can work from to build the wall.
n/e/s/w: Example area of where dwarf could be approaching the work tile from.