DESCRIPTION:
Ruby interface to a C++ implemention of the A* search algorithm.
The C++ implementaion is found here http://code.google.com/p/a-star-algorithm-implementation/
FEATURES:
SYNOPSIS:
See spec\castar_spec.rb
for usage examples.
Create an empty map and plan a path across it:
require 'castar'
include Castar
map = init_map(:width => 4, :height => 3)
astar = HeyesDriver.new(map, HeyesDriver::EIGHT_NEIGHBORS)
astar.run(0,0,3,2)
puts get_map_with_path(astar)
|S|1|1|1|
|1|*|1|1|
|1|1|*|G|
Load a map from a text file and plan a path:
map = load_map('./spec/map_20.txt')
astar = HeyesDriver.new(map, HeyesDriver::EIGHT_NEIGHBORS)
astar.run(0,0,19,19)
puts get_map_with_path(astar)
|S|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
|1|*|*|*|*|*|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
|1|1|9|9|9|9|*|1|1|1|1|9|9|9|9|9|9|9|9|9|
|1|1|9|9|9|9|1|*|1|1|1|9|9|9|9|9|9|9|9|9|
|1|1|9|9|9|9|1|1|*|1|1|9|9|9|9|9|9|9|9|9|
|1|1|9|9|9|9|1|1|1|*|1|9|9|9|9|9|9|9|9|9|
|1|1|9|9|9|9|1|1|1|1|*|9|9|9|9|9|9|9|9|9|
|1|1|9|9|9|9|1|1|1|1|*|9|9|9|9|9|9|9|9|9|
|1|1|1|1|1|1|1|1|1|1|*|9|9|9|9|9|9|9|9|9|
|1|1|1|1|1|1|1|1|1|1|*|9|9|9|9|9|9|9|9|9|
|1|1|1|1|1|1|1|1|1|1|1|*|1|1|1|1|1|1|1|1|
|1|1|1|1|1|1|1|1|1|1|1|1|*|*|*|*|*|1|1|1|
|1|1|1|1|1|9|9|9|9|9|9|9|9|9|9|9|9|*|1|1|
|1|1|1|1|1|9|9|9|9|9|9|9|9|9|9|9|9|1|*|1|
|1|1|1|1|1|9|9|9|9|9|9|9|9|9|9|9|9|1|1|*|
|1|1|1|1|1|9|9|9|9|9|9|9|9|9|9|9|9|1|1|*|
|1|1|1|1|1|9|9|9|9|9|9|9|9|9|9|9|9|1|1|*|
|1|1|1|1|1|9|9|9|9|9|9|9|9|9|9|9|9|1|1|*|
|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|*|
|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|G|
REQUIREMENTS:
- Ruby 1.9
- C compiler for C extensions
DEVELOPMENT
To modify the gem in a cloned repo this is what I'm doing (from root of gem):
bundle install
cd ext/
ruby extconf.rb
make
These steps will install the development dependencies, build the Makefile and compile the C++ code. Running
bundle exec rspec ./spec
should show all tests passing. To clean up the autogenerated Makefile and the compiled objects:
cd ext/
make realclean
If you need to regenerate the ruby interface functions heyes_wrap.cxx
, run:
cd swig/
swig -c++ -ruby heyes.i
mv heyes_wrap.cxx ../ext
If you are just trying to run the tests:
rake build
gem install pkg/castar-0.0.1.gem
builds the gem and installs it to your local machine.
gem which castar
tells you where it is. You can then cd to that directory and run the tests as above (but since you're not in a git repo you can't commit them).
I followed the instructions here for using Bundler to create the gem.
To run the benchmarks:
bundle install
cd swig/
./buildRubyExtension.sh
cd ../benchmarks
bundle exec ruby -I . ./benchmarker.rb
BIG_OBSTACLE | SMALL_OBSTACLES |
----------------------------------------------------------------------------------
using polaris 1.150 | 0.468 |
using c++ implementation 0.034 | 0.079 |
using c++ implementation, eight neighbors 0.010 | 0.014 |
INSTALL:
- gem install castar
LICENSE:
(The MIT License)