I’m currently trying to implement a simple path finding script which will just follow different roads on a 2d tile grid.
It might not even fall into the category of path finding since there are no obstacles - only different pieces of road which should be followed.
I would like to then be able to return the path which will bring you the closest to the target tile in as little moves as possible.
So here is my grid:
[26111-screen+shot+2014-05-04+at+12.21.01.png|26111]
I started by creating a new class for each tile and named it the Tile class - this class just holds information on each tiles rotation, position in the grid and type of tile.
I also created a new class called QuadInt which will just hold 4 integers. I use this class to store which directions of a tile have road on them. For example:
Tile newTile = new Tile();
newTile.type = 1;
newTile.directions = new QuadInt(1, 1, 0, 0);
This would look like this for a tile:
So QuadInt(1, 1, 0, 0) describes if the top, right, bottom and left part of a tile have road on them.
Now I can know the road directions of each tile and compare them to find a continuous path.
This is where I am getting stuck unfortunately.
The main problem is that the roads have multiple conjunctions at which the path can take two or more different turns - I would have to follow one path and then go back to the first conjunction and follow the second route and do the same for any other crossroads along the way.
I would like to find my own solution if possible since I would like to learn how this kinda thing works… I’m not sure if A* could be used in this scenario?
Are there any flaws in my approach and any ideas on how to deal with this issue?
Thanks for the help!