polaris 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Rakefile +12 -21
- data/lib/line_of_site.rb +1 -1
- data/lib/polaris.rb +7 -4
- data/lib/polaris/version.rb +11 -0
- data/lib/two_d_grid_location.rb +13 -6
- data/polaris.gemspec +24 -52
- data/spec/helper.rb +3 -0
- data/spec/line_of_site_spec.rb +0 -2
- data/spec/polaris_spec.rb +2 -2
- metadata +111 -73
- data/VERSION +0 -1
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,28 +1,19 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
1
4
|
begin
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
gem.summary = %Q{A* pathfinding in ruby.}
|
7
|
-
gem.description = %Q{A* pathfinding in Ruby, using C datastructures to speed things up.}
|
8
|
-
gem.email = "shawn42@gmail.com"
|
9
|
-
gem.homepage = "http://github.com/shawn42/polaris"
|
10
|
-
gem.authors = ["Shawn Anderson"]
|
11
|
-
gem.add_development_dependency "rspec"
|
12
|
-
gem.add_development_dependency "jeweler"
|
13
|
-
gem.add_dependency 'algorithms'
|
14
|
-
gem.test_files = FileList['{spec,test}/**/*.rb']
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
desc "Run all rspecs"
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
+
t.pattern = 'spec/**/*_spec.rb'
|
15
9
|
end
|
16
|
-
|
10
|
+
|
11
|
+
task :default => :spec
|
17
12
|
rescue LoadError
|
18
|
-
puts "
|
13
|
+
puts "please install rspec to run tests"
|
14
|
+
puts "install with gem install rspec"
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
|
-
desc "Run all rspecs"
|
23
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
24
|
-
t.spec_files = FileList['spec/*_spec.rb']
|
25
|
-
end
|
26
|
-
task :default => :spec
|
17
|
+
|
27
18
|
|
28
19
|
# vim: syntax=Ruby
|
data/lib/line_of_site.rb
CHANGED
data/lib/polaris.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'polaris/version'
|
2
|
+
|
1
3
|
require 'algorithms'
|
2
4
|
include Containers
|
3
5
|
|
@@ -37,16 +39,17 @@ class Polaris
|
|
37
39
|
|
38
40
|
return path
|
39
41
|
else
|
40
|
-
closed.push
|
42
|
+
closed.push loc, current_element
|
41
43
|
@map.neighbors(loc).each do |next_door|
|
42
|
-
el = PathElement.new(next_door,current_element)
|
43
44
|
next if closed.has_key? next_door
|
44
|
-
|
45
|
+
|
46
|
+
el = PathElement.new(next_door,current_element)
|
47
|
+
|
45
48
|
if @map.blocked? next_door, unit_type
|
46
49
|
closed.push el.location, el
|
47
50
|
else
|
48
51
|
current_rating = current_element.cost_to + @map.cost(loc, next_door)
|
49
|
-
|
52
|
+
|
50
53
|
# add to open
|
51
54
|
el.cost_to = current_rating
|
52
55
|
el.dist_from = @map.distance(next_door,to)
|
data/lib/two_d_grid_location.rb
CHANGED
@@ -7,15 +7,22 @@ class TwoDGridLocation
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def <=>(b)
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if @x < b.x
|
11
|
+
-1
|
12
|
+
elsif @x > b.x
|
13
|
+
1
|
14
|
+
else
|
15
|
+
if @y < b.y
|
16
|
+
-1
|
17
|
+
elsif @y > b.y
|
18
|
+
1
|
19
|
+
else
|
20
|
+
0
|
21
|
+
end
|
13
22
|
end
|
14
|
-
ret = -1 if @x <= b.x && @y < b.y
|
15
|
-
return ret
|
16
23
|
end
|
17
24
|
|
18
25
|
def to_s
|
19
26
|
"#{@x},#{@y}"
|
20
27
|
end
|
21
|
-
end
|
28
|
+
end
|
data/polaris.gemspec
CHANGED
@@ -1,62 +1,34 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "polaris/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.name = "polaris"
|
7
|
+
s.version = Polaris::VERSION::STRING
|
8
|
+
s.platform = Gem::Platform::RUBY
|
11
9
|
s.authors = ["Shawn Anderson"]
|
12
|
-
s.date = %q{2010-02-27}
|
13
|
-
s.description = %q{A* pathfinding in Ruby, using C datastructures to speed things up.}
|
14
10
|
s.email = %q{shawn42@gmail.com}
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
s.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"lib/two_d_grid_map.rb",
|
26
|
-
"polaris.gemspec",
|
27
|
-
"spec/helper.rb",
|
28
|
-
"spec/line_of_site_spec.rb",
|
29
|
-
"spec/polaris_spec.rb"
|
30
|
-
]
|
31
|
-
s.homepage = %q{http://github.com/shawn42/polaris}
|
32
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
11
|
+
s.homepage = %q{http://shawn42.github.com/gamebox}
|
12
|
+
s.description = %q{A* pathfinding in Ruby, using C datastructures to speed things up.}
|
13
|
+
s.summary = %q{A* pathfinding in Ruby, using C datastructures to speed things up.}
|
14
|
+
s.rubyforge_project = "polaris"
|
15
|
+
|
16
|
+
s.date = %q{2010-02-27}
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n").reject{ |f| f[/^examples\//] || f[/^\./] }
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
33
21
|
s.require_paths = ["lib"]
|
34
|
-
s.rubyforge_project = %q{polaris}
|
35
|
-
s.rubygems_version = %q{1.3.6}
|
36
|
-
s.summary = %q{A* pathfinding in ruby.}
|
37
|
-
s.test_files = [
|
38
|
-
"spec/helper.rb",
|
39
|
-
"spec/line_of_site_spec.rb",
|
40
|
-
"spec/polaris_spec.rb"
|
41
|
-
]
|
42
22
|
|
43
|
-
|
44
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
-
s.specification_version = 3
|
23
|
+
s.add_dependency "algorithms"
|
46
24
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
s.add_dependency(%q<algorithms>, [">= 0"])
|
55
|
-
end
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
58
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
59
|
-
s.add_dependency(%q<algorithms>, [">= 0"])
|
60
|
-
end
|
25
|
+
s.add_development_dependency "rspec-core"
|
26
|
+
s.add_development_dependency "rspec-mocks"
|
27
|
+
s.add_development_dependency "rspec-expectations"
|
28
|
+
s.add_development_dependency "mocha"
|
29
|
+
s.add_development_dependency "rspec"
|
30
|
+
s.add_development_dependency "rake"
|
31
|
+
s.add_development_dependency "pry"
|
61
32
|
end
|
62
33
|
|
34
|
+
|
data/spec/helper.rb
CHANGED
data/spec/line_of_site_spec.rb
CHANGED
data/spec/polaris_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'helper')
|
2
|
-
require 'polaris'
|
3
|
-
require 'two_d_grid_map'
|
4
2
|
|
5
3
|
describe 'A new polaris' do
|
6
4
|
before do
|
@@ -180,11 +178,13 @@ describe 'A new polaris' do
|
|
180
178
|
it 'should return nil when the path does not exist' do
|
181
179
|
from = TwoDGridLocation.new 0, 0
|
182
180
|
to = TwoDGridLocation.new 2, 0
|
181
|
+
@pather.nodes_considered.should == 0
|
183
182
|
|
184
183
|
# put up a wall
|
185
184
|
@map.h.times do |i|
|
186
185
|
@map.place TwoDGridLocation.new(1, i), "ME"
|
187
186
|
end
|
187
|
+
# @map = TwoDGridMap.new 10, 20
|
188
188
|
|
189
189
|
path = @pather.guide(from,to)
|
190
190
|
path.should == nil
|
metadata
CHANGED
@@ -1,109 +1,147 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: polaris
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Shawn Anderson
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
date: 2010-02-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: algorithms
|
16
|
+
requirement: &2153157860 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2153157860
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec-core
|
27
|
+
requirement: &2153157440 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2153157440
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-mocks
|
38
|
+
requirement: &2152538480 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2152538480
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-expectations
|
49
|
+
requirement: &2152537380 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2152537380
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mocha
|
60
|
+
requirement: &2152536060 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2152536060
|
69
|
+
- !ruby/object:Gem::Dependency
|
21
70
|
name: rspec
|
71
|
+
requirement: &2152532900 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
22
78
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
79
|
+
version_requirements: *2152532900
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rake
|
82
|
+
requirement: &2152530940 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
30
88
|
type: :development
|
31
|
-
version_requirements: *id001
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: jeweler
|
34
89
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
90
|
+
version_requirements: *2152530940
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: pry
|
93
|
+
requirement: &2153197700 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
42
99
|
type: :development
|
43
|
-
version_requirements: *id002
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
name: algorithms
|
46
100
|
prerelease: false
|
47
|
-
|
48
|
-
requirements:
|
49
|
-
- - ">="
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
segments:
|
52
|
-
- 0
|
53
|
-
version: "0"
|
54
|
-
type: :runtime
|
55
|
-
version_requirements: *id003
|
101
|
+
version_requirements: *2153197700
|
56
102
|
description: A* pathfinding in Ruby, using C datastructures to speed things up.
|
57
103
|
email: shawn42@gmail.com
|
58
104
|
executables: []
|
59
|
-
|
60
105
|
extensions: []
|
61
|
-
|
62
|
-
|
63
|
-
-
|
64
|
-
files:
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- Gemfile
|
65
109
|
- README.txt
|
66
110
|
- Rakefile
|
67
|
-
- VERSION
|
68
111
|
- lib/line_of_site.rb
|
69
112
|
- lib/polaris.rb
|
113
|
+
- lib/polaris/version.rb
|
70
114
|
- lib/two_d_grid_location.rb
|
71
115
|
- lib/two_d_grid_map.rb
|
72
116
|
- polaris.gemspec
|
73
117
|
- spec/helper.rb
|
74
118
|
- spec/line_of_site_spec.rb
|
75
119
|
- spec/polaris_spec.rb
|
76
|
-
|
77
|
-
homepage: http://github.com/shawn42/polaris
|
120
|
+
homepage: http://shawn42.github.com/gamebox
|
78
121
|
licenses: []
|
79
|
-
|
80
122
|
post_install_message:
|
81
|
-
rdoc_options:
|
82
|
-
|
83
|
-
require_paths:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
84
125
|
- lib
|
85
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
- 0
|
98
|
-
version: "0"
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
99
138
|
requirements: []
|
100
|
-
|
101
139
|
rubyforge_project: polaris
|
102
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 1.8.10
|
103
141
|
signing_key:
|
104
142
|
specification_version: 3
|
105
|
-
summary: A* pathfinding in
|
106
|
-
test_files:
|
143
|
+
summary: A* pathfinding in Ruby, using C datastructures to speed things up.
|
144
|
+
test_files:
|
107
145
|
- spec/helper.rb
|
108
146
|
- spec/line_of_site_spec.rb
|
109
147
|
- spec/polaris_spec.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.2
|