From 9c47e51edd0839d2a5cc5579e30254bacbea1cf3 Mon Sep 17 00:00:00 2001 From: Afri <58883403+q9f@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:14:14 +0100 Subject: [PATCH] docs: add Changelog (#2) * docs: add Changelog * docs: add Changelog --- CHANGELOG.md | 16 ++++++++++++++++ README.md | 29 ++++++++++++++++++++++++----- examples/distance.rb | 6 +++--- 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5f5bef5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +### Frontier.rb v0.0.1 + +- Docs: add changelog ([#2](https://github.com/q9f/frontier.rb/pulls/2)) +- Ci: enable github actions ([#1](https://github.com/q9f/frontier.rb/pulls/1)) +- Examples: add distance script +- Examples: add progress tracking +- Docs: clarify limitations +- Graph: fix edge case for missing vertices +- Gem: add usage example +- Graph: use dijkstra's algorithm for path finding +- Coords: add class to handle 3d coordinates in space +- Frontier: add version 0.0.1 +- Coords: Fix coords spec +- Star: add struct for handling star systems +- Coords: add class to handle 3d coordinates in space +- Initial commit for the Frontier library diff --git a/README.md b/README.md index 458b85f..8d09409 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Limitations: - path finding on 24k star systems can hit the limits of Ruby (SystemStackError: stack level too deep), try running shorter queries over less distance and combine the results ## Installation -The gem is not published yet, but yuo can install it locally: +The gem is not published yet, but you can install it locally: ``` git clone https://github.com/q9f/frontier.rb @@ -27,21 +27,30 @@ require "frontier" include Frontier ``` -### Shortest path between two star systems -Get the shortest path between `D:S299` and `Y:1SII`. +### Direct distance between two star systems +Get the direct distance between `D:S299` and `Y:1SII`. ```ruby -best_smart_gate_path = UNIVERSE_GRAPH.shortest_path("D:S299", "Y:1SII") +direct_distance = ALL_STARS["D:S299"].distance_ly(ALL_STARS["Y:1SII"]) ``` See [examples/](./examples/) for usage and options to fine-tune. -```ruby +```bash ❯ ruby examples/distance.rb "D:S299" "Y:1SII" 1974.926982542737 ``` +### Shortest jump-path between two star systems +Get the shortest path between `D:S299` and `Y:1SII`. + ```ruby +best_smart_gate_path = UNIVERSE_GRAPH.shortest_path("D:S299", "Y:1SII") +``` + +See [examples/](./examples/) for usage and options to fine-tune. + +```bash ❯ ruby examples/pathfinder.rb Mapping all star systems ... done. Building universe graph ... done. @@ -51,6 +60,16 @@ Building universe graph ... done. "dist"=>1978.63507044974} ``` +### Frontier console + +Run the console to make ad-hoc computations on the command line: + +```bash +❯ ./bin/console +[1] pry(main)> g = Graph.new +=> #> +``` + ## Testing To run tests, simply use `rspec`. diff --git a/examples/distance.rb b/examples/distance.rb index 5349958..484b41e 100644 --- a/examples/distance.rb +++ b/examples/distance.rb @@ -37,7 +37,7 @@ c_id += 1 end - # Distance between "D:S299" to "Y:1SII" - distance = ALL_STARS["D:S299"].distance_ly(ALL_STARS["Y:1SII"]) - pp distance + # Direct distance between "D:S299" to "Y:1SII" + direct_distance = ALL_STARS["D:S299"].distance_ly(ALL_STARS["Y:1SII"]) + pp direct_distance end