Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request/WIP: Rail Planner track builder #7607

Draft
wants to merge 2 commits into
base: master
from

Conversation

@Hexus-One
Copy link
Contributor

Hexus-One commented May 25, 2019

Hello!

I am working on this Rail Planner tool, a rail building tool which lets you designate a start point and a goal point. It is based on the Factorio Rail Planner, and it uses A* path search algorithm to find the shortest route from the start to the goal. It previews the track . This saves a lot of effort in "planning" your route between two points, and I think it will make it easier for mobile/console/laptop players to play the game.

Here's a demo video if it in action

There's still some work to do, though:

  • Implement a proper DoCommand protocol for this tool - currently it just chains together BuildRail commands which is compatible with 1.9.1 servers but is otherwise undesirable given the network load it causes.
  • Currently the algorithm uses a LOT of memory (up to 4GiB for 1024x2048, corner to corner) so I'm trying to find less memory-intensive algorithms (IDA*, SMA* are candidates)
  • The algorithm doesn't account for dynamic environment (i.e. the environment changing, such as town growth, other players building, water spread etc.), D* lite could be a solution to this
  • The algorithm doesn't account for curve size limitations - eg. minimum curve length for a route. Ideally the player would be able to give a train length and the rail planner will find a path that has no slowdowns
  • Similarly, accounting for slopes
  • Bridge and tunnel building would be nice but can be potentially complicated
  • An option for the rail planner to make use of existing track or to treat them as obstructions - there are lots of ways to do this (eg. should it take one-way signal into account?) so this will probably be left to later

For now I am going to implement this for 1. ship canals and then 2. roads as they have simpler mechanics compared to rails.

For now, you can view and compile the source here. So far, I've developed this against the CityMania client codebase, but the rest of my progress will be made using the OpenTTD/OpenTTD GitHub codebase.

As far as I know, there are no search algorithms which are memory-bound and can work in a dynamic environment. If you know of any, please let me know!

I look forward to your feedback/suggestions :)

@kiwitreekor
Copy link
Contributor

kiwitreekor commented May 26, 2019

The demo video page says Access denied... :(

@Hexus-One
Copy link
Contributor Author

Hexus-One commented May 26, 2019

Thanks, fixed!

@andythenorth
Copy link
Contributor

andythenorth commented Oct 22, 2019

Thanks for this. The video is pretty neat, but I don't know if this is something that would be accepted for vanilla OpenTTD.

As there has been no activity on this PR for some, I'm proposing closing it in a few weeks if nothing more has changed, as we try to keep the PR count low. Thanks for contributing!

@andythenorth andythenorth added the stale label Nov 2, 2019
@Hexus-One
Copy link
Contributor Author

Hexus-One commented Nov 15, 2019

Hi sorry for the hiatus - I've been very busy with school.

I'm going to work on this in January, if not earlier :)

@Hexus-One
Copy link
Contributor Author

Hexus-One commented Jul 3, 2020

Hello
I've implemented the build planner for canals and locks, using BFS/Dijkstra path search.
Github branch is here, I'm unsure how to handle it being a different branch name to this one.
See a gif of it in action here
It's just in a basic stage right now - please provide feedback, suggestions and bug reports :D

…working (or compilable) at the moment.
@Hexus-One Hexus-One force-pushed the Hexus-One:railplanner branch from 4ee0955 to 02fb3b9 Jul 5, 2020
@Hexus-One
Copy link
Contributor Author

Hexus-One commented Jul 5, 2020

I had an existing implementation last year (on CMClient repo fork), ported to this repo just now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.