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 ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/Rakefile CHANGED
@@ -1,28 +1,19 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
1
4
  begin
2
- require 'jeweler'
3
- Jeweler::Tasks.new do |gem|
4
- gem.name = "polaris"
5
- gem.rubyforge_project = "polaris"
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
- Jeweler::GemcutterTasks.new
10
+
11
+ task :default => :spec
17
12
  rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
13
+ puts "please install rspec to run tests"
14
+ puts "install with gem install rspec"
19
15
  end
20
16
 
21
- require 'spec/rake/spectask'
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
@@ -58,4 +58,4 @@ class LineOfSite
58
58
  coords
59
59
  end
60
60
 
61
- end
61
+ end
@@ -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 current_element.location, current_element
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)
@@ -0,0 +1,11 @@
1
+ class Polaris
2
+ module VERSION #:nodoc:
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ TINY = 0
6
+
7
+ ARRAY = [MAJOR, MINOR, TINY]
8
+ STRING = ARRAY.join('.')
9
+ end
10
+ end
11
+
@@ -7,15 +7,22 @@ class TwoDGridLocation
7
7
  end
8
8
 
9
9
  def <=>(b)
10
- ret = 1
11
- if @x == b.x && @y == b.y
12
- ret = 0
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
@@ -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 = %q{polaris}
8
- s.version = "0.0.2"
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.extra_rdoc_files = [
16
- "README.txt"
17
- ]
18
- s.files = [
19
- "README.txt",
20
- "Rakefile",
21
- "VERSION",
22
- "lib/line_of_site.rb",
23
- "lib/polaris.rb",
24
- "lib/two_d_grid_location.rb",
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
- if s.respond_to? :specification_version then
44
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
- s.specification_version = 3
23
+ s.add_dependency "algorithms"
46
24
 
47
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
- s.add_development_dependency(%q<rspec>, [">= 0"])
49
- s.add_development_dependency(%q<jeweler>, [">= 0"])
50
- s.add_runtime_dependency(%q<algorithms>, [">= 0"])
51
- else
52
- s.add_dependency(%q<rspec>, [">= 0"])
53
- s.add_dependency(%q<jeweler>, [">= 0"])
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
+
@@ -2,3 +2,6 @@ here = File.dirname(__FILE__)
2
2
  polaris_root = File.expand_path(File.join(here, '..', 'lib'))
3
3
 
4
4
  $: << polaris_root
5
+ require 'polaris'
6
+ require 'line_of_site'
7
+ require 'two_d_grid_map'
@@ -1,6 +1,4 @@
1
1
  require File.join(File.dirname(__FILE__),'helper')
2
- require 'line_of_site'
3
- require 'two_d_grid_map'
4
2
 
5
3
  describe 'A new LineOfSite' do
6
4
  before do
@@ -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
- prerelease: false
5
- segments:
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
- date: 2010-02-27 00:00:00 -05:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
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
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
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
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
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
- requirement: &id003 !ruby/object:Gem::Requirement
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
- extra_rdoc_files:
63
- - README.txt
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
- has_rdoc: true
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
- - --charset=UTF-8
83
- require_paths:
123
+ rdoc_options: []
124
+ require_paths:
84
125
  - lib
85
- required_ruby_version: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- segments:
90
- - 0
91
- version: "0"
92
- required_rubygems_version: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- segments:
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.3.6
140
+ rubygems_version: 1.8.10
103
141
  signing_key:
104
142
  specification_version: 3
105
- summary: A* pathfinding in ruby.
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