Road Pathfinder
Moderator: OpenTTD Developers
-
- Transport Coordinator
- Posts: 294
- Joined: 23 Jul 2007 15:13
- Location: Somewhere in this page
Road Pathfinder
Could someone tell me how the Road Pathfinder works - as I'm attempting to make my own....
Thank you!
Matthew:out
Thank you!
Matthew:out
Yay! I'm back! Did you miss me?
...
I thought not.
...
I thought not.
Re: Road Pathfinder
Search for "games path finding" at the Internet.
A common algorithm is A* (pronounced A-star).
A common algorithm is A* (pronounced A-star).
-
- Transport Coordinator
- Posts: 294
- Joined: 23 Jul 2007 15:13
- Location: Somewhere in this page
Re: Road Pathfinder
I know how the A* graph works, (compare cost of two lines, choose the one with least cost, is the jist of it) but I want to know about the commands used for placing a node, getting that node, sectioning the route and building the road from that. Some sort of tutorial would be nice.
Matthew:out
Matthew:out
Yay! I'm back! Did you miss me?
...
I thought not.
...
I thought not.
Re: Road Pathfinder
A read of the code would surely give you the best idea of what's going on 'inside' the pathfinder...
Then ask if you don't get it entirely
(I don't get it entirely myself to be honest
)
Then ask if you don't get it entirely

