pathing 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +55 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afb27fb129cf526ac658ac0df464f094791bb0e0
|
4
|
+
data.tar.gz: 8c8efa03a5f7fe2584c58d109520e600c8dcec99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82f0669c363d9566f91ac2966307addda396f275a2d4ef9cfa28454fff74e0b49fa65532cb12a36c90061bec0c6352f9c408550805fa7cfcb5e2d710a2dfc8bd
|
7
|
+
data.tar.gz: a4246a43c471472b9b16c7ac6590efcaac80b433c885e5bd76b95d70b971e3099dfc05f2a03d15fd11e3fc8e9516ba601f72129682ca0f006f19399ad9ffbc7e
|
data/README.md
CHANGED
@@ -1,2 +1,56 @@
|
|
1
|
-
# pathing
|
1
|
+
# pathing v0.1.1
|
2
|
+
|
2
3
|
Dijkstra's algorithm pathfinding in Ruby
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- **Quick** - written in C as a Ruby extension!
|
8
|
+
- **Flexible** - use your own graph interface!
|
9
|
+
- **Simple** - describe your graph, call one method, and you have your path!
|
10
|
+
|
11
|
+
## Sample Usage
|
12
|
+
|
13
|
+
The easiest way to download the gem is to use [Bundler](http://bundler.io/) with a Gemfile. In your Gemfile, include the line `gem 'pathing'`. Then you can run `bundle install` to automatically download and compile the gem for your system. To include the gem in a Ruby file, use the line `require 'pathing'`.
|
14
|
+
|
15
|
+
To do some pathfinding, first set up a graph interface object. This object defines the entire layout of your graph. The following example is one way of achieving a two-dimensional grid with neighbors only in the cardinal directions.
|
16
|
+
```
|
17
|
+
class Interface
|
18
|
+
SIZE = 32
|
19
|
+
|
20
|
+
# gets an array of neighbors for the given node key
|
21
|
+
# for this example, the node key is passed in as an array like so: [x, y]
|
22
|
+
def neighbors_for(node_key)
|
23
|
+
x, y = *node_key
|
24
|
+
neighbors = []
|
25
|
+
|
26
|
+
neighbors << [x-1, y] if x > 0
|
27
|
+
neighbors << [x, y-1] if y > 0
|
28
|
+
neighbors << [x+1, y] if x < SIZE-1
|
29
|
+
neighbors << [x, y+1] if y < SIZE-1
|
30
|
+
|
31
|
+
neighbors
|
32
|
+
end
|
33
|
+
|
34
|
+
# gets the cost for moving from node1 to node2
|
35
|
+
def edge_cost_between(node1_key, node2_key)
|
36
|
+
1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
Now, create a `Graph` object referencing your interface object.
|
42
|
+
```
|
43
|
+
graph = Pathing::Graph.new(Interface.new)
|
44
|
+
```
|
45
|
+
|
46
|
+
You're all set. Simply call
|
47
|
+
```
|
48
|
+
graph.path([0,0], [15, 20])
|
49
|
+
```
|
50
|
+
to get your optimized path!
|
51
|
+
|
52
|
+
## Credits
|
53
|
+
|
54
|
+
Copyright (c) 2015 [Nick Lowery](https://github.com/ClockVapor)
|
55
|
+
|
56
|
+
View LICENSE for full license.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Lowery
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: Dijkstra's algorithm pathfinding
|
27
|
+
description: Quick and flexible Dijkstra's algorithm pathfinding
|
28
28
|
email: nick.a.lowery@gmail.com
|
29
29
|
executables: []
|
30
30
|
extensions:
|
@@ -42,7 +42,7 @@ files:
|
|
42
42
|
- ext/pathing/pathing.c
|
43
43
|
- ext/pathing/pathing.h
|
44
44
|
- ext/pathing/util.h
|
45
|
-
homepage:
|
45
|
+
homepage: ''
|
46
46
|
licenses:
|
47
47
|
- MIT
|
48
48
|
metadata: {}
|
@@ -65,5 +65,5 @@ rubyforge_project:
|
|
65
65
|
rubygems_version: 2.4.3
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
|
-
summary: Dijkstra's algorithm pathfinding
|
68
|
+
summary: Quick and flexible Dijkstra's algorithm pathfinding
|
69
69
|
test_files: []
|