-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.lua
51 lines (34 loc) · 858 Bytes
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--
-- test.lua
-- lua-astar
--
-- Created by Jay Roberts on 2011-01-12.
-- Copyright 2011 GloryFish.org. All rights reserved.
--
-- This is a simple test script which demonstrates the AStar class in use.
--
require 'astar'
require 'tiledmaphandler'
require 'profiler'
local handler = TiledMapHandler()
local astar = AStar(handler)
profiler = newProfiler()
profiler:start()
print 'Beginning...'
for i=1,1000 do
local start = {
x = math.random(1, 23),
y = math.random(1, 23)
}
local goal = {
x = math.random(1, 23),
y = math.random(1, 23)
}
-- print(string.format('Testing: (%i, %i) (%i, %i)', start.x, start.y, goal.x, goal.y))
local path = astar:findPath(start, goal)
end
print 'Done'
profiler:stop()
local outfile = io.open('profile.txt', 'w+')
profiler:report(outfile)
outfile:close()