(I don't get it entirely myself to be honest

AroAI - A really feeble attempt at an AI
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
-
- Transport Coordinator
- Posts: 294
- Joined: 23 Jul 2007 15:13
- Location: Somewhere in this page
Re: Road Pathfinder
*cough* *cough* Already have, twice... I still see text - it's not my fault I'm rubbish at anything to do with code...
Matthew:out
EDIT: And I barely understand the Doxygen documents, so no use there.
Matthew:out
EDIT: And I barely understand the Doxygen documents, so no use there.
Yay! I'm back! Did you miss me?
...
I thought not.
...
I thought not.
Re: Road Pathfinder
The AI main page at the wiki has a link to documentation, which should have a link to road-related functions.
Those are your primtive operations in which you have to express road building.
Those are your primtive operations in which you have to express road building.
-
- Transport Coordinator
- Posts: 294
- Joined: 23 Jul 2007 15:13
- Location: Somewhere in this page
Re: Road Pathfinder
Evidently I am being misunderstood...
AroAI already has a route builder, I need to know how to get the result from the AyStar into a route usable by the bus route builder. Which is what the Road Pathfinder does.
MAtthew:out
AroAI already has a route builder, I need to know how to get the result from the AyStar into a route usable by the bus route builder. Which is what the Road Pathfinder does.
MAtthew:out
Yay! I'm back! Did you miss me?
...
I thought not.
...
I thought not.
Re: Road Pathfinder
I think you are misunderstanding as well, most of the AI's available, code examples on the wiki and the doxygen comments should help you a lot. If that is not enough, several questions which you preferably answer all as clearly as possibly:
- what is the problem?
- what solutions to your problem did you find and how did you find them?
- what parts of your solutions didn't work?
- what errors did those parts generate?
Reading the code of available AI's should help you a lot, they al already tackled your problem!
- what is the problem?
- what solutions to your problem did you find and how did you find them?
- what parts of your solutions didn't work?
- what errors did those parts generate?
Reading the code of available AI's should help you a lot, they al already tackled your problem!
-
- Transport Coordinator
- Posts: 294
- Joined: 23 Jul 2007 15:13
- Location: Somewhere in this page
Re: Road Pathfinder
The problem: I want to make a Road Pathfinder Library. The wiki says how to use the existing one, but not how to make one.
The solution: Ask the people who made it how it works, and copy the existing RPF.
How I got there: PM'd TrueBrain.
Problems encountered: The people haven't answered, and I have no idea how the existing Road PF works, plus the AI (AroAI)/ AI Debug isn't recognising the library I've made from the solution.
Error's generated: As above (Couldn't find library 'superpf')
The library.nut, and main.nut are attached.
Matthew:out
The solution: Ask the people who made it how it works, and copy the existing RPF.
How I got there: PM'd TrueBrain.
Problems encountered: The people haven't answered, and I have no idea how the existing Road PF works, plus the AI (AroAI)/ AI Debug isn't recognising the library I've made from the solution.
Error's generated: As above (Couldn't find library 'superpf')
The library.nut, and main.nut are attached.
Matthew:out
- Attachments
-
- library.nut
- library.nut
- (591 Bytes) Downloaded 46 times
-
- main.nut
- main.nut
- (15.22 KiB) Downloaded 49 times
Yay! I'm back! Did you miss me?
...
I thought not.
...
I thought not.
Re: Road Pathfinder
Getting a "library not found" error message usually indicates an error in your library.nut. In this case:
GetVersion should return an integer, so that line of code should read:
Also, while TrueBrain has helped a lot with the A* library and the road pathfinder, I wrote them originally.
Code: Select all
function GetVersion() { return "1"; }
Code: Select all
function GetVersion() { return 1; }
Re: Road Pathfinder
I still don't understand what your problem is (besides the thing yexo pointed out).
Perhaps you should simplify the problem, and learn to crawl before trying to walk.
I suggest you create a flat landscape of 64x64 tiles with a single town somewhere in the corner where it does not bother you.
Then make an AI for that scenario that builds a road from tile (10, 15) to (30, 15) or some other straight line.
(Yes, you can build stuff in the middle of nowhere, not useful in real games, but as a first step it may be useful.)
If that works, try making a road with a corner in it.
Perhaps you should simplify the problem, and learn to crawl before trying to walk.
I suggest you create a flat landscape of 64x64 tiles with a single town somewhere in the corner where it does not bother you.
Then make an AI for that scenario that builds a road from tile (10, 15) to (30, 15) or some other straight line.
(Yes, you can build stuff in the middle of nowhere, not useful in real games, but as a first step it may be useful.)
If that works, try making a road with a corner in it.
-
- Transport Coordinator
- Posts: 294
- Joined: 23 Jul 2007 15:13
- Location: Somewhere in this page
Re: Road Pathfinder
@Yexo Ah, it was the fact it said:
Thank you, for getting it detected, even if I still don't understand how to call nodes (I am simplifying it, to make it faster, that is assuming that each tile is a node.), or how to give AroAI a path.
It's better than nothing...
@Alberth I'll try that.
Matthew:out
that threw me...truebrain
Thank you, for getting it detected, even if I still don't understand how to call nodes (I am simplifying it, to make it faster, that is assuming that each tile is a node.), or how to give AroAI a path.
It's better than nothing...
@Alberth I'll try that.
Matthew:out
Yay! I'm back! Did you miss me?
...
I thought not.
...
I thought not.
Re: Road Pathfinder
1. Don't bother about speed until you got it working. Optimizations only get in the way of understanding.OTTDmaster wrote:... how to call nodes (I am simplifying it, to make it faster, that is assuming that each tile is a node.), or how to give AroAI a path.
2. What is a node? OpenTTD has no nodes. If you mean PF algorithm nodes, then quite likely, tile == node.
Re: Road Pathfinder
A node can be everything you want. If I recall correctly in the default road pathfinder library it is indeed true that node==tile. In the rail pathfinder a node is a combination of a tile + a direction, because you cannot go in every direction when 90 degree turns are disabled.
Are you trying to use the A* library or not? If you want to use it, just copy the default road pathfinder and implement your own _Cost function. The return value of FindPath is an instance of AyStar.Path which is a linked list that contains the complete path.
Are you trying to use the A* library or not? If you want to use it, just copy the default road pathfinder and implement your own _Cost function. The return value of FindPath is an instance of AyStar.Path which is a linked list that contains the complete path.
Re: Road Pathfinder
In case anyone is wondering or cares about the excessive use of AroAI, OTTDmaster has become a sort of assistant developer with me
Just thought i'd let you know
Just thought i'd let you know

AroAI - A really feeble attempt at an AI
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Who is online
Users browsing this forum: No registered users and 8 guests