Page 1 of 3 123 LastLast
Results 1 to 15 of 32

Thread: EDTS: A collection of scripts for route planning and other tools

  1. #1

    EDTS: A collection of scripts for route planning and other tools

    I've made a route planner in Python which uses data from EDDB to produce routes for specified jump ranges.
    It's also able to guess at optimal ways to visit a certain set of stations (a.k.a. the travelling salesman problem), as well as various other sort-of useful scripts. The functionality to create full routes between systems can produce significantly more optimal routes than the in-game route planner, although it often doesn't run quite as quickly.

    I'm not anticipating this being hugely popular - it'll likely see some use within the Buckyball racing community though - I just want it to have a thread for support/help.

    The project page is here; there are currently no formal releases, I'd recommend downloading a ZIP of the master branch (or cloning it if you're familiar with git). The develop branch is often slightly ahead of master, but may be less stable.
    The scripts are written in Python; the only requirements are a Python 2.7+ or Python 3.x interpreter, and about 200MB of RAM to run the scripts.

    The usage for the main script is on the website (and in help flags within the applications), but the basics are as follows:
    On first run, the latest EDDB system and station data must be downloaded, as well as Coriolis data for ship FSD sizes:

    python update.py

    Once this is done, the script can be used:

    python edts.py -j 35.2 --start="Sol/Galileo" --end="Alioth/Golden Gate" "Wolf 359/Powell High" "Agartha/Enoch Port" "Alpha Centauri"

    This example assumes you wish to go from Galileo in Sol, to Golden Gate in Alioth, via Powell High, Enoch Port and Alpha Centauri. All of this will be done in a ship with a 35.2Ly jump range. Note that for the case of Alpha Centauri, we only specify the system name; this is because we definitely do not want to visit any stations in Alpha Centauri. It is a silly place.

    The output might look similar to the following:

    Code:
    Sol, Galileo (505Ls, Ocellus Starport)
        ===   7.78Ly ( 1 jump ) ===> Wolf 359, Powell High (99Ls, Coriolis Starport), SC: ~83s
        ===   8.33Ly ( 1 jump ) ===> Alpha Centauri
        === 145.96Ly ( 5 jumps) ===> Agartha, Enoch Port (878Ls, Coriolis Starport), SC: ~118s
        === 230.65Ly ( 8 jumps) ===> Alioth, Golden Gate (7783Ls, Unknown Starport), SC: ~224s
    
    Total distance: 392.72Ly; total jumps: 15; total SC distance: 8760Ls; ETT: 24:20
    The other scripts are documented on the project wiki and are basically in development; feel free to ask about them or suggest new features.

    Other scripts
    • close_to: find systems close to one or more provided systems (with restrictions, e.g. must have stations of a certain pad size, must be of a certain allegiance)
    • coords: print coordinates of provided systems
    • distance: print the distance between two systems
    • find: find systems and/or stations of a certain name, allowing wildcards
    • fuel_usage: determine the fuel usage required for a set of jumps
    • galmath: calculate "magic numbers" for plotting in the core
    • edi: an interactive interpreter to run all of the above commands whilst keeping the EDDB data persistently loaded for speed


    Other functionality
    • Representations of FSDs and ships, allowing for easy calculation of jump ranges/fuel costs.
    • A module to determine the approximate position of a PG system/sector from its name, and vice versa.


    You might ask: "can't the EDDB website do most of this?" The answer is yes, this is just intended an instantly-available command-line alternative for those who prefer that sort of thing. I'm not imagining that will be a lot of people, but it might be some.

    Contributors
    CMDR furrycat: submitted many patches for these tools, for which I am very grateful
    Onane: helped to investigate a very odd issue related to file size limits
    Bruski: helped in our ongoing fight against ever-increasing EDSM/EDDB data file sizes

  2. #2
    Good idea!

    python installed - check
    EDTS files downloaded - check

    open Python 3.5.0 Shell

    >>> python eddb.py --download
    SyntaxError: invalid syntax
    >>>

    what have i done wrong, or not done

  3. #3
    Originally Posted by superflyguy View Post (Source)
    >>> python eddb.py --download
    SyntaxError: invalid syntax
    >>>
    I'm not sure you've done anything wrong at all!

    This could be your Python version being a lot newer than mine (I tested it on 2.7, not sure what other users have used). I'll download a 3.x version of Python in a little while and sort it out!

  4. #4

  5. #5
    where should the .py files be saved? if that makes a difference

  6. #6
    i get the same 'invalid syntax' in 2.7

  7. #7
    Originally Posted by superflyguy View Post (Source)
    i get the same 'invalid syntax' in 2.7
    What OS/environment are you running on? Very strange that it's giving such a non-specific error...

    Edit: From the "open" I guess OS X... Maybe it's line endings or something like that. Although I have tried it on my work laptop which is OS X... But I did clone the git repository rather than downloading a ZIP, so not really the same I guess.

    Edit 2: I'm an idiot, I just realised what's going on... You're already in a python shell, so running "python" within that won't have the desired effect (since Python's already running).
    Either you can run it from within a normal terminal window, or I can look up how to run a python script from within an already-Python shell. One sec

    Eugh... Looks like there's no nice way of running a file from within an existing Python prompt.
    If possible, I'd suggest you start a normal Terminal prompt, use "cd" to get to the directory the *.py files are in, and then follow the normal instructions on the website. I guess you could first check that Terminal can find Python, by running "python --version" from Terminal.

  8. #8
    i 'think' i'm getting somwhere. *i now assume i should be running this from Command Prompt not from within Python*
    if so it appears something is happening, not sure it's all good.

    C:\Users\TeamSpeed> python eddb.py --download
    'python' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\TeamSpeed>cd E:\Python

    C:\Users\TeamSpeed>E:\Python
    'E:\Python' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\TeamSpeed>cd\E:\Python
    The filename, directory name, or volume label syntax is incorrect.

    C:\Users\TeamSpeed>cd python
    The system cannot find the path specified.

    C:\Users\TeamSpeed>e:

    E:\Python>python eddb.py --download
    [2015-11-06 21:08:19,855] [eddb ] Downloading EDDB Systems list from http://eddb.io/archive/v4/systems.json ...
    Traceback (most recent call last):
    File "eddb.py", line 76, in <module>
    download_eddb_files(default_systems_file, default_stations_file)
    File "eddb.py", line 33, in download_eddb_files
    urllib.urlretrieve(eddb_systems_url, sys_file)
    AttributeError: module 'urllib' has no attribute 'urlretrieve'

    E:\Python>python coriolis.py --download
    [2015-11-06 21:09:41,737] [coriolis] Downloading Coriolis FSD list from https://raw.githubusercontent.com/cm...ift_drive.json ...
    Traceback (most recent call last):
    File "coriolis.py", line 53, in <module>
    download_coriolis_files(default_frame_shift_drive_file)
    File "coriolis.py", line 27, in download_coriolis_files
    urllib.urlretrieve(coriolis_frame_shift_drive_url, frame_shift_drive_file)
    AttributeError: module 'urllib' has no attribute 'urlretrieve'

    E:\Python>python edts.py -j 35.2 --start="Sol/Galileo" --end="Alioth/Golden Gate" "Wolf 359/Powell High" "Agartha/Enoch Port" "Alpha Centauri"
    File "edts.py", line 167
    print ""
    ^
    SyntaxError: Missing parentheses in call to 'print'

    E:\Python>python edts.py -j 35.2 --start="Sol/Galileo" --end="Alioth/Golden Gate" "Wolf 359/Powell High" "Agartha/Enoch Port" "Alpha Centauri"
    File "edts.py", line 167
    print ""
    ^
    SyntaxError: Missing parentheses in call to 'print'

    E:\Python

  9. #9
    Originally Posted by superflyguy View Post (Source)
    i 'think' i'm getting somwhere. *i now assume i should be running this from Command Prompt not from within Python*
    if so it appears something is happening, not sure it's all good.
    You're definitely getting somewhere, but now you're running into the same Python 2 vs Python 3 problems I did an hour ago
    I've just pushed a version which should fix all those issues, so if you redownload it and try again you should have better luck. At least, I ran into every error in your post when I tried it with Python 3, and after my changes just now I no longer am.

    Thanks for persevering with this! I'll make sure and test any future additions in both Python 2 and 3; hopefully that should be nice and easy now the existing code is working on both.

    EDIT: Just found yet another thing not quite working properly ... and fixed!

  10. #10
    good. good. bad

    -------------------------------------------------------------------
    E:\Python>python eddb.py --download
    [2015-11-06 22:39:51,673] [eddb ] Downloading EDDB Systems list from http://eddb.io/archive/v4/systems.json ...
    [2015-11-06 22:39:55,065] [eddb ] Done.
    [2015-11-06 22:39:55,065] [eddb ] Downloading EDDB Stations list from http://eddb.io/archive/v4/stations.json ...
    [2015-11-06 22:40:01,150] [eddb ] Done.
    [2015-11-06 22:40:01,564] [eddb ] Systems file exists and loads OK (48992 systems)
    [2015-11-06 22:40:02,674] [eddb ] Stations file exists and loads OK (40713 stations)

    E:\Python>python coriolis.py --download
    [2015-11-06 22:40:40,290] [coriolis] Downloading Coriolis FSD list from https://raw.githubusercontent.com/cm...ift_drive.json ...
    [2015-11-06 22:40:40,949] [coriolis] Done.
    [2015-11-06 22:40:40,949] [coriolis] FSD file exists and loads OK (35 drives)

    E:\Python>python edts.py -j 35.2 --start="Sol/Galileo" --end="Alioth/Golden Gate" "Wolf 359/Powell High" "Agartha/Enoch Port" "Alpha Centauri"
    Traceback (most recent call last):
    File "edts.py", line 8, in <module>
    import env
    File "E:\Python\env.py", line 95, in <module>
    eddb_stations = eddb.load_stations(global_args.eddb_stations_file)
    File "E:\Python\eddb.py", line 65, in load_stations
    return load_json(filename, eddb_stations_file_size_limit)
    File "E:\Python\eddb.py", line 69, in load_json
    return json.loads(f.read(size_limit))
    MemoryError
    -------------------------------------------------------------------

    help required, again!

  11. #11
    Originally Posted by superflyguy View Post (Source)
    File "E:\Python\eddb.py", line 69, in load_json
    return json.loads(f.read(size_limit))
    MemoryError
    -------------------------------------------------------------------

    help required, again!
    Hmm... That suggests it's failing to load the EDDB station data (i.e. details of all the stations), which is weird... I've never seen that fail, on several different machines (one of which only had 1GB of RAM).
    How much RAM does the machine you're using have? On my machine the Python interpreter ends up using a total of about 160MB once it's all loaded, so it should only need about that much free.

    It's especially confusing because it successfully loaded those same files after downloading them ("Stations file exists and loads OK")... Very weird.

  12. #12
    Works fine here on cygwin with both 2.7 and 3.4. Well done, btw.

  13. #13
    Originally Posted by Esvandiary View Post (Source)
    Hmm... That suggests it's failing to load the EDDB station data (i.e. details of all the stations), which is weird... I've never seen that fail, on several different machines (one of which only had 1GB of RAM).
    How much RAM does the machine you're using have? On my machine the Python interpreter ends up using a total of about 160MB once it's all loaded, so it should only need about that much free.

    It's especially confusing because it successfully loaded those same files after downloading them ("Stations file exists and loads OK")... Very weird.
    Hi! Esvandiary.
    I sent a PM... had the memory issue and managed to fix it (for my environment).
    Regards
    Onane

  14. #14
    Originally Posted by Onane View Post (Source)
    Hi! Esvandiary.
    I sent a PM... had the memory issue and managed to fix it (for my environment).
    Regards
    Onane
    So I see! I've just pushed a new version with that limit adjusted, so hopefully it should now work properly for superflyguy too... Thanks very much!

  15. #15
    Sent a little bug report to bitbucket... about trundle mode

Page 1 of 3 123 LastLast