Problem
I want ot write a simple 1D RTS game and have the following path finding problem: There are many one-dimensional lines and everywhere are teleporters which can be used to travel between the lines but also to travel inside the current line. The teleporters are the only way to travle between lines. What algorithm or pseudo code can used to determine the shortest path between position po1 on line li1 to po2 on li2? We have a set of teleporters T (each has a po and li) which are connected with each other with a cost of zero.
Why not A* or Dijkstra-algorithm
It's because I think these would be an overkill in 1D.
Clarification
- It's maybe sounds a bit two dimensional but it isn't because you can only travel left or right on one line.
- There are costs to travel to a teleporter but teleporting from one to another has no cost. See this ascii art:
...0....s..0 ......0.x...
Here, the shortest is way from start s to target x is
- to go to the right teleporter
- teleport one line down (only in this graphic; really planes are unordered)
- and go right to the target (final cost = 5)