Now, for this game I will be making a landscape which consists of numbers. When the train is on the tile, it will follow an instruction based on the tile number. For this I'm using symbols instead of letters.
For this example only:
- = Straight Track
\/ = Curve
X = Junction
S = Station
/-------------------------------------\
S-------------------/ \------------------------S
Basically, each tile (when the train is touching it) will have instructions, so at - it moves forwards, at / it turns and at S it stops, loads and turns around.
However, let's say I had something like this:
/-------------------------------------\
S-------------------X X------------------------S
\ /
\ /
\--------------------------------/
The original path is shorter than the new path, but I need a way for the trains to know that. How are pathfinders created?
One idea was that all of the possible tracks would be stored into a list, hence the one with the shortest list would be used. However, not only would I need a pathfinder for the train, but I'd need a pathfinder for the pathfinder. There would have to be a way for it to guess what track to pick, so that it can add them tracks to the list. So, how could it find the other station?
Last edited by Borrego6165 (2012-09-07 13:22:17)
Offline
Borrego6165 wrote:
Now, for this game I will be making a landscape which consists of numbers. When the train is on the tile, it will follow an instruction based on the tile number. For this I'm using symbols instead of letters.
For this example only:
- = Straight Track
\/ = Curve
X = Junction
S = Station
/-------------------------------------\
S-------------------/ \------------------------S
Basically, each tile (when the train is touching it) will have instructions, so at - it moves forwards, at / it turns and at S it stops, loads and turns around.
However, let's say I had something like this:
/-------------------------------------\
S-------------------X X------------------------S
\ /
\ /
\--------------------------------/
The original path is shorter than the new path, but I need a way for the trains to know that. How are pathfinders created?
One idea was that all of the possible tracks would be stored into a list, hence the one with the shortest list would be used. However, not only would I need a pathfinder for the train, but I'd need a pathfinder for the pathfinder. There would have to be a way for it to guess what track to pick, so that it can add them tracks to the list. So, how could it find the other station?
Here's my pathfinder, but in your case it would need to recalculate every time the user adds a block, making it slow. And in my game PPTracks, I just let the user decide how cars move.
Last edited by Molybdenum (2012-09-07 16:25:01)
Offline
Molybdenum wrote:
Borrego6165 wrote:
Stuff...
One idea was that all of the possible tracks would be stored into a list, hence the one with the shortest list would be used. However, not only would I need a pathfinder for the train, but I'd need a pathfinder for the pathfinder. There would have to be a way for it to guess what track to pick, so that it can add them tracks to the list. So, how could it find the other station?Here's my pathfinder, but in your case it would need to recalculate every time the user adds a block, making it slow.
You could make it so that the AI only recalculates every time that a station is put down, or when a track makes more than one connection when placed. This would greatly speed up the AI.
Last edited by ErnieParke (2012-09-07 16:37:02)
Offline
thanks you two! I'll think some things over
Offline