Sha256: 56b0a4eb22fd5d84ec91b38e7aa5ac7987d1e9b21e7391bafcef54bb8c191d32

Contents?: true

Size: 727 Bytes

Versions: 28

Compression:

Stored size: 727 Bytes

Contents

$: << File.dirname(__FILE__)+"/../lib/gamebox"

require 'ai/polaris'
require 'ai/two_d_grid_map'

@map = TwoDGridMap.new 100, 90

from = TwoDGridLocation.new 0, 0
to = TwoDGridLocation.new 9, 0
@pather = Polaris.new @map

require 'benchmark'
Benchmark.bm do|b|
  
  b.report("warm up") do
    10.times { path = @pather.guide(from,to) }
  end

  b.report("shorter path") do
    10.times { path = @pather.guide(from,to) }
  end

  to = TwoDGridLocation.new 92, 0
  b.report("longer path") do
    10.times { path = @pather.guide(from,to) }
  end

  # put up a wall
  @map.h.times do |i|
    @map.place TwoDGridLocation.new(89, i), "ME"
  end

  b.report("blocked path") do
    10.times { path = @pather.guide(from,to) }
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
gamebox-0.5.5 script/perf_polaris.rb
gamebox-0.5.4 script/perf_polaris.rb
gamebox-0.5.2 script/perf_polaris.rb
gamebox-0.5.1 script/perf_polaris.rb
gamebox-0.5.0 script/perf_polaris.rb
gamebox-0.4.1 script/perf_polaris.rb
gamebox-0.4.0 script/perf_polaris.rb
gamebox-0.4.0.rc11 script/perf_polaris.rb
gamebox-0.4.0.rc5 script/perf_polaris.rb
gamebox-0.4.0.rc4 script/perf_polaris.rb
gamebox-0.4.0.rc3 script/perf_polaris.rb
gamebox-0.4.0.rc2 script/perf_polaris.rb
gamebox-0.4.0.rc1 script/perf_polaris.rb
gamebox-0.3.4 script/perf_polaris.rb
gamebox-0.3.3 script/perf_polaris.rb
gamebox-0.3.2 script/perf_polaris.rb
gamebox-0.2.1 script/perf_polaris.rb
gamebox-0.1.1 script/perf_polaris.rb
gamebox-0.1.0 script/perf_polaris.rb
gamebox-0.0.9 script/perf_polaris.rb