[
  {
    "path": ".gitignore",
    "content": "*.yml\n*.ld\n*.bat\ntsc\ntest*\nldoc*\ntelescope*\nhkl\ndebug*\nprofiler*"
  },
  {
    "path": "LICENSE.txt",
    "content": "Copyright (c) 2012-2013 Roland Yonaba\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "Jumper\n======\n\n[![Join the chat at https://gitter.im/Yonaba/Jumper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Yonaba/Jumper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n[![Build Status](https://secure.travis-ci.org/Yonaba/Jumper.png)](http://travis-ci.org/Yonaba/Jumper)\n\n__Jumper__ is a pathfinding library designed for grid-based games. It aims to be __fast__ and __lightweight__.\nIt features a wide range of search algorithms, built within a clean interface with \nchaining features which makes it __very friendly and easy to use__.<br/>\n\n__Jumper__ is written in pure [Lua][]. Thus, it is not __framework-related__ and can be used in any project embedding [Lua][] code.\n\n## Installation\nThe current repository can be retrieved locally on your computer via:\n\n### Bash\n```bash\ngit clone git://github.com/Yonaba/Jumper.git\n````\n\n### Download (latest)\n* __Development version__: [zip](http://github.com/Yonaba/Jumper/zipball/master) | [tar.gz](http://github.com/Yonaba/Jumper/tarball/master) ( __please do not use this!__ )\n* __Latest stable release (1.8.1)__: [zip](http://github.com/Yonaba/Jumper/archive/jumper-1.8.1-1.zip) | [tar.gz](http://github.com/Yonaba/Jumper/archive/jumper-1.8.1-1.tar.gz) ( __Recommended!__ )\n* __All stable releases__: [tags](http://github.com/Yonaba/Jumper/tags)\n\n\n### LuaRocks\n```bash\nluarocks install jumper\n````\n\n### MoonRocks\n```bash\nluarocks install --server=http://rocks.moonscript.org/manifests/Yonaba jumper\n````\n\n## Installing Jumper\nCopy the contents of the folder named [jumper](http://github.com/Yonaba/Jumper/blob/master/jumper) and its contents and place it inside your projet. Use *require* function to import any module of the library.\n\n## A Simple Example of Use\nHere is a simple example explaining how to use Jumper:\n\n```lua\n-- Usage Example\n-- First, set a collision map\nlocal map = {\n\t{0,1,0,1,0},\n\t{0,1,0,1,0},\n\t{0,1,1,1,0},\n\t{0,0,0,0,0},\n}\n-- Value for walkable tiles\nlocal walkable = 0\n\n-- Library setup\nlocal Grid = require (\"jumper.grid\") -- The grid class\nlocal Pathfinder = require (\"jumper.pathfinder\") -- The pathfinder class\n\n-- Creates a grid object\nlocal grid = Grid(map) \n-- Creates a pathfinder object using Jump Point Search\nlocal myFinder = Pathfinder(grid, 'JPS', walkable) \n\n-- Define start and goal locations coordinates\nlocal startx, starty = 1,1\nlocal endx, endy = 5,1\n\n-- Calculates the path, and its length\nlocal path = myFinder:getPath(startx, starty, endx, endy)\nif path then\n  print(('Path found! Length: %.2f'):format(path:getLength()))\n\tfor node, count in path:nodes() do\n\t  print(('Step: %d - x: %d - y: %d'):format(count, node:getX(), node:getY()))\n\tend\nend\n\n--> Output:\n--> Path found! Length: 8.83\n--> Step: 1 - x: 1 - y: 1\n--> Step: 2 - x: 1 - y: 3\n--> Step: 3 - x: 2 - y: 4\n--> Step: 4 - x: 4 - y: 4\n--> Step: 5 - x: 5 - y: 3\n--> Step: 6 - x: 5 - y: 1\n````\n\n## Specs\nSpecs tests have been included.<br/>\nYou can run them using [Telescope](http://github.com/norman/telescope) with the following command \nfrom the [root](http://github.com/Yonaba/Jumper/blob/master/jumper) folder:\n\n```\ntsc -f specs/*\n```\n\n## Credits and Thanks\n\n* [Daniel Harabor][], [Alban Grastien][] : for the [Jump Point Search](http://harablog.wordpress.com/2011/09/07/jump-point-search/) algorithm.<br/>\n* [XueXiao Xu][], [Nathan Witmer][]: for the [JavaScript port][] of the algorithm.<br/>\n* [Steve Donovan](http://github.com/stevedonovan): for the awesome documentation generator tool [LDoc](http://github.com/stevedonovan/ldoc/).\n* [Srdjan Markovic](http://github.com/srdjan-m), for his tremendous feedback.\n\n## License\nThis work is under [MIT-LICENSE][]<br/>\nCopyright (c) 2012-2013 Roland Yonaba.\n\n> Permission is hereby granted, free of charge, to any person obtaining a copy<br/>\n> of this software and associated documentation files (the \"Software\"), to deal<br/>\n> in the Software without restriction, including without limitation the rights<br/>\n> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>\n> copies of the Software, and to permit persons to whom the Software is<br/>\n> furnished to do so, subject to the following conditions:<br/>\n><br/>\n> The above copyright notice and this permission notice shall be included in<br/>\n> all copies or substantial portions of the Software.<br/>\n><br/>\n> THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>\n> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>\n> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE<br/>\n> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>\n> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>\n> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>\n> THE SOFTWARE.\n\n[Jump Point Search]: http://harablog.wordpress.com/2011/09/07/jump-point-search/\n[Lua]: http://lua.org\n[L�ve]: http://love2d.org\n[L�ve2d]: http://love2d.org\n[L�ve 0.8.0 Framework]: http://love2d.org\n[Dragon Age : Origins]: http://dragonage.bioware.com\n[Moving AI]: http://movingai.com\n[Nathan Witmer]: http://github.com/aniero\n[XueXiao Xu]: http://github.com/qiao\n[JavaScript port]: http://github.com/qiao/PathFinding.js\n[Alban Grastien]: http://www.grastien.net/ban/\n[Daniel Harabor]: http://users.cecs.anu.edu.au/~dharabor/home.html\n[the algorithm and the technical papers]: http://users.cecs.anu.edu.au/~dharabor/data/papers/harabor-grastien-aaai11.pdf\n[MIT-LICENSE]: http://www.opensource.org/licenses/mit-license.php\n[heuristics.lua]: http://github.com/Yonaba/Jumper/blob/master/Jumper/core/heuristics.lua\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Yonaba/jumper/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/5165385288dcb27776c96dce1a82e33d \"githalytics.com\")](http://githalytics.com/Yonaba/Jumper)\n"
  },
  {
    "path": "docs/examples/annotatedpathing.lua.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n\n\n<h2>Examples</h2>\n<ul>\n  <li><strong>annotatedpathing.lua</strong></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Example <code>annotatedpathing.lua</code></h1>\n\n    <pre>\n<span class=\"comment\">-- Tests sample for clearance metrics calculation\n</span><span class=\"comment\">-- See Figure 10 at http://aigamedev.com/open/tutorial/clearance-based-pathfinding/\n</span><span class=\"comment\">-- Jump Point Search still has some flaws with clearance based pathfinding\n</span>\n<span class=\"keyword\">local</span> Grid = <span class=\"global\">require</span> <span class=\"string\">'jumper.grid'</span>\n<span class=\"keyword\">local</span> PF = <span class=\"global\">require</span> <span class=\"string\">'jumper.pathfinder'</span>\n<span class=\"keyword\">local</span> map = {\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>}\n}\n<span class=\"keyword\">local</span> grid = Grid(map)\n<span class=\"keyword\">local</span> walkable = <span class=\"keyword\">function</span>(v) <span class=\"keyword\">return</span> v~=<span class=\"number\">2</span> <span class=\"keyword\">end</span>\n<span class=\"keyword\">local</span> finder = PF(grid, <span class=\"string\">'ASTAR'</span>,walkable)\nfinder:annotateGrid()\n<span class=\"keyword\">local</span> finderNames = PF:getFinders()\n\n<span class=\"keyword\">local</span> sx, sy = <span class=\"number\">1</span>,<span class=\"number\">1</span>\n<span class=\"keyword\">local</span> ex, ey = <span class=\"number\">9</span>,<span class=\"number\">9</span>\n<span class=\"keyword\">local</span> agent_size = <span class=\"number\">2</span>\n\n<span class=\"keyword\">for</span> i = <span class=\"number\">1</span>,#finderNames <span class=\"keyword\">do</span>\n\tfinder:setFinder(finderNames[i])\n\t<span class=\"keyword\">local</span> path = finder:getPath(sx, sy, ex, ey, agent_size)\n\t<span class=\"global\">print</span>((<span class=\"string\">'Algorithm used: %s - Path %s'</span>)\n\t\t:format(finder:getFinder(), path <span class=\"keyword\">and</span> <span class=\"string\">'found'</span> <span class=\"keyword\">or</span> <span class=\"string\">'not found'</span>))\n\t<span class=\"keyword\">if</span> path <span class=\"keyword\">then</span>\n\t\t<span class=\"keyword\">for</span> node, count <span class=\"keyword\">in</span> path:nodes() <span class=\"keyword\">do</span>\n\t\t\t<span class=\"global\">print</span>((<span class=\"string\">'  Step %d. (%d,%d)'</span>)\n\t\t\t\t:format(count, node:getPos()))\n\t\t<span class=\"keyword\">end</span>\n\t<span class=\"keyword\">end</span>\n<span class=\"keyword\">end</span></pre>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/examples/customheuristics.lua.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n\n\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><strong>customheuristics.lua</strong></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Example <code>customheuristics.lua</code></h1>\n\n    <pre>\n<span class=\"comment\">--- Example of use for Heuristics\n</span>\n<span class=\"keyword\">local</span> Grid = <span class=\"global\">require</span> (<span class=\"string\">\"jumper.grid\"</span>)\n<span class=\"keyword\">local</span> Pathfinder = <span class=\"global\">require</span> (<span class=\"string\">\"jumper.pathfinder\"</span>)\n\n<span class=\"keyword\">local</span> map = {\n  {<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n  {<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n  {<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>},\n  {<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n  {<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n}\n\n<span class=\"keyword\">local</span> walkable = <span class=\"number\">0</span>\n<span class=\"keyword\">local</span> grid = Grid(map)\n<span class=\"keyword\">local</span> myFinder = Pathfinder(grid, <span class=\"string\">'ASTAR'</span>, walkable)\n\n<span class=\"comment\">-- Use Euclidian heuristic to evaluate distance\n</span>myFinder:setHeuristic(<span class=\"string\">'EUCLIDIAN'</span>)\nmyFinder:setHeuristic(<span class=\"string\">'DIAGONAL'</span>)\nmyFinder:setHeuristic(<span class=\"string\">'MANHATTAN'</span>)\n\n<span class=\"comment\">-- Custom\n</span><span class=\"keyword\">local</span> h = <span class=\"keyword\">function</span>(nodeA, nodeB)\n\t<span class=\"keyword\">return</span> (<span class=\"number\">0.1</span> * (<span class=\"global\">math</span>.abs(nodeA:getX() - nodeB:getX()))\n\t      + <span class=\"number\">0.9</span> * (<span class=\"global\">math</span>.abs(nodeA:getY() - nodeB:getY())))\n<span class=\"keyword\">end</span>\nmyFinder:setHeuristic(h)\n\n<span class=\"keyword\">local</span> p = myFinder:getPath(<span class=\"number\">1</span>,<span class=\"number\">1</span>, <span class=\"number\">6</span>,<span class=\"number\">5</span>)\n<span class=\"keyword\">for</span> node, count <span class=\"keyword\">in</span> p:nodes() <span class=\"keyword\">do</span>\n  <span class=\"global\">print</span>((<span class=\"string\">'%d. Node(%d,%d)'</span>):format(count, node:getX(), node:getY()))\n<span class=\"keyword\">end</span>\n<span class=\"global\">print</span>((<span class=\"string\">'Path length: %.2f'</span>):format(p:getLength()))\n\n<span class=\"comment\">-- etc ...\n</span></pre>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/examples/makeclearance.lua.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n\n\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><strong>makeclearance.lua</strong></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Example <code>makeclearance.lua</code></h1>\n\n    <pre>\n<span class=\"comment\">-- Tests sample for clearance metrics calculation\n</span><span class=\"comment\">-- See Figure 10 at http://aigamedev.com/open/tutorial/clearance-based-pathfinding/\n</span><span class=\"keyword\">local</span> Grid = <span class=\"global\">require</span> <span class=\"string\">'jumper.grid'</span>\n<span class=\"keyword\">local</span> PF = <span class=\"global\">require</span> <span class=\"string\">'jumper.pathfinder'</span>\n<span class=\"keyword\">local</span> map = {\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">2</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>}\n}\n<span class=\"keyword\">local</span> grid = Grid(map)\n<span class=\"keyword\">local</span> walkable = <span class=\"keyword\">function</span>(v) <span class=\"keyword\">return</span> v~=<span class=\"number\">2</span> <span class=\"keyword\">end</span>\n<span class=\"keyword\">local</span> finder = PF(grid, <span class=\"string\">'ASTAR'</span>,walkable)\nfinder:annotateGrid()\n\n<span class=\"keyword\">for</span> y = <span class=\"number\">1</span>, #map <span class=\"keyword\">do</span>\n\t<span class=\"keyword\">local</span> s = <span class=\"string\">''</span>\n\t<span class=\"keyword\">for</span> x = <span class=\"number\">1</span>, #map[y] <span class=\"keyword\">do</span>\n\t  <span class=\"keyword\">local</span> node = grid:getNodeAt(x,y)\n\t\ts = (s .. <span class=\"string\">' '</span> .. node:getClearance(walkable))\n\t<span class=\"keyword\">end</span>\n\t<span class=\"global\">print</span>(s)\n<span class=\"keyword\">end</span>\n\n<span class=\"comment\">-- Expected output\n</span><span class=\"comment\">--  6 6 5 5 4 4 4 3 2 1\n</span><span class=\"comment\">--  6 5 5 4 4 3 3 3 2 1\n</span><span class=\"comment\">--  6 5 4 4 3 3 2 2 2 1\n</span><span class=\"comment\">--  6 5 4 3 3 2 2 1 1 1\n</span><span class=\"comment\">--  6 5 4 3 2 2 1 1 0 1\n</span><span class=\"comment\">--  5 5 4 3 2 1 1 0 1 1\n</span><span class=\"comment\">--  4 4 4 3 2 1 0 2 1 0\n</span><span class=\"comment\">--  3 3 3 3 3 3 3 2 1 0\n</span><span class=\"comment\">--  2 2 2 2 2 2 2 2 2 1\n</span><span class=\"comment\">--  1 1 1 1 1 1 1 1 1 1\n</span></pre>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/examples/simpleexample.lua.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n\n\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><strong>simpleexample.lua</strong></li>\n</ul>\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Example <code>simpleexample.lua</code></h1>\n\n    <pre>\n<span class=\"comment\">--- Very minimal usage example for Jumper\n</span>\n<span class=\"comment\">-- Set up a collision map\n</span><span class=\"keyword\">local</span> map = {\n\t{<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">1</span>,<span class=\"number\">0</span>},\n\t{<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>,<span class=\"number\">0</span>},\n}\n<span class=\"comment\">-- Value for walkable tiles\n</span><span class=\"keyword\">local</span> walkable = <span class=\"number\">0</span>\n\n<span class=\"comment\">-- Library setup\n</span><span class=\"comment\">-- Calls the grid class\n</span><span class=\"keyword\">local</span> Grid = <span class=\"global\">require</span> (<span class=\"string\">\"jumper.grid\"</span>)\n<span class=\"comment\">-- Calls the pathfinder class\n</span><span class=\"keyword\">local</span> Pathfinder = <span class=\"global\">require</span> (<span class=\"string\">\"jumper.pathfinder\"</span>)\n\n<span class=\"comment\">-- Creates a grid object\n</span><span class=\"keyword\">local</span> grid = Grid(map)\n\n<span class=\"comment\">-- Creates a pathfinder object using Jump Point Search algorithm\n</span><span class=\"keyword\">local</span> myFinder = Pathfinder(grid, <span class=\"string\">'JPS'</span>, walkable)\n\n<span class=\"comment\">-- Define start and goal locations coordinates\n</span><span class=\"keyword\">local</span> startx, starty = <span class=\"number\">1</span>,<span class=\"number\">1</span>\n<span class=\"keyword\">local</span> endx, endy = <span class=\"number\">5</span>,<span class=\"number\">1</span>\n\n<span class=\"comment\">-- Calculates the path, and its length\n</span><span class=\"keyword\">local</span> path = myFinder:getPath(startx, starty, endx, endy)\n\n<span class=\"comment\">-- Pretty-printing the results\n</span><span class=\"keyword\">if</span> path <span class=\"keyword\">then</span>\n  <span class=\"global\">print</span>((<span class=\"string\">'Path found! Length: %.2f'</span>):format(path:getLength()))\n\t<span class=\"keyword\">for</span> node, count <span class=\"keyword\">in</span> path:nodes() <span class=\"keyword\">do</span>\n\t  <span class=\"global\">print</span>((<span class=\"string\">'Step: %d - x: %d - y: %d'</span>):format(count, node:getX(), node:getY()))\n\t<span class=\"keyword\">end</span>\n<span class=\"keyword\">end</span></pre>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/index.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n\n\n\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"modules/core.node.html\">core.node</a></li>\n  <li><a href=\"modules/core.path.html\">core.path</a></li>\n  <li><a href=\"modules/grid.html\">grid</a></li>\n  <li><a href=\"modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n\n\n  <h2>\n\n<h2>Fast and lightweight pathfinding library for grid based games</h2>\n\n</h2>\n\n<h2>Modules</h2>\n<table class=\"module_list\">\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"modules/core.bheap.html\">core.bheap</a></td>\n\t\t<td class=\"summary\">A light implementation of Binary heaps data structure.</td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"modules/core.heuristics.html\">core.heuristics</a></td>\n\t\t<td class=\"summary\">Heuristic functions for search algorithms.</td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"modules/core.node.html\">core.node</a></td>\n\t\t<td class=\"summary\">The Node class.</td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"modules/core.path.html\">core.path</a></td>\n\t\t<td class=\"summary\">The Path class.</td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"modules/grid.html\">grid</a></td>\n\t\t<td class=\"summary\">The Grid class.</td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"modules/pathfinder.html\">pathfinder</a></td>\n\t\t<td class=\"summary\">The Pathfinder class</td>\n\t</tr>\n</table>\n<h2>Examples</h2>\n<table class=\"module_list\">\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></td>\n\t\t<td class=\"summary\"></td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"examples/customheuristics.lua.html\">customheuristics.lua</a></td>\n\t\t<td class=\"summary\"></td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"examples/makeclearance.lua.html\">makeclearance.lua</a></td>\n\t\t<td class=\"summary\"></td>\n\t</tr>\n\t<tr>\n\t\t<td class=\"name\" nowrap><a href=\"examples/simpleexample.lua.html\">simpleexample.lua</a></td>\n\t\t<td class=\"summary\"></td>\n\t</tr>\n</table>\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/modules/core.bheap.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n<h2>Contents</h2>\n<ul>\n<li><a href=\"#Class_heap_\">Class heap </a></li>\n</ul>\n\n\n<h2>Modules</h2>\n<ul>\n  <li><strong>core.bheap</strong></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Module <code>core.bheap</code></h1>\n\n<p>A light implementation of Binary heaps data structure.</p>\n<p> While running a search, some search algorithms (Astar, Dijkstra, Jump Point Search) have to maintains\n a list of nodes called <strong>open list</strong>. Retrieve from this list the lowest cost node can be quite slow,\n as it normally requires to skim through the full set of nodes stored in this list. This becomes a real\n problem especially when dozens of nodes are being processed (on large maps). </p>\n\n<p> The current module implements a <a href=\"http://www.policyalmanac.org/games/binaryHeaps.htm\">binary heap</a>\n data structure, from which the search algorithm will instantiate an open list, and cache the nodes being\n examined during a search. As such, retrieving the lower-cost node is faster and globally makes the search end\n up quickly.</p>\n\n<p> This module is internally used by the library on purpose.\n It should normally not be used explicitely, yet it remains fully accessible.</p>\n\n<h2><a href=\"#Class_heap_\">Class heap </a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#heap:empty\">heap:empty&nbsp;()</a></td>\n\t<td class=\"summary\">Checks if a <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  is empty</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#heap:clear\">heap:clear&nbsp;()</a></td>\n\t<td class=\"summary\">Clears the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  (removes all items queued in the heap)</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#heap:push\">heap:push&nbsp;(item)</a></td>\n\t<td class=\"summary\">Adds a new item in the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#heap:pop\">heap:pop&nbsp;()</a></td>\n\t<td class=\"summary\">Pops from the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#heap:heapify\">heap:heapify&nbsp;( [item])</a></td>\n\t<td class=\"summary\">Restores the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  property.</td>\n\t</tr>\n</table>\n\n<br/>\n<br/>\n\n\n    <h2><a name=\"Class_heap_\"></a>Class heap </h2>\n    The <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  class.<br/>\n This class is callable.\n <em>Therefore,</em> <code>heap(...)</code> <em>is used to instantiate new heaps</em>.\n    <dl class=\"function\">\n    <dt>\n    <a name = \"heap:empty\"></a>\n    <strong>heap:empty&nbsp;()</strong>\n    </dt>\n    <dd>\n    Checks if a <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  is empty\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n if myHeap:empty() then\n   print('Heap is empty!')\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">bool</a></span>\n        <strong>true</strong> of no item is queued in the heap, <strong>false</strong> otherwise\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"heap:clear\"></a>\n    <strong>heap:clear&nbsp;()</strong>\n    </dt>\n    <dd>\n    Clears the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  (removes all items queued in the heap)\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myHeap:clear()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.bheap.html#Class_heap\">heap</a></span>\n        self (the calling <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"heap:push\"></a>\n    <strong>heap:push&nbsp;(item)</strong>\n    </dt>\n    <dd>\n    Adds a new item in the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">item</span>\n        <span class=\"types\"><span class=\"type\">value</span></span>\n       a new value to be queued in the heap</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n myHeap:push(1)\n -- or, with chaining\n myHeap:push(1):push(2):push(4)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.bheap.html#Class_heap\">heap</a></span>\n        self (the calling <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"heap:pop\"></a>\n    <strong>heap:pop&nbsp;()</strong>\n    </dt>\n    <dd>\n    Pops from the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a> .\n Removes and returns the lowest cost item (with respect to the comparison function being used) from the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a> .\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n while not myHeap:empty() do\n   local lowestValue = myHeap:pop()\n   ...\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">value</span></span>\n        a value previously pushed into the heap\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"heap:heapify\"></a>\n    <strong>heap:heapify&nbsp;( [item])</strong>\n    </dt>\n    <dd>\n    Restores the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  property.\n Reorders the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  with respect to the comparison function being used.\n When given argument <strong>item</strong> (a value existing in the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a> ), will sort from that very item in the <a href=\"../modules/core.bheap.html#Class_heap\">heap</a> .\n Otherwise, the whole <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  will be cheacked.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">item</span>\n        <span class=\"types\"><span class=\"type\">value</span></span>\n       the modified value</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myHeap:heapify()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.bheap.html#Class_heap\">heap</a></span>\n        self (the calling <a href=\"../modules/core.bheap.html#Class_heap\">heap</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n</dl>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/modules/core.heuristics.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n<h2>Contents</h2>\n<ul>\n<li><a href=\"#Functions\">Functions</a></li>\n</ul>\n\n\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><strong>core.heuristics</strong></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Module <code>core.heuristics</code></h1>\n\n<p>Heuristic functions for search algorithms.</p>\n<p> A <a href=\"http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html\">distance heuristic</a>\n provides an <em>estimate of the optimal distance cost</em> from a given location to a target.\n As such, it guides the pathfinder to the goal, helping it to decide which route is the best.</p>\n\n<p> This script holds the definition of some built-in heuristics available through jumper.</p>\n\n<p> Distance functions are internally used by the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  to evaluate the optimal path\n from the start location to the goal. These functions share the same prototype:</p>\n<pre><code> local function myHeuristic(nodeA, nodeB)\n   -- function body\n end\n</code></pre>\n<p> Jumper features some built-in distance heuristics, namely <code>MANHATTAN</code>, <code>EUCLIDIAN</code>, <code>DIAGONAL</code>, <code>CARDINTCARD</code>.\n You can also supply your own heuristic function, following the same template as above.</p>\n\n<h2><a href=\"#Functions\">Functions</a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Heuristics.MANHATTAN\">Heuristics.MANHATTAN&nbsp;(nodeA, nodeB)</a></td>\n\t<td class=\"summary\">Manhattan distance.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Heuristics.EUCLIDIAN\">Heuristics.EUCLIDIAN&nbsp;(nodeA, nodeB)</a></td>\n\t<td class=\"summary\">Euclidian distance.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Heuristics.DIAGONAL\">Heuristics.DIAGONAL&nbsp;(nodeA, nodeB)</a></td>\n\t<td class=\"summary\">Diagonal distance.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Heuristics.CARDINTCARD\">Heuristics.CARDINTCARD&nbsp;(nodeA, nodeB)</a></td>\n\t<td class=\"summary\">Cardinal/Intercardinal distance.</td>\n\t</tr>\n</table>\n\n<br/>\n<br/>\n\n\n    <h2><a name=\"Functions\"></a>Functions</h2>\n\n    <dl class=\"function\">\n    <dt>\n    <a name = \"Heuristics.MANHATTAN\"></a>\n    <strong>Heuristics.MANHATTAN&nbsp;(nodeA, nodeB)</strong>\n    </dt>\n    <dd>\n    Manhattan distance.\n <br/>This heuristic is the default one being used by the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  object.\n <br/>Evaluates as <code>distance = |dx|+|dy|</code>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">nodeA</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       a node</li>\n      <li><span class=\"parameter\">nodeB</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       another node</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- First method\n pathfinder:setHeuristic('MANHATTAN')\n -- Second method\n local Distance = require ('jumper.core.heuristics')\n pathfinder:setHeuristic(Distance.MANHATTAN)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the distance from <strong>nodeA</strong> to <strong>nodeB</strong>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Heuristics.EUCLIDIAN\"></a>\n    <strong>Heuristics.EUCLIDIAN&nbsp;(nodeA, nodeB)</strong>\n    </dt>\n    <dd>\n    Euclidian distance.\n <br/>Evaluates as <code>distance = squareRoot(dx<em>dx+dy</em>dy)</code>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">nodeA</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       a node</li>\n      <li><span class=\"parameter\">nodeB</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       another node</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- First method\n pathfinder:setHeuristic('EUCLIDIAN')\n -- Second method\n local Distance = require ('jumper.core.heuristics')\n pathfinder:setHeuristic(Distance.EUCLIDIAN) </pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the distance from <strong>nodeA</strong> to <strong>nodeB</strong>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Heuristics.DIAGONAL\"></a>\n    <strong>Heuristics.DIAGONAL&nbsp;(nodeA, nodeB)</strong>\n    </dt>\n    <dd>\n    Diagonal distance.\n <br/>Evaluates as <code>distance = max(|dx|, abs|dy|)</code>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">nodeA</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       a node</li>\n      <li><span class=\"parameter\">nodeB</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       another node</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- First method\n pathfinder:setHeuristic('DIAGONAL')\n -- Second method\n local Distance = require ('jumper.core.heuristics')\n pathfinder:setHeuristic(Distance.DIAGONAL)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the distance from <strong>nodeA</strong> to <strong>nodeB</strong>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Heuristics.CARDINTCARD\"></a>\n    <strong>Heuristics.CARDINTCARD&nbsp;(nodeA, nodeB)</strong>\n    </dt>\n    <dd>\n    Cardinal/Intercardinal distance.\n <br/>Evaluates as <code>distance = min(dx, dy)*squareRoot(2) + max(dx, dy) - min(dx, dy)</code>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">nodeA</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       a node</li>\n      <li><span class=\"parameter\">nodeB</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       another node</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- First method\n pathfinder:setHeuristic('CARDINTCARD')\n -- Second method\n local Distance = require ('jumper.core.heuristics')\n pathfinder:setHeuristic(Distance.CARDINTCARD)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the distance from <strong>nodeA</strong> to <strong>nodeB</strong>\n    </ol>\n\n\n</dd>\n</dl>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/modules/core.node.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n<h2>Contents</h2>\n<ul>\n<li><a href=\"#Class_Node_\">Class Node </a></li>\n</ul>\n\n\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><strong>core.node</strong></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Module <code>core.node</code></h1>\n\n<p>The Node class.</p>\n<p> The <a href=\"../modules/core.node.html\">node</a>  represents a cell (or a tile) on a collision map. Basically, for each single cell (tile)\n in the collision map passed-in upon initialization, a <a href=\"../modules/core.node.html\">node</a>  object will be generated\n and then cached within the <a href=\"../modules/grid.html#\">grid</a> .</p>\n\n<p> In the following implementation, nodes can be compared using the <code>&lt;</code> operator. The comparison is\n made with regards of their <code>f</code> cost. From a given node being examined, the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  will expand the search\n to the next neighbouring node having the lowest <code>f</code> cost. See <a href=\"../modules/core.bheap.html#\">core.bheap</a>  for more details.\n </p>\n\n<h2><a href=\"#Class_Node_\">Class Node </a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Node:new\">Node:new&nbsp;(x, y)</a></td>\n\t<td class=\"summary\">Inits a new <a href=\"../modules/core.node.html\">node</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Node:getX\">Node:getX&nbsp;()</a></td>\n\t<td class=\"summary\">Returns x-coordinate of a <a href=\"../modules/core.node.html\">node</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Node:getY\">Node:getY&nbsp;()</a></td>\n\t<td class=\"summary\">Returns y-coordinate of a <a href=\"../modules/core.node.html\">node</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Node:getPos\">Node:getPos&nbsp;()</a></td>\n\t<td class=\"summary\">Returns x and y coordinates of a <a href=\"../modules/core.node.html\">node</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Node:getClearance\">Node:getClearance&nbsp;(walkable)</a></td>\n\t<td class=\"summary\">Returns the amount of true <a href=\"http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric\">clearance</a>\n for a given <a href=\"../modules/core.node.html\">node</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Node:removeClearance\">Node:removeClearance&nbsp;(walkable)</a></td>\n\t<td class=\"summary\">Removes the clearance value for a given walkable.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Node:reset\">Node:reset&nbsp;()</a></td>\n\t<td class=\"summary\">Clears temporary cached attributes of a <a href=\"../modules/core.node.html\">node</a> .</td>\n\t</tr>\n</table>\n\n<br/>\n<br/>\n\n\n    <h2><a name=\"Class_Node_\"></a>Class Node </h2>\n    The <a href=\"../modules/core.node.html#Class_Node\">Node</a>  class.<br/>\n This class is callable.\n Therefore,_ <code>Node(...)</code> <em>acts as a shortcut to</em> <code>Node:new(...)</code>.\n    <dl class=\"function\">\n    <dt>\n    <a name = \"Node:new\"></a>\n    <strong>Node:new&nbsp;(x, y)</strong>\n    </dt>\n    <dd>\n    Inits a new <a href=\"../modules/core.node.html\">node</a>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">x</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the x-coordinate of the node on the collision map</li>\n      <li><span class=\"parameter\">y</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the y-coordinate of the node on the collision map</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local node = Node(3,4)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n        a new <a href=\"../modules/core.node.html\">node</a>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Node:getX\"></a>\n    <strong>Node:getX&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns x-coordinate of a <a href=\"../modules/core.node.html\">node</a>\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local x = node:getX()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the x-coordinate of the <a href=\"../modules/core.node.html\">node</a>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Node:getY\"></a>\n    <strong>Node:getY&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns y-coordinate of a <a href=\"../modules/core.node.html\">node</a>\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local y = node:getY()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the y-coordinate of the <a href=\"../modules/core.node.html\">node</a>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Node:getPos\"></a>\n    <strong>Node:getPos&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns x and y coordinates of a <a href=\"../modules/core.node.html\">node</a>\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local x, y = node:getPos()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n        <li>\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the x-coordinate of the <a href=\"../modules/core.node.html\">node</a> </li>\n        <li>\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the y-coordinate of the <a href=\"../modules/core.node.html\">node</a> </li>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Node:getClearance\"></a>\n    <strong>Node:getClearance&nbsp;(walkable)</strong>\n    </dt>\n    <dd>\n    Returns the amount of true <a href=\"http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric\">clearance</a>\n for a given <a href=\"../modules/core.node.html\">node</a>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">walkable</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>, <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       the value for walkable locations in the collision map array.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n  -- Assuming walkable was 0\n local clearance = node:getClearance(0)\t\t</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the clearance of the <a href=\"../modules/core.node.html\">node</a>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Node:removeClearance\"></a>\n    <strong>Node:removeClearance&nbsp;(walkable)</strong>\n    </dt>\n    <dd>\n    Removes the clearance value for a given walkable.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">walkable</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>, <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       the value for walkable locations in the collision map array.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n  -- Assuming walkable is defined\n node:removeClearance(walkable)\t</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n        self (the calling <a href=\"../modules/core.node.html\">node</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Node:reset\"></a>\n    <strong>Node:reset&nbsp;()</strong>\n    </dt>\n    <dd>\n    Clears temporary cached attributes of a <a href=\"../modules/core.node.html\">node</a> .\n Deletes the attributes cached within a given node after a pathfinding call.\n This function is internally used by the search algorithms, so you should not use it explicitely.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local thisNode = Node(1,2)\n thisNode:reset()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n        self (the calling <a href=\"../modules/core.node.html\">node</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n</dl>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/modules/core.path.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n<h2>Contents</h2>\n<ul>\n<li><a href=\"#Class_Path_\">Class Path </a></li>\n</ul>\n\n\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><strong>core.path</strong></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Module <code>core.path</code></h1>\n\n<p>The Path class.</p>\n<p> The <a href=\"../modules/core.path.html\">path</a>  class is a structure which represents a path (ordered set of nodes) from a start location to a goal.\n An instance from this class would be a result of a request addressed to <code>Pathfinder:getPath</code>.</p>\n\n<p> This module is internally used by the library on purpose.\n It should normally not be used explicitely, yet it remains fully accessible.</p>\n\n<h2><a href=\"#Class_Path_\">Class Path </a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:new\">Path:new&nbsp;()</a></td>\n\t<td class=\"summary\">Inits a new <a href=\"../modules/core.path.html\">path</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:iter\">Path:iter&nbsp;()</a></td>\n\t<td class=\"summary\">Iterates on each single <a href=\"../modules/core.node.html\">node</a>  along a <a href=\"../modules/core.path.html\">path</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:nodes\">Path:nodes&nbsp;()</a></td>\n\t<td class=\"summary\">Iterates on each single <a href=\"../modules/core.node.html\">node</a>  along a <a href=\"../modules/core.path.html\">path</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:getLength\">Path:getLength&nbsp;()</a></td>\n\t<td class=\"summary\">Evaluates the <a href=\"../modules/core.path.html\">path</a>  length</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:addNode\">Path:addNode&nbsp;(node [, index])</a></td>\n\t<td class=\"summary\">Counts the number of steps.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:fill\">Path:fill&nbsp;()</a></td>\n\t<td class=\"summary\"><a href=\"../modules/core.path.html#Class_Path\">Path</a>  filling modifier.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:filter\">Path:filter&nbsp;()</a></td>\n\t<td class=\"summary\"><a href=\"../modules/core.path.html#Class_Path\">Path</a>  compression modifier.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:clone\">Path:clone&nbsp;()</a></td>\n\t<td class=\"summary\">Clones a <a href=\"../modules/core.path.html\">path</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:isEqualTo\">Path:isEqualTo&nbsp;(p2)</a></td>\n\t<td class=\"summary\">Checks if a <a href=\"../modules/core.path.html\">path</a>  is equal to another.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:reverse\">Path:reverse&nbsp;()</a></td>\n\t<td class=\"summary\">Reverses a <a href=\"../modules/core.path.html\">path</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Path:append\">Path:append&nbsp;(p)</a></td>\n\t<td class=\"summary\">Appends a given <a href=\"../modules/core.path.html\">path</a>  to self.</td>\n\t</tr>\n</table>\n\n<br/>\n<br/>\n\n\n    <h2><a name=\"Class_Path_\"></a>Class Path </h2>\n    The <a href=\"../modules/core.path.html#Class_Path\">Path</a>  class.<br/>\n This class is callable.\n Therefore, <em><code>Path(...)</code></em> acts as a shortcut to <em><code>Path:new(...)</code></em>.\n    <dl class=\"function\">\n    <dt>\n    <a name = \"Path:new\"></a>\n    <strong>Path:new&nbsp;()</strong>\n    </dt>\n    <dd>\n    Inits a new <a href=\"../modules/core.path.html\">path</a> .\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local p = Path()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n        a <a href=\"../modules/core.path.html\">path</a>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Path:iter\"></a>\n    <strong>Path:iter&nbsp;()</strong>\n    </dt>\n    <dd>\n    Iterates on each single <a href=\"../modules/core.node.html\">node</a>  along a <a href=\"../modules/core.path.html\">path</a> .  At each step of iteration,\n returns the <a href=\"../modules/core.node.html\">node</a>  plus a count value. Aliased as <a href=\"../modules/core.path.html#Path:nodes\">Path:nodes</a>\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n for node, count in p:iter() do\n   ...\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n        a <a href=\"../modules/core.node.html\">node</a> </li>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the count for the number of nodes</li>\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/core.path.html#Path:nodes\">Path:nodes</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Path:nodes\"></a>\n    <strong>Path:nodes&nbsp;()</strong>\n    </dt>\n    <dd>\n    Iterates on each single <a href=\"../modules/core.node.html\">node</a>  along a <a href=\"../modules/core.path.html\">path</a> .  At each step of iteration,\n returns a <a href=\"../modules/core.node.html\">node</a>  plus a count value. Alias for <a href=\"../modules/core.path.html#Path:iter\">Path:iter</a>\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n for node, count in p:nodes() do\n   ...\n end\t</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n        a <a href=\"../modules/core.node.html\">node</a> </li>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the count for the number of nodes</li>\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/core.path.html#Path:iter\">Path:iter</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Path:getLength\"></a>\n    <strong>Path:getLength&nbsp;()</strong>\n    </dt>\n    <dd>\n    Evaluates the <a href=\"../modules/core.path.html\">path</a>  length\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local len = p:getLength()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">number</span></span>\n        the <a href=\"../modules/core.path.html\">path</a>  length\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Path:addNode\"></a>\n    <strong>Path:addNode&nbsp;(node [, index])</strong>\n    </dt>\n    <dd>\n    Counts the number of steps.\n Returns the number of waypoints (nodes) in the current path.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">node</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.node.html\">node</a></span>\n       a node to be added to the path</li>\n      <li><span class=\"parameter\">index</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the index at which the node will be inserted. If omitted, the node will be appended after the last node in the path.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local nSteps = p:countSteps()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n        self (the calling <a href=\"../modules/core.path.html\">path</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Path:fill\"></a>\n    <strong>Path:fill&nbsp;()</strong>\n    </dt>\n    <dd>\n    <a href=\"../modules/core.path.html#Class_Path\">Path</a>  filling modifier.  Interpolates between non contiguous nodes along a <a href=\"../modules/core.path.html\">path</a>\n to build a fully continuous <a href=\"../modules/core.path.html\">path</a> . This maybe useful when using search algorithms such as Jump Point Search.\n Does the opposite of <a href=\"../modules/core.path.html#Path:filter\">Path:filter</a>\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">p:fill()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n        self (the calling <a href=\"../modules/core.path.html\">path</a>  itself, can be chained)\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/core.path.html#Path:filter\">Path:filter</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Path:filter\"></a>\n    <strong>Path:filter&nbsp;()</strong>\n    </dt>\n    <dd>\n    <a href=\"../modules/core.path.html#Class_Path\">Path</a>  compression modifier.  Given a <a href=\"../modules/core.path.html\">path</a> , eliminates useless nodes to return a lighter <a href=\"../modules/core.path.html\">path</a> <br/>\n consisting of straight moves. Does the opposite of <a href=\"../modules/core.path.html#Path:fill\">Path:fill</a>\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">p:filter()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n        self (the calling <a href=\"../modules/core.path.html\">path</a>  itself, can be chained)\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/core.path.html#Path:fill\">Path:fill</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Path:clone\"></a>\n    <strong>Path:clone&nbsp;()</strong>\n    </dt>\n    <dd>\n    Clones a <a href=\"../modules/core.path.html\">path</a> .\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local p = path:clone()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n        a <a href=\"../modules/core.path.html\">path</a>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Path:isEqualTo\"></a>\n    <strong>Path:isEqualTo&nbsp;(p2)</strong>\n    </dt>\n    <dd>\n    Checks if a <a href=\"../modules/core.path.html\">path</a>  is equal to another.  It also supports <em>filtered paths</em> (see <a href=\"../modules/core.path.html#Path:filter\">Path:filter</a>).\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">p2</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n       a path</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">print(myPath:isEqualTo(anotherPath))</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">boolean</a></span>\n        a boolean\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Path:reverse\"></a>\n    <strong>Path:reverse&nbsp;()</strong>\n    </dt>\n    <dd>\n    Reverses a <a href=\"../modules/core.path.html\">path</a> .\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myPath:reverse()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n        self (the calling <a href=\"../modules/core.path.html\">path</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Path:append\"></a>\n    <strong>Path:append&nbsp;(p)</strong>\n    </dt>\n    <dd>\n    Appends a given <a href=\"../modules/core.path.html\">path</a>  to self.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">p</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n       a path</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myPath:append(anotherPath)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/core.path.html\">path</a></span>\n        self (the calling <a href=\"../modules/core.path.html\">path</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n</dl>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/modules/grid.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n<h2>Contents</h2>\n<ul>\n<li><a href=\"#Class_Grid_\">Class Grid </a></li>\n</ul>\n\n\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><strong>grid</strong></li>\n  <li><a href=\"../modules/pathfinder.html\">pathfinder</a></li>\n</ul>\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Module <code>grid</code></h1>\n\n<p>The Grid class.</p>\n<p> Implementation of the <a href=\"../modules/grid.html#\">grid</a>  class.\n The <a href=\"../modules/grid.html#\">grid</a>  is a implicit graph which represents the 2D\n world map layout on which the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  object will run.\n During a search, the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  object needs to save some critical values. These values are cached within each <code>node</code>\n object, and the whole set of nodes are tight inside the <a href=\"../modules/grid.html#\">grid</a>  object itself.</p>\n\n<h2><a href=\"#Class_Grid_\">Class Grid </a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:new\">Grid:new&nbsp;(map [, cacheNodeAtRuntime])</a></td>\n\t<td class=\"summary\">Inits a new <a href=\"../modules/grid.html#\">grid</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:isWalkableAt\">Grid:isWalkableAt&nbsp;(x, y [, walkable [, clearance]])</a></td>\n\t<td class=\"summary\">Checks if <code>node</code> at [x,y] is <strong>walkable</strong>.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:getWidth\">Grid:getWidth&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the <a href=\"../modules/grid.html#\">grid</a>  width.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:getHeight\">Grid:getHeight&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the <a href=\"../modules/grid.html#\">grid</a>  height.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:getMap\">Grid:getMap&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the collision map.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:getNodes\">Grid:getNodes&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the set of nodes.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:getBounds\">Grid:getBounds&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the <a href=\"../modules/grid.html#\">grid</a>  bounds.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:getNeighbours\">Grid:getNeighbours&nbsp;(node [, walkable [, allowDiagonal [, tunnel [, clearance]]]])</a></td>\n\t<td class=\"summary\">Returns neighbours.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:iter\">Grid:iter&nbsp;( [lx [, ly [, ex [, ey]]]])</a></td>\n\t<td class=\"summary\">Grid iterator.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:around\">Grid:around&nbsp;(node [, radius])</a></td>\n\t<td class=\"summary\">Grid iterator.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:each\">Grid:each&nbsp;(f [, ...])</a></td>\n\t<td class=\"summary\">Each transformation.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:eachRange\">Grid:eachRange&nbsp;(lx, ly, ex, ey, f [, ...])</a></td>\n\t<td class=\"summary\">Each (in range) transformation.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:imap\">Grid:imap&nbsp;(f [, ...])</a></td>\n\t<td class=\"summary\">Map transformation.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:imapRange\">Grid:imapRange&nbsp;(lx, ly, ex, ey, f [, ...])</a></td>\n\t<td class=\"summary\">Map in range transformation.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Grid:getNodeAt\">Grid:getNodeAt&nbsp;(x, y)</a></td>\n\t<td class=\"summary\">Returns the <code>node</code> at location [x,y].</td>\n\t</tr>\n</table>\n\n<br/>\n<br/>\n\n\n    <h2><a name=\"Class_Grid_\"></a>Class Grid </h2>\n    The <a href=\"../modules/grid.html#Class_Grid\">Grid</a>  class.<br/>\n This class is callable.\n Therefore,_ <code>Grid(...)</code> <em>acts as a shortcut to</em> <code>Grid:new(...)</code>.\n    <dl class=\"function\">\n    <dt>\n    <a name = \"Grid:new\"></a>\n    <strong>Grid:new&nbsp;(map [, cacheNodeAtRuntime])</strong>\n    </dt>\n    <dd>\n    Inits a new <a href=\"../modules/grid.html#\">grid</a>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">map</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.5\">table</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a></span>\n       A collision map - (2D array) with consecutive indices (starting at 0 or 1)\n or a <a href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>  with line-break chars (<code>\\n</code> or <code>\\r</code>) as row delimiters.</li>\n      <li><span class=\"parameter\">cacheNodeAtRuntime</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">bool</a></span>\n       When <strong>true</strong>, returns an empty <a href=\"../modules/grid.html#\">grid</a>  instance, so that\n later on, indexing a non-cached <code>node</code> will cause it to be created and cache within the <a href=\"../modules/grid.html#\">grid</a>  on purpose (i.e, when needed).\n This is a <strong>memory-safe</strong> option, in case your dealing with some tight memory constraints.\n Defaults to <strong>false</strong> when omitted.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- A simple 3x3 grid\n local myGrid = Grid:new({{0,0,0},{0,0,0},{0,0,0}})\n\n -- A memory-safe 3x3 grid\n myGrid = Grid('000\\n000\\n000', true)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n        a new <a href=\"../modules/grid.html#\">grid</a>  instance\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:isWalkableAt\"></a>\n    <strong>Grid:isWalkableAt&nbsp;(x, y [, walkable [, clearance]])</strong>\n    </dt>\n    <dd>\n    Checks if <code>node</code> at [x,y] is <strong>walkable</strong>.\n Will check if <code>node</code> at location [x,y] both <em>exists</em> on the collision map and <em>is walkable</em>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">x</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the x-location of the node</li>\n      <li><span class=\"parameter\">y</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the y-location of the node</li>\n      <li><span class=\"parameter\">walkable</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>, <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       the value for walkable locations in the collision map array (see <a href=\"../modules/grid.html#Grid:new\">Grid:new</a>).\n Defaults to <strong>false</strong> when omitted.\n If this parameter is a function, it should be prototyped as <strong>f(value)</strong> and return a <a href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">boolean</a> :\n <strong>true</strong> when value matches a <strong>walkable</strong> <code>node</code>, <strong>false</strong> otherwise. If this parameter is not given\n while location [x,y] <strong>is valid</strong>, this actual function returns <strong>true</strong>.</li>\n      <li><span class=\"parameter\">clearance</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the amount of clearance needed. Defaults to 1 (normal clearance) when not given.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- Always true\n print(myGrid:isWalkableAt(2,3))\n\n -- True if node at [2,3] collision map value is 0\n print(myGrid:isWalkableAt(2,3,0))\n\n -- True if node at [2,3] collision map value is 0 and has a clearance higher or equal to 2\n print(myGrid:isWalkableAt(2,3,0,2))\n</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">bool</a></span>\n        <strong>true</strong> if <code>node</code> exists and is <strong>walkable</strong>, <strong>false</strong> otherwise\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:getWidth\"></a>\n    <strong>Grid:getWidth&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the <a href=\"../modules/grid.html#\">grid</a>  width.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">print(myGrid:getWidth())</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the <a href=\"../modules/grid.html#\">grid</a>  width\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:getHeight\"></a>\n    <strong>Grid:getHeight&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the <a href=\"../modules/grid.html#\">grid</a>  height.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">print(myGrid:getHeight())</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the <a href=\"../modules/grid.html#\">grid</a>  height\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:getMap\"></a>\n    <strong>Grid:getMap&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the collision map.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local map = myGrid:getMap()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">map</span></span>\n        the collision map (see <a href=\"../modules/grid.html#Grid:new\">Grid:new</a>)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:getNodes\"></a>\n    <strong>Grid:getNodes&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the set of nodes.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local nodes = myGrid:getNodes()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">{{node,...},...}</span></span>\n        an array of nodes\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:getBounds\"></a>\n    <strong>Grid:getBounds&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the <a href=\"../modules/grid.html#\">grid</a>  bounds.  Returned values corresponds to the upper-left\n and lower-right coordinates (in tile units) of the actual <a href=\"../modules/grid.html#\">grid</a>  instance.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local left_x, left_y, right_x, right_y = myGrid:getBounds()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the upper-left corner x-coordinate</li>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the upper-left corner y-coordinate</li>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the lower-right corner x-coordinate</li>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the lower-right corner y-coordinate</li>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:getNeighbours\"></a>\n    <strong>Grid:getNeighbours&nbsp;(node [, walkable [, allowDiagonal [, tunnel [, clearance]]]])</strong>\n    </dt>\n    <dd>\n    Returns neighbours.  The returned value is an array of <strong>walkable</strong> nodes neighbouring a given <code>node</code>.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">node</span>\n        <span class=\"types\"><span class=\"type\">node</span></span>\n       a given <code>node</code></li>\n      <li><span class=\"parameter\">walkable</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>, <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       the value for walkable locations in the collision map array (see <a href=\"../modules/grid.html#Grid:new\">Grid:new</a>).\n Defaults to <strong>false</strong> when omitted.</li>\n      <li><span class=\"parameter\">allowDiagonal</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">bool</a></span>\n       when <strong>true</strong>, allows adjacent nodes are included (8-neighbours).\n Defaults to <strong>false</strong> when omitted.</li>\n      <li><span class=\"parameter\">tunnel</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">bool</a></span>\n       When <strong>true</strong>, allows the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  to tunnel through walls when heading diagonally.</li>\n      <li><span class=\"parameter\">clearance</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       When given, will prune for the neighbours set all nodes having a clearance value lower than the passed-in value\n Defaults to <strong>false</strong> when omitted.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local aNode = myGrid:getNodeAt(5,6)\n local neighbours = myGrid:getNeighbours(aNode, 0, true)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">{node,...}</span></span>\n        an array of nodes neighbouring a given node\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:iter\"></a>\n    <strong>Grid:iter&nbsp;( [lx [, ly [, ex [, ey]]]])</strong>\n    </dt>\n    <dd>\n    Grid iterator.  Iterates on every single node\n in the <a href=\"../modules/grid.html#\">grid</a> . Passing <strong>lx, ly, ex, ey</strong> arguments will iterate\n only on nodes inside the bounding-rectangle delimited by those given coordinates.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">lx</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the leftmost x-coordinate of the rectangle. Default to the <a href=\"../modules/grid.html#\">grid</a>  leftmost x-coordinate (see <a href=\"../modules/grid.html#Grid:getBounds\">Grid:getBounds</a>).</li>\n      <li><span class=\"parameter\">ly</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the topmost y-coordinate of the rectangle. Default to the <a href=\"../modules/grid.html#\">grid</a>  topmost y-coordinate (see <a href=\"../modules/grid.html#Grid:getBounds\">Grid:getBounds</a>).</li>\n      <li><span class=\"parameter\">ex</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the rightmost x-coordinate of the rectangle. Default to the <a href=\"../modules/grid.html#\">grid</a>  rightmost x-coordinate (see <a href=\"../modules/grid.html#Grid:getBounds\">Grid:getBounds</a>).</li>\n      <li><span class=\"parameter\">ey</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the bottom-most y-coordinate of the rectangle. Default to the <a href=\"../modules/grid.html#\">grid</a>  bottom-most y-coordinate (see <a href=\"../modules/grid.html#Grid:getBounds\">Grid:getBounds</a>).</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n for node, count in myGrid:iter() do\n   print(node:getX(), node:getY(), count)\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n        <li>\n          <span class=\"types\"><span class=\"type\">node</span></span>\n        a <code>node</code> on the collision map, upon each iteration step</li>\n        <li>\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n        the iteration count</li>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:around\"></a>\n    <strong>Grid:around&nbsp;(node [, radius])</strong>\n    </dt>\n    <dd>\n    Grid iterator.  Iterates on each node along the outline (border) of a squared area\n centered on the given node.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">node</span>\n        <span class=\"types\"><span class=\"type\">node</span></span>\n       a given <code>node</code></li>\n      <li><span class=\"parameter\">radius</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the area radius (half-length). Defaults to <strong>1</strong> when not given.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n for node in myGrid:around(node, 2) do\n   ...\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">node</span></span>\n        a <code>node</code> at each iteration step\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:each\"></a>\n    <strong>Grid:each&nbsp;(f [, ...])</strong>\n    </dt>\n    <dd>\n    Each transformation.  Calls the given function on each <code>node</code> in the <a href=\"../modules/grid.html#\">grid</a> ,\n passing the <code>node</code> as the first argument to function <strong>f</strong>.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">f</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       a function prototyped as <strong>f(node,...)</strong></li>\n      <li><span class=\"parameter\">...</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.5\">vararg</a></span>\n       args to be passed to function <strong>f</strong></li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local function printNode(node)\n   print(node:getX(), node:getY())\n end\n myGrid:each(printNode)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n        self (the calling <a href=\"../modules/grid.html#\">grid</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:eachRange\"></a>\n    <strong>Grid:eachRange&nbsp;(lx, ly, ex, ey, f [, ...])</strong>\n    </dt>\n    <dd>\n    Each (in range) transformation.  Calls a function on each <code>node</code> in the range of a rectangle of cells,\n passing the <code>node</code> as the first argument to function <strong>f</strong>.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">lx</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the leftmost x-coordinate coordinate of the rectangle</li>\n      <li><span class=\"parameter\">ly</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the topmost y-coordinate of the rectangle</li>\n      <li><span class=\"parameter\">ex</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the rightmost x-coordinate of the rectangle</li>\n      <li><span class=\"parameter\">ey</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the bottom-most y-coordinate of the rectangle</li>\n      <li><span class=\"parameter\">f</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       a function prototyped as <strong>f(node,...)</strong></li>\n      <li><span class=\"parameter\">...</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.5\">vararg</a></span>\n       args to be passed to function <strong>f</strong></li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local function printNode(node)\n   print(node:getX(), node:getY())\n end\n myGrid:eachRange(1,1,8,8,printNode)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n        self (the calling <a href=\"../modules/grid.html#\">grid</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:imap\"></a>\n    <strong>Grid:imap&nbsp;(f [, ...])</strong>\n    </dt>\n    <dd>\n    Map transformation.\n Calls function <strong>f(node,...)</strong> on each <code>node</code> in a given range, passing the <code>node</code> as the first arg to function <strong>f</strong> and replaces\n it with the returned value. Therefore, the function should return a <code>node</code>.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">f</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       a function prototyped as <strong>f(node,...)</strong></li>\n      <li><span class=\"parameter\">...</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.5\">vararg</a></span>\n       args to be passed to function <strong>f</strong></li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local function nothing(node)\n   return node\n end\n myGrid:imap(nothing)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n        self (the calling <a href=\"../modules/grid.html#\">grid</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:imapRange\"></a>\n    <strong>Grid:imapRange&nbsp;(lx, ly, ex, ey, f [, ...])</strong>\n    </dt>\n    <dd>\n    Map in range transformation.\n Calls function <strong>f(node,...)</strong> on each <code>node</code> in a rectangle range, passing the <code>node</code> as the first argument to the function and replaces\n it with the returned value. Therefore, the function should return a <code>node</code>.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">lx</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the leftmost x-coordinate coordinate of the rectangle</li>\n      <li><span class=\"parameter\">ly</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the topmost y-coordinate of the rectangle</li>\n      <li><span class=\"parameter\">ex</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the rightmost x-coordinate of the rectangle</li>\n      <li><span class=\"parameter\">ey</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the bottom-most y-coordinate of the rectangle</li>\n      <li><span class=\"parameter\">f</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       a function prototyped as <strong>f(node,...)</strong></li>\n      <li><span class=\"parameter\">...</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.5\">vararg</a></span>\n       args to be passed to function <strong>f</strong></li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local function nothing(node)\n   return node\n end\n myGrid:imap(1,1,6,6,nothing)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n        self (the calling <a href=\"../modules/grid.html#\">grid</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Grid:getNodeAt\"></a>\n    <strong>Grid:getNodeAt&nbsp;(x, y)</strong>\n    </dt>\n    <dd>\n    Returns the <code>node</code> at location [x,y].\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">x</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the x-coordinate coordinate</li>\n      <li><span class=\"parameter\">y</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the y-coordinate coordinate</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local aNode = myGrid:getNodeAt(2,2)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">node</span></span>\n        a <code>node</code>\n    </ol>\n\n\n</dd>\n</dl>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "docs/modules/pathfinder.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n   \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<head>\n    <title>Jumper documentation</title>\n    <link rel=\"stylesheet\" href=\"../ldoc.css\" type=\"text/css\" />\n</head>\n<body>\n\n<div id=\"container\">\n\n<div id=\"product\">\n\t<div id=\"product_logo\"></div>\n\t<div id=\"product_name\"><big><b></b></big></div>\n\t<div id=\"product_description\"></div>\n</div> <!-- id=\"product\" -->\n\n\n<div id=\"main\">\n\n\n<!-- Menu -->\n\n<div id=\"navigation\">\n<br/>\n<h1>Jumper</h1>\n\n<ul>\n  <li><a href=\"../index.html\">Index</a></li>\n</ul>\n\n<h2>Contents</h2>\n<ul>\n<li><a href=\"#Finders\">Finders</a></li>\n<li><a href=\"#Modes\">Modes</a></li>\n<li><a href=\"#Class_Pathfinder_\">Class Pathfinder </a></li>\n</ul>\n\n\n<h2>Modules</h2>\n<ul>\n  <li><a href=\"../modules/core.bheap.html\">core.bheap</a></li>\n  <li><a href=\"../modules/core.heuristics.html\">core.heuristics</a></li>\n  <li><a href=\"../modules/core.node.html\">core.node</a></li>\n  <li><a href=\"../modules/core.path.html\">core.path</a></li>\n  <li><a href=\"../modules/grid.html\">grid</a></li>\n  <li><strong>pathfinder</strong></li>\n</ul>\n<h2>Examples</h2>\n<ul>\n  <li><a href=\"../examples/annotatedpathing.lua.html\">annotatedpathing.lua</a></li>\n  <li><a href=\"../examples/customheuristics.lua.html\">customheuristics.lua</a></li>\n  <li><a href=\"../examples/makeclearance.lua.html\">makeclearance.lua</a></li>\n  <li><a href=\"../examples/simpleexample.lua.html\">simpleexample.lua</a></li>\n</ul>\n\n</div>\n\n<div id=\"content\">\n\n<h1>Module <code>pathfinder</code></h1>\n\n<p>The Pathfinder class</p>\n<p>\n\n</p>\n\n<h2><a href=\"#Finders\">Finders</a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Finders\">Finders</a></td>\n\t<td class=\"summary\">Finders (search algorithms implemented).</td>\n\t</tr>\n</table>\n<h2><a href=\"#Modes\">Modes</a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Modes\">Modes</a></td>\n\t<td class=\"summary\">Search modes.</td>\n\t</tr>\n</table>\n<h2><a href=\"#Class_Pathfinder_\">Class Pathfinder </a></h2>\n<table class=\"function_list\">\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:new\">Pathfinder:new&nbsp;(grid [, finderName [, walkable]])</a></td>\n\t<td class=\"summary\">Inits a new <a href=\"../modules/pathfinder.html#\">pathfinder</a> </td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:annotateGrid\">Pathfinder:annotateGrid&nbsp;()</a></td>\n\t<td class=\"summary\">Evaluates <a href=\"http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric\">clearance</a>\n for the whole <a href=\"../modules/grid.html#\">grid</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:clearAnnotations\">Pathfinder:clearAnnotations&nbsp;()</a></td>\n\t<td class=\"summary\">Removes <a href=\"http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric\">clearance</a>values.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:setGrid\">Pathfinder:setGrid&nbsp;(grid)</a></td>\n\t<td class=\"summary\">Sets the <a href=\"../modules/grid.html#\">grid</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getGrid\">Pathfinder:getGrid&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the <a href=\"../modules/grid.html#\">grid</a> .</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:setWalkable\">Pathfinder:setWalkable&nbsp;(walkable)</a></td>\n\t<td class=\"summary\">Sets the <strong>walkable</strong> value or function.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getWalkable\">Pathfinder:getWalkable&nbsp;()</a></td>\n\t<td class=\"summary\">Gets the <strong>walkable</strong> value or function.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:setFinder\">Pathfinder:setFinder&nbsp;(finderName)</a></td>\n\t<td class=\"summary\">Defines the <code>finder</code>.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getFinder\">Pathfinder:getFinder&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the name of the <code>finder</code> being used.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getFinders\">Pathfinder:getFinders&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the list of all available finders names.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:setHeuristic\">Pathfinder:setHeuristic&nbsp;(heuristic)</a></td>\n\t<td class=\"summary\">Sets a heuristic.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getHeuristic\">Pathfinder:getHeuristic&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the <code>heuristic</code> used.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getHeuristics\">Pathfinder:getHeuristics&nbsp;()</a></td>\n\t<td class=\"summary\">Gets the list of all available <code>heuristics</code>.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:setMode\">Pathfinder:setMode&nbsp;(mode)</a></td>\n\t<td class=\"summary\">Defines the search <code>mode</code>.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getMode\">Pathfinder:getMode&nbsp;()</a></td>\n\t<td class=\"summary\">Returns the search mode.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getModes\">Pathfinder:getModes&nbsp;()</a></td>\n\t<td class=\"summary\">Gets the list of all available search modes.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:setTunnelling\">Pathfinder:setTunnelling&nbsp;(bool)</a></td>\n\t<td class=\"summary\">Enables tunnelling.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getTunnelling\">Pathfinder:getTunnelling&nbsp;()</a></td>\n\t<td class=\"summary\">Returns tunnelling feature state.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:getPath\">Pathfinder:getPath&nbsp;(startX, startY, endX, endY, clearance)</a></td>\n\t<td class=\"summary\">Calculates a <code>path</code>.</td>\n\t</tr>\n\t<tr>\n\t<td class=\"name\" nowrap><a href=\"#Pathfinder:reset\">Pathfinder:reset&nbsp;()</a></td>\n\t<td class=\"summary\">Resets the <a href=\"../modules/pathfinder.html#\">pathfinder</a> .</td>\n\t</tr>\n</table>\n\n<br/>\n<br/>\n\n\n    <h2><a name=\"Finders\"></a>Finders</h2>\n\n    <dl class=\"function\">\n    <dt>\n    <a name = \"Finders\"></a>\n    <strong>Finders</strong>\n    </dt>\n    <dd>\n    Finders (search algorithms implemented).  Refers to the search algorithms actually implemented in Jumper.</p>\n\n<p> <li><a href=\"http://en.wikipedia.org/wiki/A*_search_algorithm\">A*</a></li>\n <li><a href=\"http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm\">Dijkstra</a></li>\n <li><a href=\"http://aigamedev.com/open/tutorials/theta-star-any-angle-paths/\">Theta Astar</a></li>\n <li><a href=\"http://en.wikipedia.org/wiki/Breadth-first_search\">BFS</a></li>\n <li><a href=\"http://en.wikipedia.org/wiki/Depth-first_search\">DFS</a></li>\n <li><a href=\"http://harablog.wordpress.com/2011/09/07/jump-point-search/\">JPS</a></li>\n\n\n\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/pathfinder.html#Pathfinder:getFinders\">Pathfinder:getFinders</a>\n    </ul>\n</dd>\n</dl>\n    <h2><a name=\"Modes\"></a>Modes</h2>\n\n    <dl class=\"function\">\n    <dt>\n    <a name = \"Modes\"></a>\n    <strong>Modes</strong>\n    </dt>\n    <dd>\n    Search modes.  Refers to the search modes. In ORTHOGONAL mode, 4-directions are only possible when moving,\n including North, East, West, South. In DIAGONAL mode, 8-directions are possible when moving,\n including North, East, West, South and adjacent directions.</p>\n\n<p> <li>ORTHOGNAL</li>\n <li>DIAGONAL</li>\n\n\n\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/pathfinder.html#Pathfinder:getModes\">Pathfinder:getModes</a>\n    </ul>\n</dd>\n</dl>\n    <h2><a name=\"Class_Pathfinder_\"></a>Class Pathfinder </h2>\n    The <a href=\"../modules/pathfinder.html#Class_Pathfinder\">Pathfinder</a>  class.<br/>\n This class is callable.\n Therefore,_ <code>Pathfinder(...)</code> <em>acts as a shortcut to</em> <code>Pathfinder:new(...)</code>.\n    <dl class=\"function\">\n    <dt>\n    <a name = \"Pathfinder:new\"></a>\n    <strong>Pathfinder:new&nbsp;(grid [, finderName [, walkable]])</strong>\n    </dt>\n    <dd>\n    Inits a new <a href=\"../modules/pathfinder.html#\">pathfinder</a>\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">grid</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n       a <a href=\"../modules/grid.html#\">grid</a> </li>\n      <li><span class=\"parameter\">finderName</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a></span>\n       the name of the <code>Finder</code> (search algorithm) to be used for search.\n Defaults to <code>ASTAR</code> when not given (see <a href=\"../modules/pathfinder.html#Pathfinder:getFinders\">Pathfinder:getFinders</a>).</li>\n      <li><span class=\"parameter\">walkable</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>, <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       the value for <strong>walkable</strong> nodes.\n If this parameter is a function, it should be prototyped as <strong>f(value)</strong>, returning a boolean:\n <strong>true</strong> when value matches a <strong>walkable</strong> <code>node</code>, <strong>false</strong> otherwise.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- Example one\n local finder = Pathfinder:new(myGrid, 'ASTAR', 0)\n\n -- Example two\n local function walkable(value)\n   return value > 0\n end\n local finder = Pathfinder(myGrid, 'JPS', walkable)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        a new <a href=\"../modules/pathfinder.html#\">pathfinder</a>  instance\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:annotateGrid\"></a>\n    <strong>Pathfinder:annotateGrid&nbsp;()</strong>\n    </dt>\n    <dd>\n    Evaluates <a href=\"http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric\">clearance</a>\n for the whole <a href=\"../modules/grid.html#\">grid</a> .  It should be called only once, unless the collision map or the\n <strong>walkable</strong> attribute changes. The clearance values are calculated and cached within the grid nodes.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myFinder:annotateGrid()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:clearAnnotations\"></a>\n    <strong>Pathfinder:clearAnnotations&nbsp;()</strong>\n    </dt>\n    <dd>\n    Removes <a href=\"http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric\">clearance</a>values.\n Clears cached clearance values for the current <strong>walkable</strong>.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myFinder:clearAnnotations()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:setGrid\"></a>\n    <strong>Pathfinder:setGrid&nbsp;(grid)</strong>\n    </dt>\n    <dd>\n    Sets the <a href=\"../modules/grid.html#\">grid</a> .  Defines the given <a href=\"../modules/grid.html#\">grid</a>  as the one on which the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  will perform the search.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">grid</span>\n        <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n       a <a href=\"../modules/grid.html#\">grid</a> </li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myFinder:setGrid(myGrid)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getGrid\"></a>\n    <strong>Pathfinder:getGrid&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the <a href=\"../modules/grid.html#\">grid</a> .  This is a reference to the actual <a href=\"../modules/grid.html#\">grid</a>  used by the <a href=\"../modules/pathfinder.html#\">pathfinder</a> .\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local myGrid = myFinder:getGrid()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/grid.html#\">grid</a></span>\n        the <a href=\"../modules/grid.html#\">grid</a>\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:setWalkable\"></a>\n    <strong>Pathfinder:setWalkable&nbsp;(walkable)</strong>\n    </dt>\n    <dd>\n    Sets the <strong>walkable</strong> value or function.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">walkable</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>, <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n       the value for walkable nodes.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n -- Value '0' is walkable\n myFinder:setWalkable(0)\n\n -- Any value greater than 0 is walkable\n myFinder:setWalkable(function(n)\n   return n>0\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getWalkable\"></a>\n    <strong>Pathfinder:getWalkable&nbsp;()</strong>\n    </dt>\n    <dd>\n    Gets the <strong>walkable</strong> value or function.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local walkable = myFinder:getWalkable()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a>, <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n        the <code>walkable</code> value or function\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:setFinder\"></a>\n    <strong>Pathfinder:setFinder&nbsp;(finderName)</strong>\n    </dt>\n    <dd>\n    Defines the <code>finder</code>.  It refers to the search algorithm used by the <a href=\"../modules/pathfinder.html#\">pathfinder</a> .\n Default finder is <code>ASTAR</code>. Use <a href=\"../modules/pathfinder.html#Pathfinder:getFinders\">Pathfinder:getFinders</a> to get the list of available finders.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">finderName</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a></span>\n       the name of the <code>finder</code> to be used for further searches.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n --To use Breadth-First-Search\n myFinder:setFinder('BFS')</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/pathfinder.html#Pathfinder:getFinders\">Pathfinder:getFinders</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getFinder\"></a>\n    <strong>Pathfinder:getFinder&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the name of the <code>finder</code> being used.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local finderName = myFinder:getFinder()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a></span>\n        the name of the <code>finder</code> to be used for further searches.\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getFinders\"></a>\n    <strong>Pathfinder:getFinders&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the list of all available finders names.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local finders = myFinder:getFinders()\n for i, finderName in ipairs(finders) do\n   print(i, finderName)\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">{string,...}</span></span>\n        array of built-in finders names.\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:setHeuristic\"></a>\n    <strong>Pathfinder:setHeuristic&nbsp;(heuristic)</strong>\n    </dt>\n    <dd>\n    Sets a heuristic.  This is a function internally used by the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  to find the optimal path during a search.\n Use <a href=\"../modules/pathfinder.html#Pathfinder:getHeuristics\">Pathfinder:getHeuristics</a> to get the list of all available <code>heuristics</code>. One can also define\n his own <code>heuristic</code> function.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">heuristic</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a> or <a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a></span>\n       <code>heuristic</code> function, prototyped as <strong>f(dx,dy)</strong> or as a <a href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a> .</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myFinder:setHeuristic('MANHATTAN')</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <li><a href=\"../modules/pathfinder.html#Pathfinder:getHeuristics\">Pathfinder:getHeuristics</a></li>\n         <li><a href=\"../modules/core.heuristics.html#\">core.heuristics</a></li>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getHeuristic\"></a>\n    <strong>Pathfinder:getHeuristic&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the <code>heuristic</code> used.  Returns the function itself.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local h = myFinder:getHeuristic()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">func</a></span>\n        the <code>heuristic</code> function being used by the <a href=\"../modules/pathfinder.html#\">pathfinder</a>\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/core.heuristics.html#\">core.heuristics</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getHeuristics\"></a>\n    <strong>Pathfinder:getHeuristics&nbsp;()</strong>\n    </dt>\n    <dd>\n    Gets the list of all available <code>heuristics</code>.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">\n local heur = myFinder:getHeuristic()\n for i, heuristicName in ipairs(heur) do\n   ...\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">{string,...}</span></span>\n        array of heuristic names.\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/core.heuristics.html#\">core.heuristics</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Pathfinder:setMode\"></a>\n    <strong>Pathfinder:setMode&nbsp;(mode)</strong>\n    </dt>\n    <dd>\n    Defines the search <code>mode</code>.\n The default search mode is the <code>DIAGONAL</code> mode, which implies 8-possible directions when moving (north, south, east, west and diagonals).\n In <code>ORTHOGONAL</code> mode, only 4-directions are allowed (north, south, east and west).\n Use <a href=\"../modules/pathfinder.html#Pathfinder:getModes\">Pathfinder:getModes</a> to get the list of all available search modes.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">mode</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a></span>\n       the new search <code>mode</code>.</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myFinder:setMode('ORTHOGNAL')</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <li><a href=\"../modules/pathfinder.html#Pathfinder:getModes\">Pathfinder:getModes</a></li>\n         <li><a href=\"../modules/pathfinder.html#Modes\">Modes</a></li>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getMode\"></a>\n    <strong>Pathfinder:getMode&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns the search mode.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local mode = myFinder:getMode()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#5.4\">string</a></span>\n        the current search mode\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/pathfinder.html#Modes\">Modes</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getModes\"></a>\n    <strong>Pathfinder:getModes&nbsp;()</strong>\n    </dt>\n    <dd>\n    Gets the list of all available search modes.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\"> local modes = myFinder:getModes()\n for modeName in ipairs(modes) do\n   ...\n end</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">{string,...}</span></span>\n        array of search modes.\n    </ol>\n\n\n    <h3>see also:</h3>\n    <ul>\n         <a href=\"../modules/pathfinder.html#Modes\">Modes</a>\n    </ul>\n</dd>\n    <dt>\n    <a name = \"Pathfinder:setTunnelling\"></a>\n    <strong>Pathfinder:setTunnelling&nbsp;(bool)</strong>\n    </dt>\n    <dd>\n    Enables tunnelling.  Defines the ability for the <a href=\"../modules/pathfinder.html#\">pathfinder</a>  to tunnel through walls when heading diagonally.\n This feature <strong>is not compatible</strong> with Jump Point Search algorithm (i.e. enabling it will not affect Jump Point Search)\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">bool</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">bool</a></span>\n       a boolean</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">myFinder:setTunnelling(true)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getTunnelling\"></a>\n    <strong>Pathfinder:getTunnelling&nbsp;()</strong>\n    </dt>\n    <dd>\n    Returns tunnelling feature state.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local isTunnellingEnabled = myFinder:getTunnelling()</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">bool</a></span>\n        tunnelling feature actual state\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:getPath\"></a>\n    <strong>Pathfinder:getPath&nbsp;(startX, startY, endX, endY, clearance)</strong>\n    </dt>\n    <dd>\n    Calculates a <code>path</code>.  Returns the <code>path</code> from location <strong>[startX, startY]</strong> to location <strong>[endX, endY]</strong>.\n Both locations must exist on the collision map. The starting location can be unwalkable.\n\n    <h3>Parameters:</h3>\n    <ul>\n      <li><span class=\"parameter\">startX</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the x-coordinate for the starting location</li>\n      <li><span class=\"parameter\">startY</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the y-coordinate for the starting location</li>\n      <li><span class=\"parameter\">endX</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the x-coordinate for the goal location</li>\n      <li><span class=\"parameter\">endY</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the y-coordinate for the goal location</li>\n      <li><span class=\"parameter\">clearance</span>\n        <span class=\"types\"><a class=\"type\" href=\"http://www.lua.org/manual/5.1/manual.html#2.2\">int</a></span>\n       the amount of clearance (i.e the pathing agent size) to consider</li>\n    </ul>\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local path = myFinder:getPath(1,1,5,5)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><span class=\"type\">path</span></span>\n        a path (array of nodes) when found, otherwise nil\n    </ol>\n\n\n</dd>\n    <dt>\n    <a name = \"Pathfinder:reset\"></a>\n    <strong>Pathfinder:reset&nbsp;()</strong>\n    </dt>\n    <dd>\n    Resets the <a href=\"../modules/pathfinder.html#\">pathfinder</a> .  This function is called internally between successive pathfinding calls, so you should not\n use it explicitely, unless under specific circumstances.\n\n\n    <h3>Usage:</h3>\n    <ul>\n        <pre class=\"example\">local path, len = myFinder:getPath(1,1,5,5)</pre>\n    </ul>\n\n    <h3>Returns:</h3>\n    <ol>\n\n          <span class=\"types\"><a class=\"type\" href=\"../modules/pathfinder.html#\">pathfinder</a></span>\n        self (the calling <a href=\"../modules/pathfinder.html#\">pathfinder</a>  itself, can be chained)\n    </ol>\n\n\n</dd>\n</dl>\n\n\n</div> <!-- id=\"content\" -->\n</div> <!-- id=\"main\" -->\n<div id=\"about\">\n<i>generated by <a href=\"http://github.com/stevedonovan/LDoc\">LDoc 1.2</a></i>\n</div> <!-- id=\"about\" -->\n</div> <!-- id=\"container\" -->\n</body>\n</html>\n"
  },
  {
    "path": "examples/annotatedPathing.lua",
    "content": "-- Tests sample for clearance metrics calculation\n-- See Figure 10 at http://aigamedev.com/open/tutorial/clearance-based-pathfinding/\n-- Jump Point Search still has some flaws with clearance based pathfinding\n\nlocal Grid = require 'jumper.grid'\nlocal PF = require 'jumper.pathfinder'\nlocal map = {\n\t{0,0,0,0,0,0,0,0,0,0},\n\t{0,0,0,0,0,0,0,0,1,0},\n\t{0,0,0,0,0,0,0,0,0,0},\n\t{0,0,0,1,0,0,0,0,0,0},\n\t{0,0,1,0,0,0,0,0,2,0},\n\t{0,0,1,1,1,0,0,2,0,0},\n\t{0,0,0,1,1,0,2,0,0,2},\n\t{0,0,0,0,1,0,0,0,0,2},\n\t{0,0,0,0,0,0,0,0,0,0},\n\t{0,0,0,0,0,0,0,0,0,0}\n}\nlocal grid = Grid(map)\nlocal walkable = function(v) return v~=2 end\nlocal finder = PF(grid, 'ASTAR',walkable)\nfinder:annotateGrid()\nlocal finderNames = PF:getFinders()\n\nlocal sx, sy = 1,1\nlocal ex, ey = 9,9\nlocal agent_size = 2\n\nfor i = 1,#finderNames do\n\tfinder:setFinder(finderNames[i])\n\tlocal path = finder:getPath(sx, sy, ex, ey, agent_size)\n\tprint(('Algorithm used: %s - Path %s')\n\t\t:format(finder:getFinder(), path and 'found' or 'not found'))\n\tif path then\n\t\tfor node, count in path:nodes() do\n\t\t\tprint(('  Step %d. (%d,%d)')\n\t\t\t\t:format(count, node:getPos()))\n\t\tend\n\tend\nend\n\n"
  },
  {
    "path": "examples/customHeuristics.lua",
    "content": "--- Example of use for Heuristics\n\nlocal Grid = require (\"jumper.grid\")\nlocal Pathfinder = require (\"jumper.pathfinder\")\n\nlocal map = {\n  {0,0,0,0,0,0},\n  {0,0,0,0,0,0},\n  {0,1,1,1,1,0},\n  {0,0,0,0,0,0},\n  {0,0,0,0,0,0},\n}\n\nlocal walkable = 0\nlocal grid = Grid(map)\nlocal myFinder = Pathfinder(grid, 'ASTAR', walkable)\n\n-- Use Euclidian heuristic to evaluate distance\nmyFinder:setHeuristic('EUCLIDIAN')\nmyFinder:setHeuristic('DIAGONAL')\nmyFinder:setHeuristic('MANHATTAN')\n\n-- Custom\nlocal h = function(nodeA, nodeB)\n\treturn (0.1 * (math.abs(nodeA:getX() - nodeB:getX()))\n\t      + 0.9 * (math.abs(nodeA:getY() - nodeB:getY())))\nend\nmyFinder:setHeuristic(h)\n\nlocal p = myFinder:getPath(1,1, 6,5)\nfor node, count in p:nodes() do\n  print(('%d. Node(%d,%d)'):format(count, node:getX(), node:getY()))\nend\nprint(('Path length: %.2f'):format(p:getLength()))\n\n-- etc ...\n"
  },
  {
    "path": "examples/makeClearance.lua",
    "content": "-- Tests sample for clearance metrics calculation\n-- See Figure 10 at http://aigamedev.com/open/tutorial/clearance-based-pathfinding/\nlocal Grid = require 'jumper.grid'\nlocal PF = require 'jumper.pathfinder'\nlocal map = {\n\t{0,0,0,0,0,0,0,0,0,0},\n\t{0,0,0,0,0,0,0,0,1,0},\n\t{0,0,0,0,0,0,0,0,0,0},\n\t{0,0,0,1,0,0,0,0,0,0},\n\t{0,0,1,0,0,0,0,0,2,0},\n\t{0,0,1,1,1,0,0,2,0,0},\n\t{0,0,0,1,1,0,2,0,0,2},\n\t{0,0,0,0,1,0,0,0,0,2},\n\t{0,0,0,0,0,0,0,0,0,0},\n\t{0,0,0,0,0,0,0,0,0,0}\n}\nlocal grid = Grid(map)\nlocal walkable = function(v) return v~=2 end\nlocal finder = PF(grid, 'ASTAR',walkable)\nfinder:annotateGrid()\n\nfor y = 1, #map do\n\tlocal s = ''\n\tfor x = 1, #map[y] do\n\t  local node = grid:getNodeAt(x,y)\n\t\ts = (s .. ' ' .. node:getClearance(walkable))\n\tend\n\tprint(s)\nend\n\n-- Expected output\n--  6 6 5 5 4 4 4 3 2 1\n--  6 5 5 4 4 3 3 3 2 1\n--  6 5 4 4 3 3 2 2 2 1\n--  6 5 4 3 3 2 2 1 1 1\n--  6 5 4 3 2 2 1 1 0 1\n--  5 5 4 3 2 1 1 0 1 1\n--  4 4 4 3 2 1 0 2 1 0\n--  3 3 3 3 3 3 3 2 1 0\n--  2 2 2 2 2 2 2 2 2 1\n--  1 1 1 1 1 1 1 1 1 1\n\n"
  },
  {
    "path": "examples/simpleExample.lua",
    "content": "--- Very minimal usage example for Jumper\n\n-- Set up a collision map\nlocal map = {\n\t{0,1,0,1,0},\n\t{0,1,0,1,0},\n\t{0,1,1,1,0},\n\t{0,0,0,0,0},\n}\n-- Value for walkable tiles\nlocal walkable = 0\n\n-- Library setup\n-- Calls the grid class\nlocal Grid = require (\"jumper.grid\")\n-- Calls the pathfinder class\nlocal Pathfinder = require (\"jumper.pathfinder\")\n\n-- Creates a grid object\nlocal grid = Grid(map)\n\n-- Creates a pathfinder object using Jump Point Search algorithm\nlocal myFinder = Pathfinder(grid, 'JPS', walkable)\n\n-- Define start and goal locations coordinates\nlocal startx, starty = 1,1\nlocal endx, endy = 5,1\n\n-- Calculates the path, and its length\nlocal path = myFinder:getPath(startx, starty, endx, endy)\n\n-- Pretty-printing the results\nif path then\n  print(('Path found! Length: %.2f'):format(path:getLength()))\n\tfor node, count in path:nodes() do\n\t  print(('Step: %d - x: %d - y: %d'):format(count, node:getX(), node:getY()))\n\tend\nend\n"
  },
  {
    "path": "jumper/core/assert.lua",
    "content": "-- Various assertion function for API methods argument-checking\n\nif (...) then\n\t\n\t-- Dependancies\n\tlocal _PATH = (...):gsub('%.core.assert$','')\n\tlocal Utils = require (_PATH .. '.core.utils')\n\t\n\t-- Local references\n\tlocal lua_type = type\n\tlocal floor = math.floor\n\tlocal concat = table.concat\n\tlocal next = next\n\tlocal pairs = pairs\n\tlocal getmetatable = getmetatable\n\t\n\t-- Is I an integer ?\n\tlocal function isInteger(i)\n\t\treturn lua_type(i) ==('number') and (floor(i)==i)\n\tend\n\t\n\t-- Override lua_type to return integers\n\tlocal function type(v)\n\t\treturn isInteger(v) and 'int' or lua_type(v)\n\tend\n\t\n\t-- Does the given array contents match a predicate type ?\n\tlocal function arrayContentsMatch(t,...)\n\t\tlocal n_count = Utils.arraySize(t)\n\t\tif n_count < 1 then return false end\n\t\tlocal init_count = t[0] and 0 or 1\n\t\tlocal n_count = (t[0] and n_count-1 or n_count)\n\t\tlocal types = {...}\n\t\tif types then types = concat(types) end\n\t\tfor i=init_count,n_count,1 do\n\t\t\tif not t[i] then return false end\n\t\t\tif types then\n\t\t\t\tif not types:match(type(t[i])) then return false end\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend\t\n\t\n\t-- Checks if arg is a valid array map\n  local function isMap(m)\n\t\tif not arrayContentsMatch(m, 'table') then return false end\n\t\tlocal lsize = Utils.arraySize(m[next(m)])\n\t\tfor k,v in pairs(m) do\n\t\t\tif not arrayContentsMatch(m[k], 'string', 'int') then return false end\n\t\t\tif Utils.arraySize(v)~=lsize then return false end\n\t\tend\n\t\treturn true\n  end\t\n\t\n\t-- Checks if s is a valid string map\n  local function isStringMap(s)\n    if lua_type(s) ~= 'string' then return false end\n    local w\n    for row in s:gmatch('[^\\n\\r]+') do\n      if not row then return false end\n      w = w or #row\n      if w ~= #row then return false end\n    end\n    return true\n  end\n\n\t-- Does instance derive straight from class\n\tlocal function derives(instance, class)\n\t\treturn getmetatable(instance) == class\n\tend\n\t\n\t-- Does instance inherits from class\t\n\tlocal function inherits(instance, class)\n\t\treturn (getmetatable(getmetatable(instance)) == class)\n\tend\n\t\n\t-- Is arg a boolean\n\tlocal function isBoolean(b) \n\t\treturn (b==true or b==false)\n\tend\n\t\n\t-- Is arg nil ?\n\tlocal function isNil(n)\n\t\treturn (n==nil)\n\tend\n\t\n\tlocal function matchType(value, types)\n\t\treturn types:match(type(value))\t\n\tend\n\t\n\treturn {\n\t\tarrayContentsMatch = arrayContentsMatch,\n\t\tderives = derives,\n\t\tinherits = inherits,\n\t\tisInteger = isInteger,\n\t\tisBool = isBoolean,\n\t\tisMap = isMap,\n\t\tisStrMap = isStringMap,\n\t\tisOutOfRange = isOutOfRange,\n\t\tisNil = isNil,\n\t\ttype = type,\n\t\tmatchType = matchType\n\t}\n\nend\n\n\n"
  },
  {
    "path": "jumper/core/bheap.lua",
    "content": "--- A light implementation of Binary heaps data structure.\n-- While running a search, some search algorithms (Astar, Dijkstra, Jump Point Search) have to maintains\n-- a list of nodes called __open list__. Retrieve from this list the lowest cost node can be quite slow, \n-- as it normally requires to skim through the full set of nodes stored in this list. This becomes a real \n-- problem especially when dozens of nodes are being processed (on large maps). \n--\n-- The current module implements a <a href=\"http://www.policyalmanac.org/games/binaryHeaps.htm\">binary heap</a>\n-- data structure, from which the search algorithm will instantiate an open list, and cache the nodes being \n-- examined during a search. As such, retrieving the lower-cost node is faster and globally makes the search end \n-- up quickly.\n-- \n-- This module is internally used by the library on purpose.\n-- It should normally not be used explicitely, yet it remains fully accessible.\n--\n\n--[[\n  Notes:\n  This lighter implementation of binary heaps, based on :\n    https://github.com/Yonaba/Binary-Heaps\n--]]\n\nif (...) then\n\n\t-- Dependency\n\tlocal Utils = require((...):gsub('%.bheap$','.utils'))\n\t\n\t-- Local reference\n\tlocal floor = math.floor\n\n\t-- Default comparison function\n\tlocal function f_min(a,b) return a < b end\n\n\t-- Percolates up\n\tlocal function percolate_up(heap, index)\n\t\tif index == 1 then return end\n\t\tlocal pIndex\n\t\tif index <= 1 then return end\n\t\tif index%2 == 0 then\n\t\t\tpIndex =  index/2\n\t\telse pIndex = (index-1)/2\n\t\tend\n\t\tif not heap._sort(heap._heap[pIndex], heap._heap[index]) then\n\t\t\theap._heap[pIndex], heap._heap[index] = \n\t\t\t\theap._heap[index], heap._heap[pIndex]\n\t\t\tpercolate_up(heap, pIndex)\n\t\tend\n\tend\n\n\t-- Percolates down\n\tlocal function percolate_down(heap,index)\n\t\tlocal lfIndex,rtIndex,minIndex\n\t\tlfIndex = 2*index\n\t\trtIndex = lfIndex + 1\n\t\tif rtIndex > heap._size then\n\t\t\tif lfIndex > heap._size then return\n\t\t\telse minIndex = lfIndex  end\n\t\telse\n\t\t\tif heap._sort(heap._heap[lfIndex],heap._heap[rtIndex]) then\n\t\t\t\tminIndex = lfIndex\n\t\t\telse\n\t\t\t\tminIndex = rtIndex\n\t\t\tend\n\t\tend\n\t\tif not heap._sort(heap._heap[index],heap._heap[minIndex]) then\n\t\t\theap._heap[index],heap._heap[minIndex] = heap._heap[minIndex],heap._heap[index]\n\t\t\tpercolate_down(heap,minIndex)\n\t\tend\n\tend\n\n\t-- Produces a new heap\n\tlocal function newHeap(template,comp)\n\t\treturn setmetatable({_heap = {},\n\t\t\t_sort = comp or f_min, _size = 0},\n\t\ttemplate)\n\tend\n\n\n\t--- The `heap` class.<br/>\n\t-- This class is callable.\n\t-- _Therefore,_ <code>heap(...)</code> _is used to instantiate new heaps_.\n\t-- @type heap\n\tlocal heap = setmetatable({},\n\t\t{__call = function(self,...)\n\t\t\treturn newHeap(self,...)\n\t\tend})\n\theap.__index = heap\n\n\t--- Checks if a `heap` is empty\n\t-- @class function\n\t-- @treturn bool __true__ of no item is queued in the heap, __false__ otherwise\n\t-- @usage\n\t-- if myHeap:empty() then \n\t--   print('Heap is empty!')\n\t-- end\n\tfunction heap:empty()\n\t\treturn (self._size==0)\n\tend\n\n\t--- Clears the `heap` (removes all items queued in the heap)\n\t-- @class function\n\t-- @treturn heap self (the calling `heap` itself, can be chained)\n\t-- @usage myHeap:clear()\n\tfunction heap:clear()\n\t\tself._heap = {}\n\t\tself._size = 0\n\t\tself._sort = self._sort or f_min\n\t\treturn self\n\tend\n\n\t--- Adds a new item in the `heap`\n\t-- @class function\n\t-- @tparam value item a new value to be queued in the heap\n\t-- @treturn heap self (the calling `heap` itself, can be chained)\n\t-- @usage\n\t-- myHeap:push(1)\n\t-- -- or, with chaining\n\t-- myHeap:push(1):push(2):push(4)\n\tfunction heap:push(item)\n\t\tif item then\n\t\t\tself._size = self._size + 1\n\t\t\tself._heap[self._size] = item\n\t\t\tpercolate_up(self, self._size)\n\t\tend\n\t\treturn self\n\tend\n\n\t--- Pops from the `heap`.\n\t-- Removes and returns the lowest cost item (with respect to the comparison function being used) from the `heap`.\n\t-- @class function\n\t-- @treturn value a value previously pushed into the heap\n\t-- @usage\n\t-- while not myHeap:empty() do \n\t--   local lowestValue = myHeap:pop()\n\t--   ...\n\t-- end\n\tfunction heap:pop()\n\t\tlocal root\n\t\tif self._size > 0 then\n\t\t\troot = self._heap[1]\n\t\t\tself._heap[1] = self._heap[self._size]\n\t\t\tself._heap[self._size] = nil\n\t\t\tself._size = self._size-1\n\t\t\tif self._size>1 then\n\t\t\t\tpercolate_down(self, 1)\n\t\t\tend\n\t\tend\n\t\treturn root\n\tend\n\n\t--- Restores the `heap` property.\n\t-- Reorders the `heap` with respect to the comparison function being used. \n\t-- When given argument __item__ (a value existing in the `heap`), will sort from that very item in the `heap`. \n\t-- Otherwise, the whole `heap` will be cheacked. \n\t-- @class function\n\t-- @tparam[opt] value item the modified value\n\t-- @treturn heap self (the calling `heap` itself, can be chained)\n\t-- @usage myHeap:heapify() \n\tfunction heap:heapify(item)\n\t\tif self._size == 0 then return end\n\t\tif item then\n\t\t\tlocal i = Utils.indexOf(self._heap,item)\n\t\t\tif i then \n\t\t\t\tpercolate_down(self, i)\n\t\t\t\tpercolate_up(self, i)\n\t\t\tend\n\t\t\treturn\n\t\tend\n\t\tfor i = floor(self._size/2),1,-1 do\n\t\t\tpercolate_down(self,i)\n\t\tend\n\t\treturn self\n\tend\n\n\treturn heap\nend"
  },
  {
    "path": "jumper/core/heuristics.lua",
    "content": "--- Heuristic functions for search algorithms.\n-- A <a href=\"http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html\">distance heuristic</a> \n-- provides an *estimate of the optimal distance cost* from a given location to a target. \n-- As such, it guides the pathfinder to the goal, helping it to decide which route is the best.\n--\n-- This script holds the definition of some built-in heuristics available through jumper.\n--\n-- Distance functions are internally used by the `pathfinder` to evaluate the optimal path\n-- from the start location to the goal. These functions share the same prototype:\n--     local function myHeuristic(nodeA, nodeB)\n--       -- function body\n--     end\n-- Jumper features some built-in distance heuristics, namely `MANHATTAN`, `EUCLIDIAN`, `DIAGONAL`, `CARDINTCARD`.\n-- You can also supply your own heuristic function, following the same template as above.\n\n\nlocal abs = math.abs\nlocal sqrt = math.sqrt\nlocal sqrt2 = sqrt(2)\nlocal max, min = math.max, math.min\n\nlocal Heuristics = {}\n  --- Manhattan distance.\n  -- <br/>This heuristic is the default one being used by the `pathfinder` object.\n  -- <br/>Evaluates as <code>distance = |dx|+|dy|</code>\n  -- @class function\n  -- @tparam node nodeA a node\n  -- @tparam node nodeB another node\n  -- @treturn number the distance from __nodeA__ to __nodeB__\n\t-- @usage\n  -- -- First method\n  -- pathfinder:setHeuristic('MANHATTAN')\n  -- -- Second method\n  -- local Distance = require ('jumper.core.heuristics')\n  -- pathfinder:setHeuristic(Distance.MANHATTAN)\n  function Heuristics.MANHATTAN(nodeA, nodeB) \n\t\tlocal dx = abs(nodeA._x - nodeB._x)\n\t\tlocal dy = abs(nodeA._y - nodeB._y)\n\t\treturn (dx + dy) \n\tend\n  \n  --- Euclidian distance.\n  -- <br/>Evaluates as <code>distance = squareRoot(dx*dx+dy*dy)</code>\n  -- @class function\n  -- @tparam node nodeA a node\n  -- @tparam node nodeB another node\n  -- @treturn number the distance from __nodeA__ to __nodeB__\n\t-- @usage\n  -- -- First method\n  -- pathfinder:setHeuristic('EUCLIDIAN')\n  -- -- Second method\n  -- local Distance = require ('jumper.core.heuristics')\n  -- pathfinder:setHeuristic(Distance.EUCLIDIAN) \n  function Heuristics.EUCLIDIAN(nodeA, nodeB)\n\t\tlocal dx = nodeA._x - nodeB._x\n\t\tlocal dy = nodeA._y - nodeB._y\n\t\treturn sqrt(dx*dx+dy*dy) \n\tend\n  \n  --- Diagonal distance.\n  -- <br/>Evaluates as <code>distance = max(|dx|, abs|dy|)</code>\n  -- @class function\n  -- @tparam node nodeA a node\n  -- @tparam node nodeB another node\n  -- @treturn number the distance from __nodeA__ to __nodeB__\n\t-- @usage\n  -- -- First method\n  -- pathfinder:setHeuristic('DIAGONAL')\n  -- -- Second method\n  -- local Distance = require ('jumper.core.heuristics')\n  -- pathfinder:setHeuristic(Distance.DIAGONAL)\n  function Heuristics.DIAGONAL(nodeA, nodeB)\n\t\tlocal dx = abs(nodeA._x - nodeB._x)\n\t\tlocal dy = abs(nodeA._y - nodeB._y)\t\n\t\treturn max(dx,dy) \n\tend\n  \n  --- Cardinal/Intercardinal distance.\n  -- <br/>Evaluates as <code>distance = min(dx, dy)*squareRoot(2) + max(dx, dy) - min(dx, dy)</code>\n  -- @class function\n  -- @tparam node nodeA a node\n  -- @tparam node nodeB another node\n  -- @treturn number the distance from __nodeA__ to __nodeB__\n\t-- @usage\n  -- -- First method\n  -- pathfinder:setHeuristic('CARDINTCARD')\n  -- -- Second method\n  -- local Distance = require ('jumper.core.heuristics')\n  -- pathfinder:setHeuristic(Distance.CARDINTCARD)\n  function Heuristics.CARDINTCARD(nodeA, nodeB)\n\t\tlocal dx = abs(nodeA._x - nodeB._x)\n\t\tlocal dy = abs(nodeA._y - nodeB._y)\t\n    return min(dx,dy) * sqrt2 + max(dx,dy) - min(dx,dy)\n  end\n\nreturn Heuristics"
  },
  {
    "path": "jumper/core/lookuptable.lua",
    "content": "local addNode(self, node, nextNode, ed)\n\tif not self._pathDB[node] then self._pathDB[node] = {} end\n\tself._pathDB[node][ed] = (nextNode == ed and node or nextNode)\nend\n\n-- Path lookupTable\nlocal lookupTable = {}\nlookupTable.__index = lookupTable\n\nfunction lookupTable:new()\n\tlocal lut = {_pathDB = {}}\n\treturn setmetatable(lut, lookupTable)\nend\n\nfunction lookupTable:addPath(path)\n\tlocal st, ed = path._nodes[1], path._nodes[#path._nodes]\n\tfor node, count in path:nodes() do\n\t\tlocal nextNode = path._nodes[count+1]\n\t\tif nextNode then addNode(self, node, nextNode, ed) end\n\tend\nend\n\nfunction lookupTable:hasPath(nodeA, nodeB)\n\tlocal found\n\tfound = self._pathDB[nodeA] and self._path[nodeA][nodeB]\n\tif found then return true, true end\n\tfound = self._pathDB[nodeB] and self._path[nodeB][nodeA]\n\tif found then return true, false end\n\treturn false\nend\n\nreturn lookupTable"
  },
  {
    "path": "jumper/core/node.lua",
    "content": "--- The Node class.\n-- The `node` represents a cell (or a tile) on a collision map. Basically, for each single cell (tile)\n-- in the collision map passed-in upon initialization, a `node` object will be generated\n-- and then cached within the `grid`.\n--\n-- In the following implementation, nodes can be compared using the `<` operator. The comparison is\n-- made with regards of their `f` cost. From a given node being examined, the `pathfinder` will expand the search \n-- to the next neighbouring node having the lowest `f` cost. See `core.bheap` for more details.\n-- \n\nif (...) then\n\n\tlocal assert = assert\n\t\n\t--- The `Node` class.<br/>\n\t-- This class is callable.\n\t-- Therefore,_ <code>Node(...)</code> _acts as a shortcut to_ <code>Node:new(...)</code>.\n\t-- @type Node\n  local Node = {}\n  Node.__index = Node\n\n  --- Inits a new `node`\n  -- @class function\n  -- @tparam int x the x-coordinate of the node on the collision map\n  -- @tparam int y the y-coordinate of the node on the collision map\n  -- @treturn node a new `node`\n\t-- @usage local node = Node(3,4)\n  function Node:new(x,y)\n    return setmetatable({_x = x, _y = y, _clearance = {}}, Node)\n  end\n\n  -- Enables the use of operator '<' to compare nodes.\n  -- Will be used to sort a collection of nodes in a binary heap on the basis of their F-cost\n  function Node.__lt(A,B) return (A._f < B._f) end\n\n  --- Returns x-coordinate of a `node`\n  -- @class function\n  -- @treturn number the x-coordinate of the `node`\n\t-- @usage local x = node:getX()\t\n\tfunction Node:getX() return self._x end\n\t\n  --- Returns y-coordinate of a `node`\n  -- @class function\n  -- @treturn number the y-coordinate of the `node`\t\n\t-- @usage local y = node:getY()\t\t\n\tfunction Node:getY() return self._y end\n\t\n  --- Returns x and y coordinates of a `node`\n  -- @class function\n  -- @treturn number the x-coordinate of the `node`\n  -- @treturn number the y-coordinate of the `node`\n\t-- @usage local x, y = node:getPos()\t\t\n\tfunction Node:getPos() return self._x, self._y end\n\t\n  --- Returns the amount of true [clearance](http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric) \n\t-- for a given `node`\n  -- @class function\n  -- @tparam string|int|func walkable the value for walkable locations in the collision map array.\n  -- @treturn int the clearance of the `node`\n\t-- @usage\n\t--  -- Assuming walkable was 0\t\n\t-- local clearance = node:getClearance(0)\t\t\n\tfunction Node:getClearance(walkable)\n\t\treturn self._clearance[walkable]\n\tend\n\t\n  --- Removes the clearance value for a given walkable.\n  -- @class function\n  -- @tparam string|int|func walkable the value for walkable locations in the collision map array.\n\t-- @treturn node self (the calling `node` itself, can be chained)\n\t-- @usage\n\t--  -- Assuming walkable is defined\t\n\t-- node:removeClearance(walkable)\t\n\tfunction Node:removeClearance(walkable)\n\t\tself._clearance[walkable] = nil\n\t\treturn self\n\tend\n\t\n\t--- Clears temporary cached attributes of a `node`.\n\t-- Deletes the attributes cached within a given node after a pathfinding call.\n\t-- This function is internally used by the search algorithms, so you should not use it explicitely.\n\t-- @class function\n\t-- @treturn node self (the calling `node` itself, can be chained)\n\t-- @usage\n\t-- local thisNode = Node(1,2)\n\t-- thisNode:reset()\n\tfunction Node:reset()\n\t\tself._g, self._h, self._f = nil, nil, nil\n\t\tself._opened, self._closed, self._parent = nil, nil, nil\n\t\treturn self\n\tend\n\t\n  return setmetatable(Node,\n\t\t{__call = function(self,...) \n\t\t\treturn Node:new(...) \n\t\tend}\n\t)\nend"
  },
  {
    "path": "jumper/core/path.lua",
    "content": "--- The Path class.\n-- The `path` class is a structure which represents a path (ordered set of nodes) from a start location to a goal.\n-- An instance from this class would be a result of a request addressed to `Pathfinder:getPath`.\n--\n-- This module is internally used by the library on purpose.\n-- It should normally not be used explicitely, yet it remains fully accessible.\n--\n\n\nif (...) then\n\t\n  -- Dependencies\n\tlocal _PATH = (...):match('(.+)%.path$')\n  local Heuristic = require (_PATH .. '.heuristics')\n\t\n\t -- Local references\n  local abs, max = math.abs, math.max\n\tlocal t_insert, t_remove = table.insert, table.remove\n\t\n\t--- The `Path` class.<br/>\n\t-- This class is callable.\n\t-- Therefore, <em><code>Path(...)</code></em> acts as a shortcut to <em><code>Path:new(...)</code></em>.\n\t-- @type Path\n  local Path = {}\n  Path.__index = Path\n\n  --- Inits a new `path`.\n  -- @class function\n  -- @treturn path a `path`\n\t-- @usage local p = Path()\n  function Path:new()\n    return setmetatable({_nodes = {}}, Path)\n  end\n\n  --- Iterates on each single `node` along a `path`. At each step of iteration,\n  -- returns the `node` plus a count value. Aliased as @{Path:nodes}\n  -- @class function\n  -- @treturn node a `node`\n  -- @treturn int the count for the number of nodes\n\t-- @see Path:nodes\n\t-- @usage\n\t-- for node, count in p:iter() do\n\t--   ...\n\t-- end\n  function Path:iter()\n    local i,pathLen = 1,#self._nodes\n    return function()\n      if self._nodes[i] then\n        i = i+1\n        return self._nodes[i-1],i-1\n      end\n    end\n  end\n  \n  --- Iterates on each single `node` along a `path`. At each step of iteration,\n  -- returns a `node` plus a count value. Alias for @{Path:iter}\n  -- @class function\n\t-- @name Path:nodes\n  -- @treturn node a `node`\n  -- @treturn int the count for the number of nodes\n\t-- @see Path:iter\t\n\t-- @usage\n\t-- for node, count in p:nodes() do\n\t--   ...\n\t-- end\t\n\tPath.nodes = Path.iter\n\t\n  --- Evaluates the `path` length\n  -- @class function\n  -- @treturn number the `path` length\n\t-- @usage local len = p:getLength()\n  function Path:getLength()\n    local len = 0\n    for i = 2,#self._nodes do\n      len = len + Heuristic.EUCLIDIAN(self._nodes[i], self._nodes[i-1])\n    end\n    return len\n  end\n\t\n\t--- Counts the number of steps.\n\t-- Returns the number of waypoints (nodes) in the current path.\n\t-- @class function\n\t-- @tparam node node a node to be added to the path\n\t-- @tparam[opt] int index the index at which the node will be inserted. If omitted, the node will be appended after the last node in the path.\n\t-- @treturn path self (the calling `path` itself, can be chained)\n\t-- @usage local nSteps = p:countSteps()\n\tfunction Path:addNode(node, index)\n\t\tindex = index or #self._nodes+1\n\t\tt_insert(self._nodes, index, node)\n\t\treturn self\n\tend\n\t\n\t\n  --- `Path` filling modifier. Interpolates between non contiguous nodes along a `path`\n  -- to build a fully continuous `path`. This maybe useful when using search algorithms such as Jump Point Search.\n  -- Does the opposite of @{Path:filter}\n  -- @class function\n\t-- @treturn path self (the calling `path` itself, can be chained)\t\n  -- @see Path:filter\n\t-- @usage p:fill()\n  function Path:fill()\n    local i = 2\n    local xi,yi,dx,dy\n    local N = #self._nodes\n    local incrX, incrY\n    while true do\n      xi,yi = self._nodes[i]._x,self._nodes[i]._y\n      dx,dy = xi-self._nodes[i-1]._x,yi-self._nodes[i-1]._y\n      if (abs(dx) > 1 or abs(dy) > 1) then\n        incrX = dx/max(abs(dx),1)\n        incrY = dy/max(abs(dy),1)\n        t_insert(self._nodes, i, self._grid:getNodeAt(self._nodes[i-1]._x + incrX, self._nodes[i-1]._y +incrY))\n        N = N+1\n      else i=i+1\n      end\n      if i>N then break end\n    end\n\t\treturn self\n  end\n\n  --- `Path` compression modifier. Given a `path`, eliminates useless nodes to return a lighter `path` \n\t-- consisting of straight moves. Does the opposite of @{Path:fill}\n  -- @class function\n\t-- @treturn path self (the calling `path` itself, can be chained)\t\n  -- @see Path:fill\n\t-- @usage p:filter()\n  function Path:filter()\n    local i = 2\n    local xi,yi,dx,dy, olddx, olddy\n    xi,yi = self._nodes[i]._x, self._nodes[i]._y\n    dx, dy = xi - self._nodes[i-1]._x, yi-self._nodes[i-1]._y\n    while true do\n      olddx, olddy = dx, dy\n      if self._nodes[i+1] then\n        i = i+1\n        xi, yi = self._nodes[i]._x, self._nodes[i]._y\n        dx, dy = xi - self._nodes[i-1]._x, yi - self._nodes[i-1]._y\n        if olddx == dx and olddy == dy then\n          t_remove(self._nodes, i-1)\n          i = i - 1\n        end\n      else break end\n    end\n\t\treturn self\n  end\n\t\n  --- Clones a `path`.\n  -- @class function\n  -- @treturn path a `path`\n\t-- @usage local p = path:clone()\t\n\tfunction Path:clone()\n\t\tlocal p = Path:new()\n\t\tfor node in self:nodes() do p:addNode(node) end\n\t\treturn p\n\tend\n\t\n  --- Checks if a `path` is equal to another. It also supports *filtered paths* (see @{Path:filter}).\n  -- @class function\n\t-- @tparam path p2 a path\n  -- @treturn boolean a boolean\n\t-- @usage print(myPath:isEqualTo(anotherPath))\n\tfunction Path:isEqualTo(p2)\n\t\tlocal p1 = self:clone():filter()\n\t\tlocal p2 = p2:clone():filter()\n\t\tfor node, count in p1:nodes() do\n\t\t\tif not p2._nodes[count] then return false end\n\t\t\tlocal n = p2._nodes[count]\n\t\t\tif n._x~=node._x or n._y~=node._y then return false end\n\t\tend\t\n\t\treturn true\n\tend\n\t\n  --- Reverses a `path`.\n  -- @class function\n\t-- @treturn path self (the calling `path` itself, can be chained)\n\t-- @usage myPath:reverse()\t\n\tfunction Path:reverse()\n\t\tlocal _nodes = {}\n\t\tfor i = #self._nodes,1,-1 do\n\t\t\t_nodes[#_nodes+1] = self._nodes[i]\t\t\n\t\tend\n\t\tself._nodes = _nodes\n\t\treturn self\n\tend\t\n\n  --- Appends a given `path` to self.\n  -- @class function\n\t-- @tparam path p a path\n\t-- @treturn path self (the calling `path` itself, can be chained)\n\t-- @usage myPath:append(anotherPath)\t\t\n\tfunction Path:append(p)\n\t\tfor node in p:nodes() do self:addNode(node)\tend\n\t\treturn self\n\tend\n\t\n  return setmetatable(Path,\n    {__call = function(self,...)\n      return Path:new(...)\n    end\n  })\nend"
  },
  {
    "path": "jumper/core/utils.lua",
    "content": "-- Various utilities for Jumper top-level modules\n\nif (...) then\n\n\t-- Dependencies\n\tlocal _PATH = (...):gsub('%.utils$','')\n\tlocal Path = require (_PATH .. '.path')\n\tlocal Node = require (_PATH .. '.node')\n\n\t-- Local references\n\tlocal pairs = pairs\n\tlocal type = type\n\tlocal t_insert = table.insert\n\tlocal assert = assert\n\tlocal coroutine = coroutine\n\n\t-- Raw array items count\n\tlocal function arraySize(t)\n\t\tlocal count = 0\n\t\tfor k,v in pairs(t) do\n\t\t\tcount = count+1\n\t\tend\n\t\treturn count\n\tend\n\n\t-- Parses a string map and builds an array map\n  local function stringMapToArray(str)\n\t\tlocal map = {}\n\t\tlocal w, h\n    for line in str:gmatch('[^\\n\\r]+') do\n      if line then\n        w = not w and #line or w\n        assert(#line == w, 'Error parsing map, rows must have the same size!')\n        h = (h or 0) + 1\n        map[h] = {}\n        for char in line:gmatch('.') do\n\t\t\t\t\tmap[h][#map[h]+1] = char\n\t\t\t\tend\n      end\n    end\n    return map\n  end\n\n\t-- Collects and returns the keys of a given array\n  local function getKeys(t)\n    local keys = {}\n    for k,v in pairs(t) do keys[#keys+1] = k end\n    return keys\n  end\n\n\t-- Calculates the bounds of a 2d array\n  local function getArrayBounds(map)\n    local min_x, max_x\n    local min_y, max_y\n      for y in pairs(map) do\n        min_y = not min_y and y or (y<min_y and y or min_y)\n        max_y = not max_y and y or (y>max_y and y or max_y)\n        for x in pairs(map[y]) do\n          min_x = not min_x and x or (x<min_x and x or min_x)\n          max_x = not max_x and x or (x>max_x and x or max_x)\n        end\n      end\n    return min_x,max_x,min_y,max_y\n  end\n\n  -- Converts an array to a set of nodes\n  local function arrayToNodes(map)\n    local min_x, max_x\n    local min_y, max_y\n    local nodes = {}\n      for y in pairs(map) do\n        min_y = not min_y and y or (y<min_y and y or min_y)\n        max_y = not max_y and y or (y>max_y and y or max_y)\n        nodes[y] = {}\n        for x in pairs(map[y]) do\n          min_x = not min_x and x or (x<min_x and x or min_x)\n          max_x = not max_x and x or (x>max_x and x or max_x)\n          nodes[y][x] = Node:new(x,y)\n        end\n      end\n    return nodes,\n\t\t\t (min_x or 0), (max_x or 0),\n\t\t\t (min_y or 0), (max_y or 0)\n  end\n\n\t-- Iterator, wrapped within a coroutine\n\t-- Iterates around a given position following the outline of a square\n\tlocal function around()\n\t\tlocal iterf = function(x0, y0, s)\n\t\t\tlocal x, y = x0-s, y0-s\n\t\t\tcoroutine.yield(x, y)\n\t\t\trepeat\n\t\t\t\tx = x + 1\n\t\t\t\tcoroutine.yield(x,y)\n\t\t\tuntil x == x0+s\n\t\t\trepeat\n\t\t\t\ty = y + 1\n\t\t\t\tcoroutine.yield(x,y)\n\t\t\tuntil y == y0 + s\n\t\t\trepeat\n\t\t\t\tx = x - 1\n\t\t\t\tcoroutine.yield(x, y)\n\t\t\tuntil x == x0-s\n\t\t\trepeat\n\t\t\t\ty = y - 1\n\t\t\t\tcoroutine.yield(x,y)\n\t\t\tuntil y == y0-s+1\n\t\tend\n\t\treturn coroutine.create(iterf)\n\tend\n\n\t-- Extract a path from a given start/end position\n  local function traceBackPath(finder, node, startNode)\n    local path = Path:new()\n    path._grid = finder._grid\n    while true do\n      if node._parent then\n        t_insert(path._nodes,1,node)\n        node = node._parent\n      else\n        t_insert(path._nodes,1,startNode)\n        return path\n      end\n    end\n  end\n\n\t-- Lookup for value in a table\n\tlocal indexOf = function(t,v)\n\t\tfor i = 1,#t do\n\t\t\tif t[i] == v then return i end\n\t\tend\n\t\treturn nil\n\tend\n\n\t-- Is i out of range\n  local function outOfRange(i,low,up)\n    return (i< low or i > up)\n  end\n\t\n\treturn {\n\t\tarraySize = arraySize,\n\t\tgetKeys = getKeys,\n\t\tindexOf = indexOf,\n\t\toutOfRange = outOfRange,\n\t\tgetArrayBounds = getArrayBounds,\n\t\tarrayToNodes = arrayToNodes,\n\t\tstrToMap = stringMapToArray,\n\t\taround = around,\n\t\tdrAround = drAround,\n\t\ttraceBackPath = traceBackPath\n\t}\n\nend\n"
  },
  {
    "path": "jumper/grid.lua",
    "content": "--- The Grid class.\n-- Implementation of the `grid` class.\n-- The `grid` is a implicit graph which represents the 2D\n-- world map layout on which the `pathfinder` object will run.\n-- During a search, the `pathfinder` object needs to save some critical values. These values are cached within each `node`\n-- object, and the whole set of nodes are tight inside the `grid` object itself.\n\nif (...) then\n\n\t-- Dependencies\n  local _PATH = (...):gsub('%.grid$','')\n\n\t-- Local references\n  local Utils = require (_PATH .. '.core.utils')\n  local Assert = require (_PATH .. '.core.assert')\n  local Node = require (_PATH .. '.core.node')\n\n\t-- Local references\n  local pairs = pairs\n  local assert = assert\n  local next = next\n\tlocal setmetatable = setmetatable\n  local floor = math.floor\n\tlocal coroutine = coroutine\n\n  -- Offsets for straights moves\n  local straightOffsets = {\n    {x = 1, y = 0} --[[W]], {x = -1, y =  0}, --[[E]]\n    {x = 0, y = 1} --[[S]], {x =  0, y = -1}, --[[N]]\n  }\n\n  -- Offsets for diagonal moves\n  local diagonalOffsets = {\n    {x = -1, y = -1} --[[NW]], {x = 1, y = -1}, --[[NE]]\n    {x = -1, y =  1} --[[SW]], {x = 1, y =  1}, --[[SE]]\n  }\n\n\t--- The `Grid` class.<br/>\n\t-- This class is callable.\n\t-- Therefore,_ <code>Grid(...)</code> _acts as a shortcut to_ <code>Grid:new(...)</code>.\n\t-- @type Grid\n  local Grid = {}\n  Grid.__index = Grid\n\n  -- Specialized grids\n  local PreProcessGrid = setmetatable({},Grid)\n  local PostProcessGrid = setmetatable({},Grid)\n  PreProcessGrid.__index = PreProcessGrid\n  PostProcessGrid.__index = PostProcessGrid\n  PreProcessGrid.__call = function (self,x,y)\n    return self:getNodeAt(x,y)\n  end\n  PostProcessGrid.__call = function (self,x,y,create)\n    if create then return self:getNodeAt(x,y) end\n    return self._nodes[y] and self._nodes[y][x]\n  end\n\n  --- Inits a new `grid`\n  -- @class function\n  -- @tparam table|string map A collision map - (2D array) with consecutive indices (starting at 0 or 1)\n\t-- or a `string` with line-break chars (<code>\\n</code> or <code>\\r</code>) as row delimiters.\n  -- @tparam[opt] bool cacheNodeAtRuntime When __true__, returns an empty `grid` instance, so that\n\t-- later on, indexing a non-cached `node` will cause it to be created and cache within the `grid` on purpose (i.e, when needed).\n\t-- This is a __memory-safe__ option, in case your dealing with some tight memory constraints.\n\t-- Defaults to __false__ when omitted.\n  -- @treturn grid a new `grid` instance\n\t-- @usage\n\t-- -- A simple 3x3 grid\n\t-- local myGrid = Grid:new({{0,0,0},{0,0,0},{0,0,0}})\n\t--\n\t-- -- A memory-safe 3x3 grid\n\t-- myGrid = Grid('000\\n000\\n000', true)\n  function Grid:new(map, cacheNodeAtRuntime)\n\t\tif type(map) == 'string' then\n\t\t\tassert(Assert.isStrMap(map), 'Wrong argument #1. Not a valid string map')\n\t\t\tmap = Utils.strToMap(map)\n\t\tend\n    assert(Assert.isMap(map),('Bad argument #1. Not a valid map'))\n    assert(Assert.isBool(cacheNodeAtRuntime) or Assert.isNil(cacheNodeAtRuntime),\n      ('Bad argument #2. Expected \\'boolean\\', got %s.'):format(type(cacheNodeAtRuntime)))\n    if cacheNodeAtRuntime then\n      return PostProcessGrid:new(map,walkable)\n    end\n    return PreProcessGrid:new(map,walkable)\n  end\n\n  --- Checks if `node` at [x,y] is __walkable__.\n\t-- Will check if `node` at location [x,y] both *exists* on the collision map and *is walkable*\n  -- @class function\n  -- @tparam int x the x-location of the node\n  -- @tparam int y the y-location of the node\n  -- @tparam[opt] string|int|func walkable the value for walkable locations in the collision map array (see @{Grid:new}).\n\t-- Defaults to __false__ when omitted.\n  -- If this parameter is a function, it should be prototyped as __f(value)__ and return a `boolean`:\n  -- __true__ when value matches a __walkable__ `node`, __false__ otherwise. If this parameter is not given\n  -- while location [x,y] __is valid__, this actual function returns __true__.\n  -- @tparam[optchain] int clearance the amount of clearance needed. Defaults to 1 (normal clearance) when not given.\n  -- @treturn bool __true__ if `node` exists and is __walkable__, __false__ otherwise\n\t-- @usage\n\t-- -- Always true\n\t-- print(myGrid:isWalkableAt(2,3))\n\t--\n\t-- -- True if node at [2,3] collision map value is 0\n\t-- print(myGrid:isWalkableAt(2,3,0))\n\t--\n\t-- -- True if node at [2,3] collision map value is 0 and has a clearance higher or equal to 2\n\t-- print(myGrid:isWalkableAt(2,3,0,2))\n\t--\n  function Grid:isWalkableAt(x, y, walkable, clearance)\n    local nodeValue = self._map[y] and self._map[y][x]\n    if nodeValue then\n      if not walkable then return true end\n    else\n\t\t\treturn false\n    end\n\t\tlocal hasEnoughClearance = not clearance and true or false\n\t\tif not hasEnoughClearance then\n\t\t\tif not self._isAnnotated[walkable] then return false end\n\t\t\tlocal node = self:getNodeAt(x,y)\n\t\t\tlocal nodeClearance = node:getClearance(walkable)\n\t\t\thasEnoughClearance = (nodeClearance >= clearance)\n\t\tend\n    if self._eval then\n\t\t\treturn walkable(nodeValue) and hasEnoughClearance\n\t\tend\n    return ((nodeValue == walkable) and hasEnoughClearance)\n  end\n\n  --- Returns the `grid` width.\n  -- @class function\n  -- @treturn int the `grid` width\n\t-- @usage print(myGrid:getWidth())\n  function Grid:getWidth()\n    return self._width\n  end\n\n  --- Returns the `grid` height.\n  -- @class function\n  -- @treturn int the `grid` height\n\t-- @usage print(myGrid:getHeight())\n  function Grid:getHeight()\n     return self._height\n  end\n\n  --- Returns the collision map.\n  -- @class function\n  -- @treturn map the collision map (see @{Grid:new})\n\t-- @usage local map = myGrid:getMap()\n  function Grid:getMap()\n    return self._map\n  end\n\n  --- Returns the set of nodes.\n  -- @class function\n  -- @treturn {{node,...},...} an array of nodes\n\t-- @usage local nodes = myGrid:getNodes()\n  function Grid:getNodes()\n    return self._nodes\n  end\n\n  --- Returns the `grid` bounds. Returned values corresponds to the upper-left\n\t-- and lower-right coordinates (in tile units) of the actual `grid` instance.\n  -- @class function\n  -- @treturn int the upper-left corner x-coordinate\n  -- @treturn int the upper-left corner y-coordinate\n  -- @treturn int the lower-right corner x-coordinate\n  -- @treturn int the lower-right corner y-coordinate\n\t-- @usage local left_x, left_y, right_x, right_y = myGrid:getBounds()\n\tfunction Grid:getBounds()\n\t\treturn self._min_x, self._min_y,self._max_x, self._max_y\n\tend\n\n  --- Returns neighbours. The returned value is an array of __walkable__ nodes neighbouring a given `node`.\n  -- @class function\n  -- @tparam node node a given `node`\n  -- @tparam[opt] string|int|func walkable the value for walkable locations in the collision map array (see @{Grid:new}).\n\t-- Defaults to __false__ when omitted.\n  -- @tparam[optchain] bool allowDiagonal when __true__, allows adjacent nodes are included (8-neighbours).\n\t-- Defaults to __false__ when omitted.\n  -- @tparam[optchain] bool tunnel When __true__, allows the `pathfinder` to tunnel through walls when heading diagonally.\n  -- @tparam[optchain] int clearance When given, will prune for the neighbours set all nodes having a clearance value lower than the passed-in value\n\t-- Defaults to __false__ when omitted.\n  -- @treturn {node,...} an array of nodes neighbouring a given node\n\t-- @usage\n\t-- local aNode = myGrid:getNodeAt(5,6)\n\t-- local neighbours = myGrid:getNeighbours(aNode, 0, true)\n  function Grid:getNeighbours(node, walkable, allowDiagonal, tunnel, clearance)\n\t\tlocal neighbours = {}\n    for i = 1,#straightOffsets do\n      local n = self:getNodeAt(\n        node._x + straightOffsets[i].x,\n        node._y + straightOffsets[i].y\n      )\n      if n and self:isWalkableAt(n._x, n._y, walkable, clearance) then\n        neighbours[#neighbours+1] = n\n      end\n    end\n\n    if not allowDiagonal then return neighbours end\n\n\t\ttunnel = not not tunnel\n    for i = 1,#diagonalOffsets do\n      local n = self:getNodeAt(\n        node._x + diagonalOffsets[i].x,\n        node._y + diagonalOffsets[i].y\n      )\n      if n and self:isWalkableAt(n._x, n._y, walkable, clearance) then\n\t\t\t\tif tunnel then\n\t\t\t\t\tneighbours[#neighbours+1] = n\n\t\t\t\telse\n\t\t\t\t\tlocal skipThisNode = false\n\t\t\t\t\tlocal n1 = self:getNodeAt(node._x+diagonalOffsets[i].x, node._y)\n\t\t\t\t\tlocal n2 = self:getNodeAt(node._x, node._y+diagonalOffsets[i].y)\n\t\t\t\t\tif ((n1 and n2) and not self:isWalkableAt(n1._x, n1._y, walkable, clearance) and not self:isWalkableAt(n2._x, n2._y, walkable, clearance)) then\n\t\t\t\t\t\tskipThisNode = true\n\t\t\t\t\tend\n\t\t\t\t\tif not skipThisNode then neighbours[#neighbours+1] = n end\n\t\t\t\tend\n      end\n    end\n\n    return neighbours\n  end\n\n  --- Grid iterator. Iterates on every single node\n  -- in the `grid`. Passing __lx, ly, ex, ey__ arguments will iterate\n  -- only on nodes inside the bounding-rectangle delimited by those given coordinates.\n  -- @class function\n  -- @tparam[opt] int lx the leftmost x-coordinate of the rectangle. Default to the `grid` leftmost x-coordinate (see @{Grid:getBounds}).\n  -- @tparam[optchain] int ly the topmost y-coordinate of the rectangle. Default to the `grid` topmost y-coordinate (see @{Grid:getBounds}).\n  -- @tparam[optchain] int ex the rightmost x-coordinate of the rectangle. Default to the `grid` rightmost x-coordinate (see @{Grid:getBounds}).\n  -- @tparam[optchain] int ey the bottom-most y-coordinate of the rectangle. Default to the `grid` bottom-most y-coordinate (see @{Grid:getBounds}).\n  -- @treturn node a `node` on the collision map, upon each iteration step\n  -- @treturn int the iteration count\n\t-- @usage\n\t-- for node, count in myGrid:iter() do\n\t--   print(node:getX(), node:getY(), count)\n\t-- end\n  function Grid:iter(lx,ly,ex,ey)\n    local min_x = lx or self._min_x\n    local min_y = ly or self._min_y\n    local max_x = ex or self._max_x\n    local max_y = ey or self._max_y\n\n    local x, y\n    y = min_y\n    return function()\n      x = not x and min_x or x+1\n      if x > max_x then\n        x = min_x\n        y = y+1\n      end\n      if y > max_y then\n        y = nil\n      end\n      return self._nodes[y] and self._nodes[y][x] or self:getNodeAt(x,y)\n    end\n  end\n\n\t--- Grid iterator. Iterates on each node along the outline (border) of a squared area\n\t-- centered on the given node.\n\t-- @tparam node node a given `node`\n\t-- @tparam[opt] int radius the area radius (half-length). Defaults to __1__ when not given.\n\t-- @treturn node a `node` at each iteration step\n\t-- @usage\n\t-- for node in myGrid:around(node, 2) do\n\t--   ...\n\t-- end\n\tfunction Grid:around(node, radius)\n\t\tlocal x, y = node._x, node._y\n\t\tradius = radius or 1\n\t\tlocal _around = Utils.around()\n\t\tlocal _nodes = {}\n\t\trepeat\n\t\t\tlocal state, x, y = coroutine.resume(_around,x,y,radius)\n\t\t\tlocal nodeAt = state and self:getNodeAt(x, y)\n\t\t\tif nodeAt then _nodes[#_nodes+1] = nodeAt end\n\t\tuntil (not state)\n\t\tlocal _i = 0\n\t\treturn function()\n\t\t\t_i = _i+1\n\t\t\treturn _nodes[_i]\n\t\tend\n\tend\n\n  --- Each transformation. Calls the given function on each `node` in the `grid`,\n\t-- passing the `node` as the first argument to function __f__.\n  -- @class function\n  -- @tparam func f a function prototyped as __f(node,...)__\n  -- @tparam[opt] vararg ... args to be passed to function __f__\n\t-- @treturn grid self (the calling `grid` itself, can be chained)\n\t-- @usage\n\t-- local function printNode(node)\n\t--   print(node:getX(), node:getY())\n\t-- end\n\t-- myGrid:each(printNode)\n  function Grid:each(f,...)\n    for node in self:iter() do f(node,...) end\n\t\treturn self\n  end\n\n  --- Each (in range) transformation. Calls a function on each `node` in the range of a rectangle of cells,\n\t-- passing the `node` as the first argument to function __f__.\n  -- @class function\n  -- @tparam int lx the leftmost x-coordinate coordinate of the rectangle\n  -- @tparam int ly the topmost y-coordinate of the rectangle\n  -- @tparam int ex the rightmost x-coordinate of the rectangle\n  -- @tparam int ey the bottom-most y-coordinate of the rectangle\n  -- @tparam func f a function prototyped as __f(node,...)__\n  -- @tparam[opt] vararg ... args to be passed to function __f__\n\t-- @treturn grid self (the calling `grid` itself, can be chained)\n\t-- @usage\n\t-- local function printNode(node)\n\t--   print(node:getX(), node:getY())\n\t-- end\n\t-- myGrid:eachRange(1,1,8,8,printNode)\n  function Grid:eachRange(lx,ly,ex,ey,f,...)\n    for node in self:iter(lx,ly,ex,ey) do f(node,...) end\n\t\treturn self\n  end\n\n  --- Map transformation.\n\t-- Calls function __f(node,...)__ on each `node` in a given range, passing the `node` as the first arg to function __f__ and replaces\n\t-- it with the returned value. Therefore, the function should return a `node`.\n  -- @class function\n  -- @tparam func f a function prototyped as __f(node,...)__\n  -- @tparam[opt] vararg ... args to be passed to function __f__\n\t-- @treturn grid self (the calling `grid` itself, can be chained)\n\t-- @usage\n\t-- local function nothing(node)\n\t--   return node\n\t-- end\n\t-- myGrid:imap(nothing)\n  function Grid:imap(f,...)\n    for node in self:iter() do\n      node = f(node,...)\n    end\n\t\treturn self\n  end\n\n  --- Map in range transformation.\n\t-- Calls function __f(node,...)__ on each `node` in a rectangle range, passing the `node` as the first argument to the function and replaces\n\t-- it with the returned value. Therefore, the function should return a `node`.\n\t-- @class function\n  -- @tparam int lx the leftmost x-coordinate coordinate of the rectangle\n  -- @tparam int ly the topmost y-coordinate of the rectangle\n  -- @tparam int ex the rightmost x-coordinate of the rectangle\n  -- @tparam int ey the bottom-most y-coordinate of the rectangle\n  -- @tparam func f a function prototyped as __f(node,...)__\n  -- @tparam[opt] vararg ... args to be passed to function __f__\n\t-- @treturn grid self (the calling `grid` itself, can be chained)\n\t-- @usage\n\t-- local function nothing(node)\n\t--   return node\n\t-- end\n\t-- myGrid:imap(1,1,6,6,nothing)\n  function Grid:imapRange(lx,ly,ex,ey,f,...)\n    for node in self:iter(lx,ly,ex,ey) do\n      node = f(node,...)\n    end\n\t\treturn self\n  end\n\n  -- Specialized grids\n  -- Inits a preprocessed grid\n  function PreProcessGrid:new(map)\n    local newGrid = {}\n    newGrid._map = map\n    newGrid._nodes, newGrid._min_x, newGrid._max_x, newGrid._min_y, newGrid._max_y = Utils.arrayToNodes(newGrid._map)\n    newGrid._width = (newGrid._max_x-newGrid._min_x)+1\n    newGrid._height = (newGrid._max_y-newGrid._min_y)+1\n\t\tnewGrid._isAnnotated = {}\n    return setmetatable(newGrid,PreProcessGrid)\n  end\n\n  -- Inits a postprocessed grid\n  function PostProcessGrid:new(map)\n    local newGrid = {}\n    newGrid._map = map\n    newGrid._nodes = {}\n    newGrid._min_x, newGrid._max_x, newGrid._min_y, newGrid._max_y = Utils.getArrayBounds(newGrid._map)\n    newGrid._width = (newGrid._max_x-newGrid._min_x)+1\n    newGrid._height = (newGrid._max_y-newGrid._min_y)+1\n\t\tnewGrid._isAnnotated = {}\t\t\n    return setmetatable(newGrid,PostProcessGrid)\n  end\n\n  --- Returns the `node` at location [x,y].\n  -- @class function\n  -- @name Grid:getNodeAt\n  -- @tparam int x the x-coordinate coordinate\n  -- @tparam int y the y-coordinate coordinate\n  -- @treturn node a `node`\n\t-- @usage local aNode = myGrid:getNodeAt(2,2)\n\n  -- Gets the node at location <x,y> on a preprocessed grid\n  function PreProcessGrid:getNodeAt(x,y)\n    return self._nodes[y] and self._nodes[y][x] or nil\n  end\n\n  -- Gets the node at location <x,y> on a postprocessed grid\n  function PostProcessGrid:getNodeAt(x,y)\n    if not x or not y then return end\n    if Utils.outOfRange(x,self._min_x,self._max_x) then return end\n    if Utils.outOfRange(y,self._min_y,self._max_y) then return end\n    if not self._nodes[y] then self._nodes[y] = {} end\n    if not self._nodes[y][x] then self._nodes[y][x] = Node:new(x,y) end\n    return self._nodes[y][x]\n  end\n\n  return setmetatable(Grid,{\n    __call = function(self,...)\n      return self:new(...)\n    end\n  })\n\nend\n"
  },
  {
    "path": "jumper/pathfinder.lua",
    "content": "--- The Pathfinder class\n\n--\n-- Implementation of the `pathfinder` class.\n\nlocal _VERSION = \"\"\nlocal _RELEASEDATE = \"\"\n\nif (...) then\n\n  -- Dependencies\n  local _PATH = (...):gsub('%.pathfinder$','')\n\tlocal Utils     = require (_PATH .. '.core.utils')\n\tlocal Assert    = require (_PATH .. '.core.assert')\n  local Heap      = require (_PATH .. '.core.bheap')\n  local Heuristic = require (_PATH .. '.core.heuristics')\n  local Grid      = require (_PATH .. '.grid')\n  local Path      = require (_PATH .. '.core.path')\n\n  -- Internalization\n  local t_insert, t_remove = table.insert, table.remove\n\tlocal floor = math.floor\n  local pairs = pairs\n  local assert = assert\n\tlocal type = type\n  local setmetatable, getmetatable = setmetatable, getmetatable\n\n\t--- Finders (search algorithms implemented). Refers to the search algorithms actually implemented in Jumper.\n\t--\n\t-- <li>[A*](http://en.wikipedia.org/wiki/A*_search_algorithm)</li>\n\t-- <li>[Dijkstra](http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)</li>\n\t-- <li>[Theta Astar](http://aigamedev.com/open/tutorials/theta-star-any-angle-paths/)</li>\n\t-- <li>[BFS](http://en.wikipedia.org/wiki/Breadth-first_search)</li>\n\t-- <li>[DFS](http://en.wikipedia.org/wiki/Depth-first_search)</li>\n\t-- <li>[JPS](http://harablog.wordpress.com/2011/09/07/jump-point-search/)</li>\n\t-- @finder Finders\n\t-- @see Pathfinder:getFinders\n  local Finders = {\n    ['ASTAR']     = require (_PATH .. '.search.astar'),\n    ['DIJKSTRA']  = require (_PATH .. '.search.dijkstra'),\n    ['THETASTAR'] = require (_PATH .. '.search.thetastar'),\n    ['BFS']       = require (_PATH .. '.search.bfs'),\n    ['DFS']       = require (_PATH .. '.search.dfs'),\n    ['JPS']       = require (_PATH .. '.search.jps')\n  }\n\n  -- Will keep track of all nodes expanded during the search\n  -- to easily reset their properties for the next pathfinding call\n  local toClear = {}\n\n\t--- Search modes. Refers to the search modes. In ORTHOGONAL mode, 4-directions are only possible when moving,\n\t-- including North, East, West, South. In DIAGONAL mode, 8-directions are possible when moving,\n\t-- including North, East, West, South and adjacent directions.\n\t--\n\t-- <li>ORTHOGONAL</li>\n\t-- <li>DIAGONAL</li>\n\t-- @mode Modes\n\t-- @see Pathfinder:getModes\n  local searchModes = {['DIAGONAL'] = true, ['ORTHOGONAL'] = true}\n\n  -- Performs a traceback from the goal node to the start node\n  -- Only happens when the path was found\n\n\t--- The `Pathfinder` class.<br/>\n\t-- This class is callable.\n\t-- Therefore,_ <code>Pathfinder(...)</code> _acts as a shortcut to_ <code>Pathfinder:new(...)</code>.\n\t-- @type Pathfinder\n  local Pathfinder = {}\n  Pathfinder.__index = Pathfinder\n\n  --- Inits a new `pathfinder`\n  -- @class function\n  -- @tparam grid grid a `grid`\n  -- @tparam[opt] string finderName the name of the `Finder` (search algorithm) to be used for search.\n\t-- Defaults to `ASTAR` when not given (see @{Pathfinder:getFinders}).\n  -- @tparam[optchain] string|int|func walkable the value for __walkable__ nodes.\n  -- If this parameter is a function, it should be prototyped as __f(value)__, returning a boolean:\n  -- __true__ when value matches a __walkable__ `node`, __false__ otherwise.\n  -- @treturn pathfinder a new `pathfinder` instance\n\t-- @usage\n\t-- -- Example one\n\t-- local finder = Pathfinder:new(myGrid, 'ASTAR', 0)\n\t--\n\t-- -- Example two\n\t-- local function walkable(value)\n\t--   return value > 0\n\t-- end\n\t-- local finder = Pathfinder(myGrid, 'JPS', walkable)\n  function Pathfinder:new(grid, finderName, walkable)\n    local newPathfinder = {}\n    setmetatable(newPathfinder, Pathfinder)\n\t  newPathfinder:setGrid(grid)\n    newPathfinder:setFinder(finderName)\n    newPathfinder:setWalkable(walkable)\n    newPathfinder:setMode('DIAGONAL')\n    newPathfinder:setHeuristic('MANHATTAN')\n    newPathfinder:setTunnelling(false)\n    return newPathfinder\n  end\n\n\t--- Evaluates [clearance](http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric)\n\t-- for the whole `grid`. It should be called only once, unless the collision map or the\n\t-- __walkable__ attribute changes. The clearance values are calculated and cached within the grid nodes.\n  -- @class function\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n\t-- @usage myFinder:annotateGrid()\n\tfunction Pathfinder:annotateGrid()\n\t\tassert(self._walkable, 'Finder must implement a walkable value')\n\t\tfor x=self._grid._max_x,self._grid._min_x,-1 do\n\t\t\tfor y=self._grid._max_y,self._grid._min_y,-1 do\n\t\t\t\tlocal node = self._grid:getNodeAt(x,y)\n\t\t\t\tif self._grid:isWalkableAt(x,y,self._walkable) then\n\t\t\t\t\tlocal nr = self._grid:getNodeAt(node._x+1, node._y)\n\t\t\t\t\tlocal nrd = self._grid:getNodeAt(node._x+1, node._y+1)\n\t\t\t\t\tlocal nd = self._grid:getNodeAt(node._x, node._y+1)\n\t\t\t\t\tif nr and nrd and nd then\n\t\t\t\t\t\tlocal m = nrd._clearance[self._walkable] or 0\n\t\t\t\t\t\tm = (nd._clearance[self._walkable] or 0)<m and (nd._clearance[self._walkable] or 0) or m\n\t\t\t\t\t\tm = (nr._clearance[self._walkable] or 0)<m and (nr._clearance[self._walkable] or 0) or m\n\t\t\t\t\t\tnode._clearance[self._walkable] = m+1\n\t\t\t\t\telse\n\t\t\t\t\t\tnode._clearance[self._walkable] = 1\n\t\t\t\t\tend\n\t\t\t\telse node._clearance[self._walkable] = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tself._grid._isAnnotated[self._walkable] = true\n\t\treturn self\n\tend\n\n\t--- Removes [clearance](http://aigamedev.com/open/tutorial/clearance-based-pathfinding/#TheTrueClearanceMetric)values.\n\t-- Clears cached clearance values for the current __walkable__.\n  -- @class function\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n\t-- @usage myFinder:clearAnnotations()\n\tfunction Pathfinder:clearAnnotations()\n\t\tassert(self._walkable, 'Finder must implement a walkable value')\n\t\tfor node in self._grid:iter() do\n\t\t\tnode:removeClearance(self._walkable)\n\t\tend\n\t\tself._grid._isAnnotated[self._walkable] = false\n\t\treturn self\n\tend\n\n  --- Sets the `grid`. Defines the given `grid` as the one on which the `pathfinder` will perform the search.\n  -- @class function\n  -- @tparam grid grid a `grid`\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n\t-- @usage myFinder:setGrid(myGrid)\n  function Pathfinder:setGrid(grid)\n    assert(Assert.inherits(grid, Grid), 'Wrong argument #1. Expected a \\'grid\\' object')\n    self._grid = grid\n    self._grid._eval = self._walkable and type(self._walkable) == 'function'\n    return self\n  end\n\n  --- Returns the `grid`. This is a reference to the actual `grid` used by the `pathfinder`.\n  -- @class function\n  -- @treturn grid the `grid`\n\t-- @usage local myGrid = myFinder:getGrid()\n  function Pathfinder:getGrid()\n    return self._grid\n  end\n\n  --- Sets the __walkable__ value or function.\n  -- @class function\n  -- @tparam string|int|func walkable the value for walkable nodes.\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n\t-- @usage\n\t-- -- Value '0' is walkable\n\t-- myFinder:setWalkable(0)\n\t--\n\t-- -- Any value greater than 0 is walkable\n\t-- myFinder:setWalkable(function(n)\n\t--   return n>0\n\t-- end\n  function Pathfinder:setWalkable(walkable)\n    assert(Assert.matchType(walkable,'stringintfunctionnil'),\n      ('Wrong argument #1. Expected \\'string\\', \\'number\\' or \\'function\\', got %s.'):format(type(walkable)))\n    self._walkable = walkable\n    self._grid._eval = type(self._walkable) == 'function'\n    return self\n  end\n\n  --- Gets the __walkable__ value or function.\n  -- @class function\n  -- @treturn string|int|func the `walkable` value or function\n\t-- @usage local walkable = myFinder:getWalkable()\n  function Pathfinder:getWalkable()\n    return self._walkable\n  end\n\n  --- Defines the `finder`. It refers to the search algorithm used by the `pathfinder`.\n  -- Default finder is `ASTAR`. Use @{Pathfinder:getFinders} to get the list of available finders.\n  -- @class function\n  -- @tparam string finderName the name of the `finder` to be used for further searches.\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n\t-- @usage\n\t-- --To use Breadth-First-Search\n\t-- myFinder:setFinder('BFS')\n\t-- @see Pathfinder:getFinders\n  function Pathfinder:setFinder(finderName)\n\t\tif not finderName then\n\t\t\tif not self._finder then\n\t\t\t\tfinderName = 'ASTAR'\n\t\t\telse return\n\t\t\tend\n\t\tend\n    assert(Finders[finderName],'Not a valid finder name!')\n    self._finder = finderName\n    return self\n  end\n\n  --- Returns the name of the `finder` being used.\n  -- @class function\n  -- @treturn string the name of the `finder` to be used for further searches.\n\t-- @usage local finderName = myFinder:getFinder()\n  function Pathfinder:getFinder()\n    return self._finder\n  end\n\n  --- Returns the list of all available finders names.\n  -- @class function\n  -- @treturn {string,...} array of built-in finders names.\n\t-- @usage\n\t-- local finders = myFinder:getFinders()\n\t-- for i, finderName in ipairs(finders) do\n\t--   print(i, finderName)\n\t-- end\n  function Pathfinder:getFinders()\n    return Utils.getKeys(Finders)\n  end\n\n  --- Sets a heuristic. This is a function internally used by the `pathfinder` to find the optimal path during a search.\n  -- Use @{Pathfinder:getHeuristics} to get the list of all available `heuristics`. One can also define\n  -- his own `heuristic` function.\n  -- @class function\n  -- @tparam func|string heuristic `heuristic` function, prototyped as __f(dx,dy)__ or as a `string`.\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n  -- @see Pathfinder:getHeuristics\n\t-- @see core.heuristics\n\t-- @usage myFinder:setHeuristic('MANHATTAN')\n  function Pathfinder:setHeuristic(heuristic)\n    assert(Heuristic[heuristic] or (type(heuristic) == 'function'),'Not a valid heuristic!')\n    self._heuristic = Heuristic[heuristic] or heuristic\n    return self\n  end\n\n  --- Returns the `heuristic` used. Returns the function itself.\n  -- @class function\n  -- @treturn func the `heuristic` function being used by the `pathfinder`\n\t-- @see core.heuristics\n\t-- @usage local h = myFinder:getHeuristic()\n  function Pathfinder:getHeuristic()\n    return self._heuristic\n  end\n\n  --- Gets the list of all available `heuristics`.\n  -- @class function\n  -- @treturn {string,...} array of heuristic names.\n\t-- @see core.heuristics\n\t-- @usage\n\t-- local heur = myFinder:getHeuristic()\n\t-- for i, heuristicName in ipairs(heur) do\n\t--   ...\n\t-- end\n  function Pathfinder:getHeuristics()\n    return Utils.getKeys(Heuristic)\n  end\n\n  --- Defines the search `mode`.\n  -- The default search mode is the `DIAGONAL` mode, which implies 8-possible directions when moving (north, south, east, west and diagonals).\n  -- In `ORTHOGONAL` mode, only 4-directions are allowed (north, south, east and west).\n  -- Use @{Pathfinder:getModes} to get the list of all available search modes.\n  -- @class function\n  -- @tparam string mode the new search `mode`.\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n  -- @see Pathfinder:getModes\n\t-- @see Modes\n\t-- @usage myFinder:setMode('ORTHOGONAL')\n  function Pathfinder:setMode(mode)\n    assert(searchModes[mode],'Invalid mode')\n    self._allowDiagonal = (mode == 'DIAGONAL')\n    return self\n  end\n\n  --- Returns the search mode.\n  -- @class function\n  -- @treturn string the current search mode\n\t-- @see Modes\n\t-- @usage local mode = myFinder:getMode()\n  function Pathfinder:getMode()\n    return (self._allowDiagonal and 'DIAGONAL' or 'ORTHOGONAL')\n  end\n\n  --- Gets the list of all available search modes.\n  -- @class function\n  -- @treturn {string,...} array of search modes.\n\t-- @see Modes\n\t-- @usage local modes = myFinder:getModes()\n\t-- for modeName in ipairs(modes) do\n\t--   ...\n\t-- end\n  function Pathfinder:getModes()\n    return Utils.getKeys(searchModes)\n  end\n\n  --- Enables tunnelling. Defines the ability for the `pathfinder` to tunnel through walls when heading diagonally.\n\t-- This feature __is not compatible__ with Jump Point Search algorithm (i.e. enabling it will not affect Jump Point Search)\n  -- @class function\n  -- @tparam bool bool a boolean\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n\t-- @usage myFinder:setTunnelling(true)\n  function Pathfinder:setTunnelling(bool)\n    assert(Assert.isBool(bool), ('Wrong argument #1. Expected boolean, got %s'):format(type(bool)))\n\t\tself._tunnel = bool\n\t\treturn self\n  end\n\n  --- Returns tunnelling feature state.\n  -- @class function\n\t-- @treturn bool tunnelling feature actual state\n\t-- @usage local isTunnellingEnabled = myFinder:getTunnelling()\n  function Pathfinder:getTunnelling()\n\t\treturn self._tunnel\n  end\n\n  --- Calculates a `path`. Returns the `path` from location __[startX, startY]__ to location __[endX, endY]__.\n  -- Both locations must exist on the collision map. The starting location can be unwalkable.\n  -- @class function\n  -- @tparam int startX the x-coordinate for the starting location\n  -- @tparam int startY the y-coordinate for the starting location\n  -- @tparam int endX the x-coordinate for the goal location\n  -- @tparam int endY the y-coordinate for the goal location\n  -- @tparam int clearance the amount of clearance (i.e the pathing agent size) to consider\n  -- @treturn path a path (array of nodes) when found, otherwise nil\n\t-- @usage local path = myFinder:getPath(1,1,5,5)\n  function Pathfinder:getPath(startX, startY, endX, endY, clearance)\n\t\tself:reset()\n    local startNode = self._grid:getNodeAt(startX, startY)\n    local endNode = self._grid:getNodeAt(endX, endY)\n    assert(startNode, ('Invalid location [%d, %d]'):format(startX, startY))\n    assert(endNode and self._grid:isWalkableAt(endX, endY),\n      ('Invalid or unreachable location [%d, %d]'):format(endX, endY))\n    local _endNode = Finders[self._finder](self, startNode, endNode, clearance, toClear)\n    if _endNode then\n\t\t\treturn Utils.traceBackPath(self, _endNode, startNode)\n    end\n    return nil\n  end\n\n  --- Resets the `pathfinder`. This function is called internally between successive pathfinding calls, so you should not\n\t-- use it explicitely, unless under specific circumstances.\n  -- @class function\n\t-- @treturn pathfinder self (the calling `pathfinder` itself, can be chained)\n\t-- @usage local path, len = myFinder:getPath(1,1,5,5)\n\tfunction Pathfinder:reset()\n    for node in pairs(toClear) do node:reset() end\n    toClear = {}\n\t\treturn self\n\tend\n\n\n  -- Returns Pathfinder class\n\tPathfinder._VERSION = _VERSION\n\tPathfinder._RELEASEDATE = _RELEASEDATE\n  return setmetatable(Pathfinder,{\n    __call = function(self,...)\n      return self:new(...)\n    end\n  })\n\nend\n"
  },
  {
    "path": "jumper/search/astar.lua",
    "content": "-- Astar algorithm\n-- This actual implementation of A-star is based on\n-- [Nash A. & al. pseudocode](http://aigamedev.com/open/tutorials/theta-star-any-angle-paths/)\n\nif (...) then\n\n\t-- Internalization\n\tlocal ipairs = ipairs\n\tlocal huge = math.huge\n\n\t-- Dependancies\n\tlocal _PATH = (...):match('(.+)%.search.astar$')\n\tlocal Heuristics = require (_PATH .. '.core.heuristics')\n\tlocal Heap = require (_PATH.. '.core.bheap')\n\n\t-- Updates G-cost\n\tlocal function computeCost(node, neighbour, finder, clearance)\n\t\tlocal mCost = Heuristics.EUCLIDIAN(neighbour, node)\n\t\tif node._g + mCost < neighbour._g then\n\t\t\tneighbour._parent = node\n\t\t\tneighbour._g = node._g + mCost\n\t\tend\n\tend\n\n\t-- Updates vertex node-neighbour\n\tlocal function updateVertex(finder, openList, node, neighbour, endNode, clearance, heuristic, overrideCostEval)\n\t\tlocal oldG = neighbour._g\n\t\tlocal cmpCost = overrideCostEval or computeCost\n\t\tcmpCost(node, neighbour, finder, clearance)\n\t\tif neighbour._g < oldG then\n\t\t\tlocal nClearance = neighbour._clearance[finder._walkable]\n\t\t\tlocal pushThisNode = clearance and nClearance and (nClearance >= clearance)\n\t\t\tif (clearance and pushThisNode) or (not clearance) then\n\t\t\t\tif neighbour._opened then neighbour._opened = false end\t\t\t\t\n\t\t\t\tneighbour._h = heuristic(endNode, neighbour)\n\t\t\t\tneighbour._f = neighbour._g + neighbour._h\n\t\t\t\topenList:push(neighbour)\n\t\t\t\tneighbour._opened = true\n\t\t\tend\n\t\tend\n\tend\n\n  -- Calculates a path.\n  -- Returns the path from location `<startX, startY>` to location `<endX, endY>`.\n  return function (finder, startNode, endNode, clearance, toClear, overrideHeuristic, overrideCostEval)\n\t\t\n\t\tlocal heuristic = overrideHeuristic or finder._heuristic\n\t\tlocal openList = Heap()\n\t\tstartNode._g = 0\n\t\tstartNode._h = heuristic(endNode, startNode)\n\t\tstartNode._f = startNode._g + startNode._h\n\t\topenList:push(startNode)\n\t\ttoClear[startNode] = true\n\t\tstartNode._opened = true\n\n\t\twhile not openList:empty() do\n\t\t\tlocal node = openList:pop()\n\t\t\tnode._closed = true\n\t\t\tif node == endNode then return node end\n\t\t\tlocal neighbours = finder._grid:getNeighbours(node, finder._walkable, finder._allowDiagonal, finder._tunnel)\n\t\t\tfor i = 1,#neighbours do\n\t\t\t\tlocal neighbour = neighbours[i]\n\t\t\t\tif not neighbour._closed then\n\t\t\t\t\ttoClear[neighbour] = true\n\t\t\t\t\tif not neighbour._opened then\n\t\t\t\t\t\tneighbour._g = huge\n\t\t\t\t\t\tneighbour._parent = nil\t\n\t\t\t\t\tend\n\t\t\t\t\tupdateVertex(finder, openList, node, neighbour, endNode, clearance, heuristic, overrideCostEval)\n\t\t\t\tend\t\n\t\t\tend\t\n\t\tend\n\t\t\n\t\treturn nil \n\tend\n\nend\n"
  },
  {
    "path": "jumper/search/bfs.lua",
    "content": "-- Breadth-First search algorithm\n\nif (...) then\n  -- Internalization\n  local t_remove = table.remove\n\n  local function breadth_first_search(finder, openList, node, endNode, clearance, toClear)\n    local neighbours = finder._grid:getNeighbours(node, finder._walkable, finder._allowDiagonal, finder._tunnel)\n    for i = 1,#neighbours do\n      local neighbour = neighbours[i]\n      if not neighbour._closed and not neighbour._opened then\n\t\t\t\tlocal nClearance = neighbour._clearance[finder._walkable]\n\t\t\t\tlocal pushThisNode = clearance and nClearance and (nClearance >= clearance)\t\t\t\n        if (clearance and pushThisNode) or (not clearance) then\n\t\t\t\t\topenList[#openList+1] = neighbour\n\t\t\t\t\tneighbour._opened = true\n\t\t\t\t\tneighbour._parent = node\n\t\t\t\t\ttoClear[neighbour] = true\n\t\t\t\tend\n      end\n    end\n\n  end\n\n  -- Calculates a path.\n  -- Returns the path from location `<startX, startY>` to location `<endX, endY>`.\n  return function (finder, startNode, endNode, clearance, toClear)\n\n    local openList = {} -- We'll use a FIFO queue (simple array)\n    openList[1] = startNode\n    startNode._opened = true\n    toClear[startNode] = true\n\n    local node\n    while (#openList > 0) do\n      node = openList[1]\n      t_remove(openList,1)\n      node._closed = true\n      if node == endNode then return node end\n      breadth_first_search(finder, openList, node, endNode, clearance, toClear)\n    end\n\n    return nil\n  end\n\nend"
  },
  {
    "path": "jumper/search/dfs.lua",
    "content": "-- Depth-First search algorithm.\n\nif (...) then\n  -- Internalization\n  local t_remove = table.remove\n\n  local function depth_first_search(finder, openList, node, endNode, clearance, toClear)\n    local neighbours = finder._grid:getNeighbours(node, finder._walkable, finder._allowDiagonal, finder._tunnel)\n    for i = 1,#neighbours do\n      local neighbour = neighbours[i]\n      if (not neighbour._closed and not neighbour._opened) then\n\t\t\t\tlocal nClearance = neighbour._clearance[finder._walkable]\n\t\t\t\tlocal pushThisNode = clearance and nClearance and (nClearance >= clearance)\n\t\t\t\tif (clearance and pushThisNode) or (not clearance) then\t\t\t\n\t\t\t\t\topenList[#openList+1] = neighbour\n\t\t\t\t\tneighbour._opened = true\n\t\t\t\t\tneighbour._parent = node\n\t\t\t\t\ttoClear[neighbour] = true\n\t\t\t\tend\n      end\n    end\n\n  end\n\n  -- Calculates a path.\n  -- Returns the path from location `<startX, startY>` to location `<endX, endY>`.\n  return function (finder, startNode, endNode, clearance, toClear)\n\n    local openList = {} -- We'll use a LIFO queue (simple array)\n    openList[1] = startNode\n    startNode._opened = true\n    toClear[startNode] = true\n\n    local node\n    while (#openList > 0) do\n      node = openList[#openList]\n      t_remove(openList)\n      node._closed = true\n      if node == endNode then return node end\n      depth_first_search(finder, openList, node, endNode, clearance, toClear)\n    end\n\n    return nil\n  end\n\nend"
  },
  {
    "path": "jumper/search/dijkstra.lua",
    "content": "-- Dijkstra algorithm (Uses Astar implementation)\n\nif (...) then\n\n  local astar_search = require ((...):gsub('%.dijkstra$','.astar'))\n  -- Dijkstra is similar to aStar, with no heuristic\n  local dijkstraHeuristic = function() return 0 end\n\n  -- Calculates a path.\n  -- Returns the path from location `<startX, startY>` to location `<endX, endY>`.\n  return function (finder, startNode, endNode, clearance, toClear)\n    return astar_search(finder, startNode, endNode, clearance, toClear, dijkstraHeuristic)\n  end\n\nend"
  },
  {
    "path": "jumper/search/jps.lua",
    "content": "-- Jump Point search algorithm\n\nif (...) then\n\n  -- Dependancies\n  local _PATH = (...):match('(.+)%.search.jps$')\n  local Heuristics = require (_PATH .. '.core.heuristics')\n\tlocal Heap = require (_PATH.. '.core.bheap')\n\n  -- Internalization\n  local max, abs = math.max, math.abs\n\n  -- Local helpers, these routines will stay private\n  -- As they are internally used by the public interface\n\n  -- Resets properties of nodes expanded during a search\n  -- This is a lot faster than resetting all nodes\n  -- between consecutive pathfinding requests\n\n  --[[\n    Looks for the neighbours of a given node.\n    Returns its natural neighbours plus forced neighbours when the given\n    node has no parent (generally occurs with the starting node).\n    Otherwise, based on the direction of move from the parent, returns\n    neighbours while pruning directions which will lead to symmetric paths.\n\n    In case diagonal moves are forbidden, when the given node has no\n    parent, we return straight neighbours (up, down, left and right).\n    Otherwise, we add left and right node (perpendicular to the direction\n    of move) in the neighbours list.\n  --]]\n  local function findNeighbours(finder, node, clearance)\n\n    if node._parent then\n      local neighbours = {}\n      local x,y = node._x, node._y\n      -- Node have a parent, we will prune some neighbours\n      -- Gets the direction of move\n      local dx = (x-node._parent._x)/max(abs(x-node._parent._x),1)\n      local dy = (y-node._parent._y)/max(abs(y-node._parent._y),1)\n\n        -- Diagonal move case\n      if dx~=0 and dy~=0 then\n        local walkY, walkX\n\n        -- Natural neighbours\n        if finder._grid:isWalkableAt(x,y+dy,finder._walkable, clearance) then\n          neighbours[#neighbours+1] = finder._grid:getNodeAt(x,y+dy)\n          walkY = true\n        end\n        if finder._grid:isWalkableAt(x+dx,y,finder._walkable, clearance) then\n          neighbours[#neighbours+1] = finder._grid:getNodeAt(x+dx,y)\n          walkX = true\n        end\n        if walkX or walkY then\n          neighbours[#neighbours+1] = finder._grid:getNodeAt(x+dx,y+dy)\n        end\n\n        -- Forced neighbours\n        if (not finder._grid:isWalkableAt(x-dx,y,finder._walkable, clearance)) and walkY then\n          neighbours[#neighbours+1] = finder._grid:getNodeAt(x-dx,y+dy)\n        end\n        if (not finder._grid:isWalkableAt(x,y-dy,finder._walkable, clearance)) and walkX then\n          neighbours[#neighbours+1] = finder._grid:getNodeAt(x+dx,y-dy)\n        end\n\n      else\n        -- Move along Y-axis case\n        if dx==0 then\n          local walkY\n          if finder._grid:isWalkableAt(x,y+dy,finder._walkable, clearance) then\n            neighbours[#neighbours+1] = finder._grid:getNodeAt(x,y+dy)\n\n            -- Forced neighbours are left and right ahead along Y\n            if (not finder._grid:isWalkableAt(x+1,y,finder._walkable, clearance)) then\n              neighbours[#neighbours+1] = finder._grid:getNodeAt(x+1,y+dy)\n            end\n            if (not finder._grid:isWalkableAt(x-1,y,finder._walkable, clearance)) then\n              neighbours[#neighbours+1] = finder._grid:getNodeAt(x-1,y+dy)\n            end\n          end\n          -- In case diagonal moves are forbidden : Needs to be optimized\n          if not finder._allowDiagonal then\n            if finder._grid:isWalkableAt(x+1,y,finder._walkable, clearance) then\n              neighbours[#neighbours+1] = finder._grid:getNodeAt(x+1,y)\n            end\n            if finder._grid:isWalkableAt(x-1,y,finder._walkable, clearance)\n              then neighbours[#neighbours+1] = finder._grid:getNodeAt(x-1,y)\n            end\n          end\n        else\n        -- Move along X-axis case\n          if finder._grid:isWalkableAt(x+dx,y,finder._walkable, clearance) then\n            neighbours[#neighbours+1] = finder._grid:getNodeAt(x+dx,y)\n\n            -- Forced neighbours are up and down ahead along X\n            if (not finder._grid:isWalkableAt(x,y+1,finder._walkable, clearance)) then\n              neighbours[#neighbours+1] = finder._grid:getNodeAt(x+dx,y+1)\n            end\n            if (not finder._grid:isWalkableAt(x,y-1,finder._walkable, clearance)) then\n              neighbours[#neighbours+1] = finder._grid:getNodeAt(x+dx,y-1)\n            end\n          end\n          -- : In case diagonal moves are forbidden\n          if not finder._allowDiagonal then\n            if finder._grid:isWalkableAt(x,y+1,finder._walkable, clearance) then\n              neighbours[#neighbours+1] = finder._grid:getNodeAt(x,y+1)\n            end\n            if finder._grid:isWalkableAt(x,y-1,finder._walkable, clearance) then\n              neighbours[#neighbours+1] = finder._grid:getNodeAt(x,y-1)\n            end\n          end\n        end\n      end\n      return neighbours\n    end\n\n    -- Node do not have parent, we return all neighbouring nodes\n    return finder._grid:getNeighbours(node, finder._walkable, finder._allowDiagonal, finder._tunnel, clearance)\n  end\n\n  --[[\n    Searches for a jump point (or a turning point) in a specific direction.\n    This is a generic translation of the algorithm 2 in the paper:\n      http://users.cecs.anu.edu.au/~dharabor/data/papers/harabor-grastien-aaai11.pdf\n    The current expanded node is a jump point if near a forced node\n\n    In case diagonal moves are forbidden, when lateral nodes (perpendicular to\n    the direction of moves are walkable, we force them to be turning points in other\n    to perform a straight move.\n  --]]\n  local function jump(finder, node, parent, endNode, clearance)\n\tif not node then return end\n\n    local x,y = node._x, node._y\n    local dx, dy = x - parent._x,y - parent._y\n\n    -- If the node to be examined is unwalkable, return nil\n    if not finder._grid:isWalkableAt(x,y,finder._walkable, clearance) then return end\n\t\t\n    -- If the node to be examined is the endNode, return this node\n    if node == endNode then return node end\n    -- Diagonal search case\n    if dx~=0 and dy~=0 then\n      -- Current node is a jump point if one of his leftside/rightside neighbours ahead is forced\n      if (finder._grid:isWalkableAt(x-dx,y+dy,finder._walkable, clearance) and (not finder._grid:isWalkableAt(x-dx,y,finder._walkable, clearance))) or\n         (finder._grid:isWalkableAt(x+dx,y-dy,finder._walkable, clearance) and (not finder._grid:isWalkableAt(x,y-dy,finder._walkable, clearance))) then\n        return node\n      end\n    else\n      -- Search along X-axis case\n      if dx~=0 then\n        if finder._allowDiagonal then\n          -- Current node is a jump point if one of his upside/downside neighbours is forced\n          if (finder._grid:isWalkableAt(x+dx,y+1,finder._walkable, clearance) and (not finder._grid:isWalkableAt(x,y+1,finder._walkable, clearance))) or\n             (finder._grid:isWalkableAt(x+dx,y-1,finder._walkable, clearance) and (not finder._grid:isWalkableAt(x,y-1,finder._walkable, clearance))) then\n            return node\n          end\n        else\n          -- : in case diagonal moves are forbidden\n          if finder._grid:isWalkableAt(x+1,y,finder._walkable, clearance) or finder._grid:isWalkableAt(x-1,y,finder._walkable, clearance) then return node end\n        end\n      else\n      -- Search along Y-axis case\n        -- Current node is a jump point if one of his leftside/rightside neighbours is forced\n        if finder._allowDiagonal then\n          if (finder._grid:isWalkableAt(x+1,y+dy,finder._walkable, clearance) and (not finder._grid:isWalkableAt(x+1,y,finder._walkable, clearance))) or\n             (finder._grid:isWalkableAt(x-1,y+dy,finder._walkable, clearance) and (not finder._grid:isWalkableAt(x-1,y,finder._walkable, clearance))) then\n            return node\n          end\n        else\n          -- : in case diagonal moves are forbidden\n          if finder._grid:isWalkableAt(x,y+1,finder._walkable, clearance) or finder._grid:isWalkableAt(x,y-1,finder._walkable, clearance) then return node end\n        end\n      end\n    end\n\n    -- Recursive horizontal/vertical search\n    if dx~=0 and dy~=0 then\n      if jump(finder,finder._grid:getNodeAt(x+dx,y),node,endNode, clearance) then return node end\n      if jump(finder,finder._grid:getNodeAt(x,y+dy),node,endNode, clearance) then return node end\n    end\n\n    -- Recursive diagonal search\n    if finder._allowDiagonal then\n      if finder._grid:isWalkableAt(x+dx,y,finder._walkable, clearance) or finder._grid:isWalkableAt(x,y+dy,finder._walkable, clearance) then\n        return jump(finder,finder._grid:getNodeAt(x+dx,y+dy),node,endNode, clearance)\n      end\n    end\nend\n\n  --[[\n    Searches for successors of a given node in the direction of each of its neighbours.\n    This is a generic translation of the algorithm 1 in the paper:\n      http://users.cecs.anu.edu.au/~dharabor/data/papers/harabor-grastien-aaai11.pdf\n\n    Also, we notice that processing neighbours in a reverse order producing a natural\n    looking path, as the pathfinder tends to keep heading in the same direction.\n    In case a jump point was found, and this node happened to be diagonal to the\n    node currently expanded in a straight mode search, we skip this jump point.\n  --]]\n  local function identifySuccessors(finder, openList, node, endNode, clearance, toClear)\n\n    -- Gets the valid neighbours of the given node\n    -- Looks for a jump point in the direction of each neighbour\n    local neighbours = findNeighbours(finder,node, clearance)\n    for i = #neighbours,1,-1 do\n\n      local skip = false\n      local neighbour = neighbours[i]\n      local jumpNode = jump(finder,neighbour,node,endNode, clearance)\n\t\t\n      -- : in case a diagonal jump point was found in straight mode, skip it.\n      if jumpNode and not finder._allowDiagonal then\n        if ((jumpNode._x ~= node._x) and (jumpNode._y ~= node._y)) then skip = true end\n      end\n\t\t\n      -- Performs regular A-star on a set of jump points\n      if jumpNode and not skip then\n        -- Update the jump node and move it in the closed list if it wasn't there\n        if not jumpNode._closed then\t\t\t\n\t\t\t\t\tlocal extraG = Heuristics.EUCLIDIAN(jumpNode, node)\n\t\t\t\t\tlocal newG = node._g + extraG\n\t\t\t\t\tif not jumpNode._opened or newG < jumpNode._g then\n\t\t\t\t\t\ttoClear[jumpNode] = true -- Records this node to reset its properties later.\n\t\t\t\t\t\tjumpNode._g = newG\n\t\t\t\t\t\tjumpNode._h = jumpNode._h or\n\t\t\t\t\t\t\t(finder._heuristic(jumpNode, endNode))\n\t\t\t\t\t\tjumpNode._f = jumpNode._g+jumpNode._h\n\t\t\t\t\t\tjumpNode._parent = node\n\t\t\t\t\t\tif not jumpNode._opened then\n\t\t\t\t\t\t\topenList:push(jumpNode)\n\t\t\t\t\t\t\tjumpNode._opened = true\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\topenList:heapify(jumpNode)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\t\t\t\t\t\n\t\t\t\tend\n      end\n    end\n  end\n\n  -- Calculates a path.\n  -- Returns the path from location `<startX, startY>` to location `<endX, endY>`.\n  return function(finder, startNode, endNode, clearance, toClear)\n\n    startNode._g, startNode._f, startNode._h = 0,0,0\n\t\tlocal openList = Heap()\n    openList:push(startNode)\n    startNode._opened = true\n    toClear[startNode] = true\n\n    local node\n    while not openList:empty() do\n      -- Pops the lowest F-cost node, moves it in the closed list\n      node = openList:pop()\n      node._closed = true\n        -- If the popped node is the endNode, return it\n        if node == endNode then\n          return node\n        end\n      -- otherwise, identify successors of the popped node\n      identifySuccessors(finder, openList, node, endNode, clearance, toClear)\n    end\n\n    -- No path found, return nil\n    return nil\n  end\n\nend"
  },
  {
    "path": "jumper/search/thetastar.lua",
    "content": "-- ThetaStar implementation\n-- See: http://aigamedev.com/open/tutorials/theta-star-any-angle-paths for reference\n\nif (...) then\n\t\n\tlocal _PATH = (...):gsub('%.search.thetastar$','')\n\n\t-- Depandancies\n\tlocal Heuristics   = require (_PATH .. '.core.heuristics')\n\tlocal astar_search = require (_PATH .. '.search.astar')\n\n\t-- Internalization\n\tlocal ipairs = ipairs\n\tlocal huge, abs = math._huge, math.abs\n\t\n\t-- Line Of Sight (Bresenham's line marching algorithm)\n\t-- http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm\n\tlocal lineOfSight = function (node, neighbour, finder, clearance)\n\t\tlocal x0, y0 = node._x, node._y\n\t\tlocal x1, y1 = neighbour._x, neighbour._y\n\t\tlocal dx = abs(x1-x0)\n\t\tlocal dy = abs(y1-y0)\n\t\tlocal err = dx - dy\n\t\tlocal sx = (x0 < x1) and 1 or -1\n\t\tlocal sy = (y0 < y1) and 1 or -1\t\t\n\n\t\twhile true do\n\t\t\tif not finder._grid:isWalkableAt(x0, y0, finder._walkable, finder._tunnel, clearance) then \n\t\t\t\treturn false \n\t\t\tend\n\t\t\tif x0 == x1 and y0 == y1 then\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tlocal e2 = 2*err\n\t\t\tif e2 > -dy then\n\t\t\t\terr = err - dy\n\t\t\t\tx0 = x0 + sx\n\t\t\tend\n\t\t\tif e2 < dx then\n\t\t\t\terr = err + dx\n\t\t\t\ty0 = y0 + sy\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend\n\t\n\t-- Theta star cost evaluation\n\tlocal function computeCost(node, neighbour, finder, clearance)\n\t\tlocal parent = node._parent or node\n\t\tlocal mpCost = Heuristics.EUCLIDIAN(neighbour, parent)\n\t\tif lineOfSight(parent, neighbour, finder, clearance) then\n\t\t\tif parent._g + mpCost < neighbour._g then\n\t\t\t\tneighbour._parent = parent\n\t\t\t\tneighbour._g = parent._g + mpCost\n\t\t\tend\n\t\telse\n\t\t\tlocal mCost = Heuristics.EUCLIDIAN(neighbour, node)\n\t\t\tif node._g + mCost < neighbour._g then\n\t\t\t\tneighbour._parent = node\n\t\t\t\tneighbour._g = node._g + mCost\n\t\t\tend\n\t\tend\n\tend\n\n  -- Calculates a path.\n  -- Returns the path from location `<startX, startY>` to location `<endX, endY>`.\n  return function (finder, startNode, endNode, clearance, toClear, overrideHeuristic)\n    return astar_search(finder, startNode, endNode, clearance, toClear, overrideHeuristic, computeCost)\n\tend\n\nend"
  },
  {
    "path": "rockspecs/jumper-1.6-2.rockspec",
    "content": "package = \"jumper\"\nversion = \"1.6-2\"\nsource = {\n   url = \"https://github.com/Yonaba/Jumper/archive/jumper-1.6-2.tar.gz\",\n   dir = \"Jumper-jumper-1.6-2\"\n}\ndescription = {\n   summary = \"Fast and easy-to-use pathfinding library for 2D grid-bases games\",\n   detailed = [[\n      Jumper is a pathfinding library designed for uniform-cost 2D grid-based games. It features a mix of A-Star, Jump Point Search\n\t  and Binary-Heaps. It aims to be fast and lightweight. It also features a clean public interface with chaining features \n\t  which makes it very friendly and easy to use.\n   ]],\n   homepage = \"http://github.com/Yonaba/Jumper\",\n   license = \"MIT <http://www.opensource.org/licenses/mit-license.php>\"\n}\ndependencies = {\n   \"lua >= 5.1\"\n}\nbuild = {\n  type = \"builtin\",\n  modules = {\n    [\"init\"] = \"init.lua\",\n    [\"jumper\"] = \"jumper.lua\",\n    [\"core.bheap\"] = \"core/bheap.lua\",\n    [\"core.grid\"] = \"core/grid.lua\",\n    [\"core.heuristics\"] = \"core/heuristics.lua\",\n    [\"core.node\"] = \"core/node.lua\"\n  }\n}"
  },
  {
    "path": "rockspecs/jumper-1.6.3-1.rockspec",
    "content": "package = \"jumper\"\nversion = \"1.6.3-1\"\nsource = {\n   url = \"https://github.com/Yonaba/Jumper/archive/jumper-1.6.3-1.tar.gz\",\n   dir = \"Jumper-jumper-1.6.3-1\"\n}\ndescription = {\n   summary = \"Fast and easy-to-use pathfinding library for 2D grid-bases games\",\n   detailed = [[\n      Jumper is a pathfinding library designed for uniform-cost 2D grid-based games. It features a mix of A-Star, Jump Point Search\n\t  and Binary-Heaps. It aims to be fast and lightweight. It also features a clean public interface with chaining features \n\t  which makes it very friendly and easy to use.\n   ]],\n   homepage = \"http://github.com/Yonaba/Jumper\",\n   license = \"MIT <http://www.opensource.org/licenses/mit-license.php>\"\n}\ndependencies = {\n   \"lua >= 5.1\"\n}\nbuild = {\n  type = \"builtin\",\n  modules = {\n    [\"init\"] = \"init.lua\",\n    [\"jumper\"] = \"jumper.lua\",\n    [\"core.bheap\"] = \"core/bheap.lua\",\n    [\"core.grid\"] = \"core/grid.lua\",\n    [\"core.heuristics\"] = \"core/heuristics.lua\",\n    [\"core.node\"] = \"core/node.lua\"\n  }\n}"
  },
  {
    "path": "rockspecs/jumper-1.7.0-1.rockspec",
    "content": "package = \"jumper\"\nversion = \"1.7.0-1\"\nsource = {\n   url = \"https://github.com/Yonaba/Jumper/archive/jumper-1.7.0-1.tar.gz\",\n   dir = \"Jumper-jumper-1.7.0-1\"\n}\ndescription = {\n   summary = \"Fast and easy-to-use pathfinding library for 2D grid-based games\",\n   detailed = [[\n      Jumper is a pathfinding library designed for 2D grid-based games.\n      It aims to be fast and lightweight. It also features a clean public interface with chaining features \n      which makes it very friendly and easy to use.\n   ]],\n   homepage = \"http://github.com/Yonaba/Jumper\",\n   license = \"MIT <http://www.opensource.org/licenses/mit-license.php>\",\n   maintainer = \"Roland Yonaba <roland.yonaba@gmail.com>\",\n}\ndependencies = {\n   \"lua >= 5.1\"\n}\nbuild = {\n   type = \"builtin\",\n   modules = {\n      [\"jumper.init\"] = \"jumper/init.lua\",\n      [\"jumper.pathfinder\"] = \"jumper/pathfinder.lua\",\n      [\"jumper.core.bheap\"] = \"jumper/core/bheap.lua\",\n      [\"jumper.core.grid\"] = \"jumper/core/grid.lua\",\n      [\"jumper.core.heuristics\"] = \"jumper/core/heuristics.lua\",\n      [\"jumper.core.node\"] = \"jumper/core/node.lua\",\n      [\"jumper.search.astar\"] = \"jumper/search/astar.lua\",\n      [\"jumper.search.jps\"] = \"jumper/search/jps.lua\",\n   },\n   copy_directories = {\"docs\"}\n}\n"
  },
  {
    "path": "rockspecs/jumper-1.8.0.rockspec",
    "content": "package = \"jumper\"\nversion = \"1.8.0\"\nsource = {\n   url = \"https://github.com/Yonaba/Jumper/archive/jumper-1.8.0.tar.gz\",\n   dir = \"Jumper-jumper-1.8.0\"\n}\ndescription = {\n   summary = \"Fast and easy-to-use pathfinding library for grid-based games\",\n   detailed = [[\n      Jumper is a pathfinding library designed for grid-based games.\n      It aims to be fast and lightweight. It also features wide range of search algorithms, \n\t  a clean public interface with chaining features  which makes it very friendly and easy to use.\n   ]],\n   homepage = \"http://github.com/Yonaba/Jumper\",\n   license = \"MIT <http://www.opensource.org/licenses/mit-license.php>\",\n   maintainer = \"Roland Yonaba <roland.yonaba@gmail.com>\",\n}\ndependencies = {\n   \"lua >= 5.1\"\n}\nbuild = {\n   type = \"builtin\",\n   modules = {\n      [\"jumper.grid\"] = \"jumper/grid.lua\",\n      [\"jumper.pathfinder\"] = \"jumper/pathfinder.lua\",\n      [\"jumper.core.bheap\"] = \"jumper/core/bheap.lua\",\n      [\"jumper.core.heuristics\"] = \"jumper/core/heuristics.lua\",\n      [\"jumper.core.node\"] = \"jumper/core/node.lua\",\n      [\"jumper.core.path\"] = \"jumper/core/path.lua\",\n      [\"jumper.search.astar\"] = \"jumper/search/astar.lua\",\n      [\"jumper.search.jps\"] = \"jumper/search/jps.lua\",\n      [\"jumper.search.dijkstra\"] = \"jumper/search/dijkstra.lua\",\n      [\"jumper.search.bfs\"] = \"jumper/search/bfs.lua\",\n      [\"jumper.search.dfs\"] = \"jumper/search/dfs.lua\",\n   },\n   copy_directories = {\"docs\"}\n}\n"
  },
  {
    "path": "rockspecs/jumper-1.8.1-1.rockspec",
    "content": "package = \"jumper\"\nversion = \"1.8.1-1\"\nsource = {\n   url = \"https://github.com/Yonaba/Jumper/archive/jumper-1.8.1-1.tar.gz\",\n   dir = \"Jumper-jumper-1.8.1-1\"\n}\ndescription = {\n   summary = \"Fast and easy-to-use pathfinding library for grid-based games\",\n   detailed = [[\n      Jumper is a pathfinding library designed for grid-based games.\n      It aims to be fast and lightweight. It also features wide range of search algorithms, \n\t  a clean public interface with chaining features  which makes it very friendly and easy to use.\n   ]],\n   homepage = \"http://github.com/Yonaba/Jumper\",\n   license = \"MIT <http://www.opensource.org/licenses/mit-license.php>\",\n   maintainer = \"Roland Yonaba <roland.yonaba@gmail.com>\",\n}\ndependencies = {\n   \"lua >= 5.1\"\n}\nbuild = {\n   type = \"builtin\",\n   modules = {\n      [\"jumper.grid\"] = \"jumper/grid.lua\",\n      [\"jumper.pathfinder\"] = \"jumper/pathfinder.lua\",\n      [\"jumper.core.bheap\"] = \"jumper/core/bheap.lua\",\n      [\"jumper.core.heuristics\"] = \"jumper/core/heuristics.lua\",\n      [\"jumper.core.node\"] = \"jumper/core/node.lua\",\n      [\"jumper.core.path\"] = \"jumper/core/path.lua\",\n      [\"jumper.search.astar\"] = \"jumper/search/astar.lua\",\n      [\"jumper.search.jps\"] = \"jumper/search/jps.lua\",\n      [\"jumper.search.dijkstra\"] = \"jumper/search/dijkstra.lua\",\n      [\"jumper.search.bfs\"] = \"jumper/search/bfs.lua\",\n      [\"jumper.search.dfs\"] = \"jumper/search/dfs.lua\",\n   },\n   copy_directories = {\"docs\",\"specs\"}\n}\n"
  },
  {
    "path": "specs/bheap_specs.lua",
    "content": "context('Module BHeap', function()\t\n\tlocal BHeap \n\t\n\tbefore(function()\n\t\tBHeap = require ('jumper.core.bheap')\n\tend)\n\t\n\tcontext('BHeap class', function()\n\t\n\t\ttest('BHeap() instantiates a new heap object', function()\n\t\t\tassert_equal(getmetatable(BHeap()), BHeap)\n\t\tend)\n\t\t\n\t\ttest('the new heap is empty', function()\n\t\t\tassert_true((BHeap()):empty())\n\t\tend)\n\t\t\n\t\ttest('items can be pushed inside', function()\n\t\t\tlocal h = BHeap()\n\t\t\th:push(1):push(2):push(3)\n\t\t\tassert_equal(h._size, 3)\n\t\tend)\n\t\t\n\t\ttest('popping returns the lowest element by default (< operator)', function()\n\t\t\tlocal h = BHeap()\n\t\t\th:push(1):push(2):push(0)\n\t\t\t\n\t\t\tassert_equal(h:pop(),0)\n\t\t\tassert_equal(h:pop(),1)\n\t\t\tassert_equal(h:pop(),2)\n\t\t\tassert_nil(h:pop())\n\t\tend)\n\t\t\n\t\ttest('a heap can be cleared', function()\n\t\t\tlocal h = BHeap()\n\t\t\tassert_true(h:empty())\n\t\t\t\n\t\t\th:push(1):push(2):push(3)\n\t\t\tassert_false(h:empty())\n\t\t\t\n\t\t\th:clear()\n\t\t\tassert_true(h:empty())\t\t\t\n\t\tend)\n\t\t\n\t\ttest('one can define a custom sort function', function()\n\t\t\tlocal sort = function(a,b) return a>b end\n\t\t\tlocal h = BHeap(sort)\n\t\t\th:push(1):push(2):push(3)\n\t\t\t\n\t\t\tassert_equal(h:pop(),3)\n\t\t\tassert_equal(h:pop(),2)\n\t\t\tassert_equal(h:pop(),1)\n\t\t\tassert_nil(h:pop())\n\t\tend)\t\t\n\n\t\ttest('items pushed can be objects, with a custom sort function', function()\n\t\t\tlocal sortNode = function(a, b) return a.cost < b.cost end\n\t\t\tlocal makeObj = function(cost) return {cost = cost} end\n\t\t\tlocal h = BHeap(sortNode)\n\t\t\th:push(makeObj(1)):push(makeObj(2)):push(makeObj(3))\n\t\t\t\n\t\t\tassert_equal(h:pop().cost,1)\n\t\t\tassert_equal(h:pop().cost,2)\n\t\t\tassert_equal(h:pop().cost,3)\n\t\t\tassert_nil(h:pop())\t\t\t\t\t\n\t\tend)\n\t\t\n\t\ttest('pushing a alue that cannot be compared to the previous ones raises an error', function()\n\t\t\tlocal h = BHeap()\n\t\t\th:push(false)\n\t\t\tassert_error(pcall(h.push, h, false))\n\t\t\tassert_error(pcall(h.push, h, true))\t\t\n\t\t\tassert_error(pcall(h.push, h, {}))\t\t\n\t\t\tassert_error(pcall(h.push, h, function() end))\t\t\n\t\tend)\n\t\t\n\t\ttest('pushing nil does nothing', function()\n\t\t\tlocal h = BHeap()\n\t\t\th:push()\n\t\t\t\n\t\t\tassert_true(h:empty())\n\t\t\th:push(1):push()\n\t\t\t\n\t\t\tassert_false(h:empty())\n\t\t\tassert_equal(h._size,1)\n\t\tend)\n\t\t\n\t\ttest('popping an empty heap returns nil', function()\n\t\t\tlocal h = BHeap()\n\t\t\tassert_nil(h:pop())\t\t\n\t\tend)\n\t\t\n\t\ttest('BHeap:heapify() forces a sort of the heap', function()\n\t\t\n\t\t\tlocal h = BHeap()\n\t\t\tlocal sort = function(a,b) return a.value < b.value end\n\t\t\tlocal function makeObj(v) return {value = v} end\n\t\t\tlocal h = BHeap(sort)\n\t\t\tlocal A, B, C = makeObj(1), makeObj(2), makeObj(3)\n\t\t\t\n\t\t\th:push(A):push(B):push(C)\n\t\t\tC.value = 0\n\t\t\th:heapify(C)\n\t\t\t\n\t\t\tlocal ret = h:pop()\n\t\t\tassert_true(ret == C)\n\t\t\tassert_equal(ret.value,0)\n\t\t\t\n\t\t\tlocal ret = h:pop()\n\t\t\tassert_true(ret == A)\n\t\t\tassert_equal(ret.value,1)\n\n\t\t\tlocal ret = h:pop()\n\t\t\tassert_true(ret == B)\n\t\t\tassert_equal(ret.value,2)\n\t\t\t\n\t\t\th:push(A):push(B):push(C)\n\t\t\tC.value, B.value, A.value = 3, 2, 100\n\t\t\th:heapify()\n\n\t\t\tlocal ret = h:pop()\n\t\t\tassert_true(ret == B)\n\t\t\tassert_equal(ret.value,2)\n\t\t\t\n\t\t\tlocal ret = h:pop()\n\t\t\tassert_true(ret == C)\n\t\t\tassert_equal(ret.value,3)\n\n\t\t\tlocal ret = h:pop()\n\t\t\tassert_true(ret == A)\n\t\t\tassert_equal(ret.value,100)\n\t\t\n\t\tend)\n\t\t\n\t\t\n\tend)\n\t\nend)"
  },
  {
    "path": "specs/grid_specs.lua",
    "content": "context('Module Grid', function()\n\tlocal Grid, Node\n\t\n\tbefore(function()\n\t\tGrid = require ('jumper.grid')\n\t\tNode = require ('jumper.core.node')\n  end)\n\t\n  context('Grid:new() or Grid() returns a new Grid object', function()\n\t\t\n\t\ttest('Grid:new() or Grid() returns a new Grid object', function()\n\t\t\tassert_equal(getmetatable(getmetatable(Grid:new({{0}}))),Grid)\n\t\t\tassert_equal(getmetatable(getmetatable(Grid({{0}}))),Grid)\n\t\tend)\n\t\t\t\n\t\ttest('Grid:new() requires a collision map upon initialization', function()\n\t\t\tlocal map = {{0,0},{0,0}}\n\t\t\tassert_not_nil(Grid:new(map))\n\t\tend)\n\t\t\t\n\t\ttest('The passed-in map can be a string', function()\n\t\t\tlocal map = '00\\n00'\n\t\t\tassert_not_nil(Grid:new(map))\n\t\tend)\n\t\t\t\n\t\ttest('passing nil to Grid:new() or Grid() causes an error', function()\n\t\t\tassert_error(pcall(Grid, Grid))\n\t\t\tassert_error(pcall(Grid.new, Grid))\n\t\tend)\t\t\t\n\t\t\t\n\t\ttest('Grid and map should have the same width', function()\n\t\t\tlocal map = '00\\n00'\n\t\t\tlocal map = {{0,0},{0,0}}\n\t\t\tlocal grid = Grid(map)\n\t\t\tlocal grid2 = Grid(map)\n\t\t\tassert_equal(grid:getWidth(), 2)\n\t\t\tassert_equal(grid2:getWidth(), 2)\t\n\t\tend)\t\n\t\t\n\t\ttest('Grid and map should have the same height', function()\n\t\t\tlocal map = '00\\n00\\n00'\n\t\t\tlocal map2 = {{0,0},{0,0},{0,0},{0,0}}\n\t\t\tlocal grid = Grid(map)\n\t\t\tlocal grid2 = Grid(map2)\n\t\t\tassert_equal(grid:getHeight(), 3)\n\t\t\tassert_equal(grid2:getHeight(), 4)\t\n\t\tend)\n\t\t\n\t\ttest('Grid:getBounds() returns the grid corners coordinates', function()\n\t\t\tlocal map = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}\n\t\t\tlocal grid = Grid(map)\n\t\t\tlocal lx,ly,rx,ry = grid:getBounds()\n\t\t\tassert_equal(lx,1)\n\t\t\tassert_equal(ly,1)\n\t\t\tassert_equal(rx,3)\n\t\t\tassert_equal(ry,4)\n\t\t\t\n\t\t\tlocal map = {}\n\t\t\tfor y = 0,2 do map[y] = {}\n\t\t\t\tfor x = 0,2 do map[y][x] = 0 end\n\t\t\tend\n\t\t\tgrid = Grid(map)\n\t\t\tlocal lx,ly,rx,ry = grid:getBounds()\n\t\t\tassert_equal(lx,0)\n\t\t\tassert_equal(ly,0)\n\t\t\tassert_equal(rx,2)\n\t\t\tassert_equal(ry,2)\t\t\t\n\t\tend)\n\t\t\n\t\ttest('Each value on the map matches a node on the grid', function()\n\t\t\tlocal map = {{0,0},{0,0},{0,0},{0,0}}\n\t\t\tlocal grid = Grid(map)\n\t\t\t\n\t\t\tfor y in pairs(map) do\n\t\t\t\tfor x in pairs(map[y]) do\n\t\t\t\t\tlocal node = grid:getNodeAt(x,y)\n\t\t\t\t\tassert_not_nil(node)\n\t\t\t\t\tassert_equal(getmetatable(node), Node)\n\t\t\t\tend\n\t\t\tend\n\t\tend)\n\t\t\n\t\ttest('the passed-in map should have a width greather than 0',function()\n\t\t\tassert_error(pcall(Grid, Grid, {{},{}}))\n\t\t\tassert_error(pcall(Grid, Grid, '\\n\\n'))\n\t\tend)\n\n\t\ttest('the passed-in map should have a height greather than 0',function()\n\t\t\tassert_error(pcall(Grid, Grid, {}))\n\t\t\tassert_error(pcall(Grid, Grid, ''))\n\t\tend)\n\t\t\n\t\ttest('the passed-in map should have rows with the same width',function()\n\t\t\tassert_error(pcall(Grid, Grid, {{0},{0,0}}))\n\t\t\tassert_error(pcall(Grid, Grid, '00\\n000'))\n\t\tend)\n\n\t\ttest('values in the map should only be integers or strings',function()\n\t\t\tassert_error(pcall(Grid, Grid, {{0.1,0,0},{0,0,0}}))\n\t\t\tassert_error(pcall(Grid, Grid, {{0,function() end,0},{0,0,0}}))\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Grid types', function()\n\t\t\n\t\ttest('passing a 2nd arg to Grid:new() or Grid() returns a safe-memory grid', function()\n\t\t\tlocal grid = Grid({{0}})\n\t\t\tlocal pgrid = Grid({{0}},true)\n\t\t\tassert_not_equal(getmetatable(grid), getmetatable(pgrid))\n\t\t\tassert_equal(getmetatable(getmetatable(grid)), getmetatable(getmetatable(pgrid)))\n\t\tend)\n\t\t\n\t\ttest('those grids are memory safe, as nodes are cached on purpose', function()\n\t\t\tlocal map = {{0,0,0},{0,0,0},{0,0,0}}\n\t\t\tlocal pgrid = Grid(map, true)\n\t\t\t\n\t\t\tassert_equal(#pgrid:getNodes(), 0)\n\t\t\tlocal count = 0\n\t\t\tfor node in pgrid:iter() do\n\t\t\t\tassert_equal(getmetatable(node), Node)\n\t\t\t\tcount = count+1\n\t\t\tend\n\t\t\tassert_equal(count, pgrid:getWidth()*pgrid:getHeight())\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Grid:isWalkablkeAt', function()\n\t\t\n\t\t\ttest('returns whether or not a node is walkable',function()\n\t\t\t\tlocal map = {{0,0},{0,0},{0,1},{0,0}}\n\t\t\t\tlocal grid = Grid(map)\t\t\t\n\t\t\t\tlocal walkable = 1\n\t\t\t\t\n\t\t\t\tfor y in pairs(map) do\n\t\t\t\t\tfor x in pairs(map[y]) do\n\t\t\t\t\t\tif map[y][x] == walkable then\n\t\t\t\t\t\t\tassert_true(grid:isWalkableAt(x,y,walkable))\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tassert_false(grid:isWalkableAt(x,y,walkable))\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tmap = 'WXW\\nWWW\\n'\n\t\t\t\tgrid = Grid(map)\t\t\t\n\t\t\t\twalkable = 'W'\n\t\t\t\t\n\t\t\t\tfor y = 1,2 do\n\t\t\t\t\tfor x = 1,3 do\n\t\t\t\t\t\tif x==2 and y==1 then\n\t\t\t\t\t\t\tassert_false(grid:isWalkableAt(x,y,walkable))\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tassert_true(grid:isWalkableAt(x,y,walkable))\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\tend)\n\n\t\t\ttest('All nodes are walkable when no walkability rule was set', function()\n\t\t\t\tlocal map = {{0,0},{0,0}}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\t\n\t\t\t\tfor y in pairs(map) do\n\t\t\t\t\tfor x in pairs(map[y]) do\n\t\t\t\t\t\tassert_true(grid:isWalkableAt(x,y,walkable))\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend)\n\t\n\tend)\n\t\t\n\tcontext('Grid:getMap()', function()\n\t\t\n\t\t\ttest('returns the collision map',function()\n\t\t\t\tlocal map = {{0,0},{0,0}}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tassert_equal(grid:getMap(), map)\n\t\t\tend)\n\t\t\n\t\t\ttest('returns the array parsed from a given string',function()\n\t\t\t\tlocal map = '00\\n00'\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tassert_equal(type(grid:getMap()), 'table')\n\t\t\t\tassert_not_equal(grid:getMap(), map)\n\t\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Grid:getNodeAt()', function()\n\t\t\tlocal map, grid\n\t\t\tbefore(function()\n\t\t\t\tmap = {\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t}\n\t\t\t\tgrid = Grid(map)\n      end)\n\t\t\t\n\t\t\ttest('returns the node at a given position', function()\n\t\t\t\tlocal node = grid:getNodeAt(1,1)\n\t\t\t\tassert_equal(getmetatable(node),Node)\n\t\t\t\tassert_equal(node._x,1)\n\t\t\t\tassert_equal(node._y,1)\n\t\t\tend)\n\t\t\t\n\t\t\ttest('returns nil if the node does not exist', function()\n\t\t\t\tassert_nil(grid:getNodeAt(0,0))\n\t\t\t\tassert_nil(grid:getNodeAt(5,1))\n\t\t\tend)\n\n\t\t\ttest('returns nil if one of its args is missing', function()\n\t\t\t\tassert_nil(grid:getNodeAt(0))\n\t\t\t\tassert_nil(grid:getNodeAt())\n\t\t\tend)\t\t\t\n\t\t\n\tend)\n\t\t\n\tcontext('Grid:getNodes()', function()\n\t\n\t\ttest('returns the array of nodes', function()\n\t\t\tlocal map = {{0,0},{0,0}}\n\t\t\tlocal grid = Grid(map)\n\t\t\tlocal nodes = grid:getNodes()\n\t\t\t\n\t\t\tassert_equal(type(nodes), 'table')\t\n\t\t\tfor y in pairs(nodes) do\n\t\t\t\tfor x in pairs(nodes[y]) do\n\t\t\t\t\tassert_equal(getmetatable(nodes[y][x]),Node)\n\t\t\t\tend\n\t\t\tend \n\t\tend)\n\t\n\tend)\n\t\n\tcontext('grid:getNeighbours()', function()\n\t\t\n\t\t\ttest('returns neighbours of a given node', function()\n\t\t\t\tlocal map = {{0,0},{0,0},}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal walkable = 0\n\t\t\t\tlocal node = grid:getNodeAt(1,1)\n\t\t\t\tlocal nb = grid:getNeighbours(node, walkable)\n\t\t\t\t\n\t\t\t\tassert_equal(type(nb), 'table')\n\t\t\t\tassert_equal(#nb, 2)\n\t\t\t\tassert_equal(nb[1], grid:getNodeAt(2,1))\n\t\t\t\tassert_equal(nb[2], grid:getNodeAt(1,2))\n\t\t\tend)\n\t\t\t\n\t\t\ttest('passing true as a third arg includes ajacent nodes', function()\n\t\t\t\tlocal map = {{0,0},{0,0},}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal walkable, allowDiag = 0, true\n\t\t\t\t\n\t\t\t\tlocal node = grid:getNodeAt(1,1)\n\t\t\t\tlocal nb = grid:getNeighbours(node, walkable, allowDiag)\n\t\t\t\t\n\t\t\t\tassert_equal(type(nb), 'table')\n\t\t\t\tassert_equal(#nb, 3)\n\t\t\t\tassert_equal(nb[1], grid:getNodeAt(2,1))\n\t\t\t\tassert_equal(nb[2], grid:getNodeAt(1,2))\n\t\t\t\tassert_equal(nb[3], grid:getNodeAt(2,2))\n\t\t\tend)\n\n\t\t\ttest('passing arg tunnel includes adjacent nodes that cannot be reached diagonnally', function()\n\t\t\t\tlocal map = {{0,0,0},{1,0,0},{0,2,0}}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal walkable, allowDiag, tunnel = 0, true, true\n\t\t\t\t\n\t\t\t\tlocal node = grid:getNodeAt(1,3)\n\t\t\t\tlocal nb = grid:getNeighbours(node, walkable, allowDiag, tunnel)\n\t\t\t\tassert_equal(type(nb), 'table')\n\t\t\t\tassert_equal(#nb, 1)\n\t\t\t\tassert_equal(nb[1], grid:getNodeAt(2,2))\t\t\t\t\n\t\t\tend)\n\t\t\t\n\tend)\n\t\t\n\tcontext('Grid:iter()', function()\n\t\t\t\n\t\t\ttest('iterates on all nodes in a grid', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tfor n in grid:iter() do\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\n\t\t\t\n\t\t\ttest('can iterate only on a rectangle of nodes', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tfor n in grid:iter(2,2,3,3) do\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\t\t\t\t\t\n\t\t\t\t\tassert_gte(n._x, 2)\n\t\t\t\t\tassert_gte(n._y, 2)\n\t\t\t\t\tassert_lte(n._x, 3)\n\t\t\t\t\tassert_lte(n._y, 3)\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\t\t\t\n\t\t\t\n\tend)\n\t\n\tcontext('Grid:around()', function()\n\t\t\t\n\t\t\ttest('iterates on nodes following a square outline pattern', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0},\n\t\t\t\t\t{0,0,0},\n\t\t\t\t\t{0,0,0}\n\t\t\t\t}\n\t\t\t\tlocal m = {{1,1},{2,1},{3,1},{3,2},{3,3},{2,3},{1,3},{1,2}}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tlocal i = 0\n\t\t\t\tfor n in grid:around(Node(2,2),1) do\n\t\t\t\t\ti = i + 1\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_equal(n._x, m[i][1])\n\t\t\t\t\tassert_equal(n._y, m[i][2])\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\n\t\t\t\n\t\t\ttest('arg spacing defaults to 1 when not given', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0},\n\t\t\t\t\t{0,0,0},\n\t\t\t\t\t{0,0,0}\n\t\t\t\t}\n\t\t\t\tlocal m = {{1,1},{2,1},{3,1},{3,2},{3,3},{2,3},{1,3},{1,2}}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tlocal i = 0\n\t\t\t\tfor n in grid:around(Node(2,2)) do\n\t\t\t\t\ti = i + 1\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_equal(n._x, m[i][1])\n\t\t\t\t\tassert_equal(n._y, m[i][2])\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\n\n\t\t\ttest('skips unexisting nodes', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0},\n\t\t\t\t\t{0,0,0},\n\t\t\t\t\t{0,0,0}\n\t\t\t\t}\n\t\t\t\tlocal m = {{2,1},{2,2},{1,2}}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tlocal i = 0\n\t\t\t\tfor n in grid:around(Node(1,1)) do\n\t\t\t\t\ti = i + 1\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_equal(n._x, m[i][1])\n\t\t\t\t\tassert_equal(n._y, m[i][2])\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\t\t\t\t\n\t\t\n\tend)\t\n\t\t\n\tcontext('Grid:each()', function()\n\t\t\t\n\t\t\ttest('calls a given function on each node in a grid', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tlocal function f(node,i) node.value = i end\n\t\t\t\tgrid:each(f, 3)\n\t\t\t\tfor n in grid:iter() do\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_equal(n.value,3)\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\n\t\t\n\tend)\n\t\t\n\tcontext('Grid:eachRange()', function()\n\t\t\t\n\t\t\ttest('calls a given function on each node in a range', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tlocal function f(node,i) node.value = i end\n\t\t\t\tgrid:eachRange(1,1,2,2,f,3)\n\t\t\t\tfor n in grid:iter() do\n\t\t\t\t\tif n._x <= 2 and n._y <= 2 then\n\t\t\t\t\t\tassert_equal(n.value,3)\n\t\t\t\t\telse\n\t\t\t\t\t\tassert_nil(n.value)\n\t\t\t\t\tend\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\n\t\t\n\tend)\t\t\n\t\t\n\tcontext('Grid:imap()', function()\n\t\t\t\n\t\t\ttest('Maps a given function on each node in a grid', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\n\t\t\t\tlocal function f(node,i) \n\t\t\t\t\tnode.v = i\n\t\t\t\t\treturn node\n\t\t\t\tend\n\t\t\t\tgrid:imap(f, 5)\n\t\t\t\tfor n in grid:iter() do\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_equal(n.v,5)\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\n\t\t\n\tend)\n\n\tcontext('Grid:imapRange()', function()\n\t\t\t\n\t\t\ttest('calls a given function on each node in a range', function()\n\t\t\t\tlocal map = {\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t\t{0,0,0,0},\n\t\t\t\t}\n\t\t\t\tlocal grid = Grid(map)\n\t\t\t\tlocal record = {}\t\t\t\t\n\t\t\t\tlocal function f(node,i) \n\t\t\t\t\tnode.v = i\n\t\t\t\t\treturn node\n\t\t\t\tend\n\t\t\t\tgrid:imapRange(3,3,4,4,f,7)\n\t\t\t\tfor n in grid:iter() do\n\t\t\t\t\tif n._x >= 3 and n._y >= 3 then\n\t\t\t\t\t\tassert_equal(n.v,7)\n\t\t\t\t\telse\n\t\t\t\t\t\tassert_nil(n.v)\n\t\t\t\t\tend\n\t\t\t\t\tassert_equal(getmetatable(n), Node)\n\t\t\t\t\tassert_not_nil(map[n._y] and map[n._y][n._x])\n\t\t\t\t\tassert_nil(record[n])\n\t\t\t\t\trecord[n] = true\n\t\t\t\tend\n\t\t\tend)\n\t\t\n\tend)\t\t\n\t\nend)"
  },
  {
    "path": "specs/heuristics_specs.lua",
    "content": "context('Module Heuristics', function()\n\tlocal H, Node\n\t\n\tbefore(function()\n\t\tH = require ('jumper.core.heuristics')\n\t\tNode = require ('jumper.core.node')\n  end)\n\t\n  context('MANHATTAN distance', function()\n\t\n    test('is a function',function()\n\t\t\tassert_type(H.MANHATTAN, 'function')\n    end)\n\t\n\t\ttest('evaluates as |dx|+|dy|', function()\n\t\t\tassert_equal(H.MANHATTAN(Node(0,0), Node(0,0)), 0)\n\t\t\tassert_equal(H.MANHATTAN(Node(1,1), Node(1,3)), 2)\n\t\t\tassert_equal(H.MANHATTAN(Node(0,0), Node(2,1)), 3)\n\t\tend)\n\t\t\n\t\ttest('calling the function with one arg raises an error', function()\n\t\t\tassert_error(pcall(H.MANHATTAN,Node(0,0)))\t\n\t\tend)\t\n\t\t\n\t\ttest('calling the function with no args raises an error', function()\n\t\t\tassert_error(pcall(H.MANHATTAN))\n\t\tend)\t\t\n\t\t\n  end)\n\n  context('EUCLIDIAN distance', function()\n\t\n    test('is a function',function()\n\t\t\tassert_type(H.EUCLIDIAN, 'function')\n    end)\n\t\n\t\ttest('evaluates as SQUAREROOT(dx*dx + dy*dy)', function()\n\t\t\tassert_equal(H.EUCLIDIAN(Node(0,0), Node(0,0)), 0)\n\t\t\tassert_equal(H.EUCLIDIAN(Node(0,0), Node(2,2)), math.sqrt(8))\n\t\t\tassert_equal(H.EUCLIDIAN(Node(0,0), Node(5,3)), math.sqrt(34))\t\t\n\t\tend)\n\t\t\n\t\ttest('calling the function with one arg raises an error', function()\n\t\t\tassert_error(pcall(H.EUCLIDIAN,Node(0,0)))\t\n\t\tend)\t\n\t\t\n\t\ttest('calling the function with no args raises an error', function()\n\t\t\tassert_error(pcall(H.EUCLIDIAN))\n\t\tend)\t\t\n\t\t\n  end)\n  \n\tcontext('DIAGONAL distance', function()\n\t\n    test('is a function',function()\n\t\t\tassert_type(H.DIAGONAL, 'function')\n    end)\n\t\n\t\ttest('evaluates as MAX(|dx|+|dy|)', function()\n\t\t\tassert_equal(H.DIAGONAL(Node(0,0), Node(0,0)), 0)\n\t\t\tassert_equal(H.DIAGONAL(Node(0,0), Node(2,2)), 2)\n\t\t\tassert_equal(H.DIAGONAL(Node(0,0), Node(1,2)), 2)\n\t\t\tassert_equal(H.DIAGONAL(Node(0,0), Node(3,1)), 3)\t\n\t\tend)\n\t\t\n\t\ttest('calling the function with one arg raises an error', function()\n\t\t\tassert_error(pcall(H.DIAGONAL,Node(0,0)))\t\n\t\tend)\t\n\t\t\n\t\ttest('calling the function with no args raises an error', function()\n\t\t\tassert_error(pcall(H.DIAGONAL))\n\t\tend)\t\t\n\t\t\n  end)\n\n\tcontext('CARDINTCARD distance', function()\n\t\n    test('is a function',function()\n\t\t\tassert_type(H.CARDINTCARD, 'function')\n    end)\n\t\t\n\t\ttest('evaluates as (SQRT(2)-1)*MIN(|dx|+|dy|)+MAX(|dx|+|dy|)', function()\n\t\t\tassert_equal(H.CARDINTCARD(Node(0,0), Node(0,0)), 0)\n\t\t\tassert_less_than(H.CARDINTCARD(Node(0,0), Node(1,1))-(math.sqrt(2)),1e-6)\n\t\t\tassert_less_than(H.CARDINTCARD(Node(0,0), Node(1,2))-(1+math.sqrt(2)),1e-6)\n\t\t\tassert_less_than(H.CARDINTCARD(Node(0,0), Node(-3,1))-(2+math.sqrt(2)),1e-6)\n\t\t\tassert_less_than(H.CARDINTCARD(Node(0,0), Node(2,2))-(2*math.sqrt(2)),1e-6)\n\t\tend)\n\t\t\n\t\ttest('calling the function with one arg raises an error', function()\n\t\t\tassert_error(pcall(H.CARDINTCARD,Node(0,0)))\t\n\t\tend)\t\n\t\t\n\t\ttest('calling the function with no args raises an error', function()\n\t\t\tassert_error(pcall(H.CARDINTCARD))\n\t\tend)\t\t\n\t\t\n  end)\n\t\nend)"
  },
  {
    "path": "specs/node_specs.lua",
    "content": "context('Module Node', function()\n\tlocal Node\n\t\n\tbefore(function()\n\t\tNode = require ('jumper.core.node')\n  end)\n\t\n  context('The Node Class', function()\n\t\n    test('Node:new() or Node() returns a Node object',function()\n\t\t\tassert_equal(getmetatable(Node:new(0,0)),Node)\n\t\t\tassert_equal(getmetatable(Node(0,0)),Node)\n    end)\n\t\n\t\ttest('A Node has x and y attributes', function()\n\t\t\tlocal node = Node:new(1,3)\n\t\t\tassert_equal(node._x, 1)\n\t\t\tassert_equal(node._y, 3)\n\t\tend)\n\t\t\n\t\ttest('x and y attributes can be retrieved through methods', function()\n\t\t\tlocal node = Node:new(5,6)\n\t\t\tassert_equal(node:getX(), 5)\n\t\t\tassert_equal(node:getY(), 6)\n\t\t\t\n\t\t\tlocal x, y = node:getPos()\n\t\t\tassert_equal(x, 5)\n\t\t\tassert_equal(y, 6)\n\t\tend)\t\t\n\t\t\n\t\ttest('Nodes can be compared, if they both have an F-cost', function()\n\t\t  local nodeA, nodeB = Node(1,2), Node(1,2)\n\t\t\tnodeA._f, nodeB._f = 1, 2\n\t\t\tassert_less_than(nodeA, nodeB)\n\t\t\t\n\t\t\tnodeA._f = 3\n\t\t\tassert_less_than(nodeB, nodeA)\n\t\tend)\t\n\t\t\n  end)\n\nend)"
  },
  {
    "path": "specs/path_specs.lua",
    "content": "context('Module Path', function()\n\tlocal Path, Node\n\t\n\tbefore(function()\n\t\tPath = require ('jumper.core.path')\n\t\tNode = require ('jumper.core.node')\n  end)\n\t\n  context('The Path Class', function()\n\t\n    test('Path:new() or Path() returns a Path object',function()\n\t\t\tassert_equal(getmetatable(Path:new()),Path)\n\t\t\tassert_equal(getmetatable(Path()),Path)\n    end)\n\t\t\n    test('Path:iter() iterates on nodes forming the path',function()\n\t\t\tlocal p = Path()\n\t\t\tfor i = 1,10 do p._nodes[#p._nodes+1] = Node(i,i) end\n\t\t\t\n\t\t\tlocal i = 0\n\t\t\tfor node, count in p:iter() do\n\t\t\t\ti = i+1\n\t\t\t\tassert_equal(getmetatable(node), Node)\n\t\t\t\tassert_equal(node._x, i)\n\t\t\t\tassert_equal(node._y, i)\n\t\t\t\tassert_equal(count, i)\n\t\t\tend\n    end)\t\t\n\t\t\n\t\ttest('Path:iter() is aliased as Path:nodes()',function()\n\t\t\tassert_equal(Path.iter, Path.nodes)\n\t\tend)\n\t\t\n\t\ttest('Path:getLength() returns the length of the path', function()\n\t\t\tlocal p = Path()\n\t\t\tfor i = 1,10 do p._nodes[#p._nodes+1] = Node(i,0) end\n\t\t\tassert_equal(p:getLength(),9)\n\t\t\t\n\t\t\tp = Path()\n\t\t\tfor j = 1,10 do p._nodes[#p._nodes+1] = Node(0,j) end\n\t\t\tassert_equal(p:getLength(),9)\n\n\t\t\tp = Path()\n\t\t\tfor i = 1,10 do p._nodes[#p._nodes+1] = Node(i,i) end\n\t\t\tassert_less_than(p:getLength()-9*math.sqrt(2),1e-6)\t\t\t\n\t\tend)\n\t\t\n\t\ttest('Path:fill() interpolates a path', function()\n\t\t\tlocal p = Path()\n\t\t\tfor i = 1,9,2 do p._nodes[#p._nodes+1] = Node(i,i) end\n\t\t\tp._grid = {getNodeAt = function(self,x,y) return {_x = x, _y = y} end}\n\t\t\tp:fill()\n\t\t\t\n\t\t\tlocal i = 0\n\t\t\tfor node, count in p:iter() do\n\t\t\t\ti = i+1\n\t\t\t\tassert_equal(node._x, i)\n\t\t\t\tassert_equal(node._y, i)\n\t\t\t\tassert_equal(count, i)\n\t\t\tend\t\t\t\n\t\t\t\n\t\tend)\n\t\t\n\t\ttest('Interpolation does not affect the total path length', function()\n\t\t\tlocal p = Path()\n\t\t\tfor i = 1,10,3 do p._nodes[#p._nodes+1] = Node(i,i) end\n\t\t\tlocal len = p:getLength()\n\t\t\tp._grid = {getNodeAt = function(self,x,y) return {_x = x, _y = y} end}\t\t\t\n\t\t\tp:fill()\n\t\t\t\n\t\t\tassert_less_than(p:getLength()-len,1e-6)\t\t\t\n\t\tend)\t\t\n\n\t\ttest('Path:filter() compresses a path', function()\n\t\t\tlocal p = Path()\n\t\t\tfor i = 1,10 do p._nodes[#p._nodes+1] = Node(i,i) end\n\t\t\tp:filter()\n\t\t\t\n\t\t\tassert_equal(p._nodes[1]._x,1)\n\t\t\tassert_equal(p._nodes[1]._y,1)\n\t\t\tassert_equal(p._nodes[2]._x,10)\n\t\t\tassert_equal(p._nodes[2]._y,10)\n\t\t\tfor i = 3,10 do\n\t\t\t\tassert_nil(p._nodes[i])\n\t\t\tend\n\t\t\t\n\t\tend)\n\n\t\ttest('Compression does not affect the total path length', function()\n\t\t\tlocal p = Path()\n\t\t\tfor i = 1,10 do p._nodes[#p._nodes+1] = Node(i,i) end\n\t\t\tlocal len = p:getLength()\n\t\t\tp:fill()\n\t\t\t\n\t\t\tassert_less_than(p:getLength()-len,1e-6)\t\t\t\n\t\tend)\t\t\n\t\t\n  end)\n\nend)"
  },
  {
    "path": "specs/pathfinder_specs.lua",
    "content": "context('Module Pathfinder', function()\n\tlocal PF, H, Grid, Path, map, grid\n\t\n\tbefore(function()\n\t\tPF = require ('jumper.pathfinder')\n\t\tGrid = require ('jumper.grid')\n\t\tH = require ('jumper.core.heuristics')\n\t\tPath = require ('jumper.core.path')\n\t\tmap = {{0,0,0},{0,0,0},{0,0,0}}\n\t\tgrid = Grid(map)\n  end)\n\t\n  context('Pathfinder:new() or Pathfinder()', function()\n\t\t\n\t\ttest('Inits a new Pathfinder object', function()\n\t\t\tassert_equal(getmetatable(PF(grid, 'ASTAR')), PF)\n\t\t\tassert_equal(getmetatable(PF:new(grid, 'ASTAR')), PF)\n\t\tend)\n\t\t\n\t\ttest('First arg is a grid object', function()\n\t\t\tassert_error(pcall(PF, PF))\n\t\t\tassert_error(pcall(PF, PF, map))\n\t\t\tassert_equal(getmetatable(PF(grid)), PF)\n\t\tend)\n\t\t\n\t\ttest('Second arg, when given must be a valid finderName', function()\n\t\t\tassert_error(pcall(PF, PF, grid, 'finder'))\n\t\t\tfor i, finder in ipairs(PF:getFinders()) do\n\t\t\t\tassert_equal(getmetatable(PF(grid, finder)), PF)\n\t\t\tend\n\t\tend)\n\t\t\n\t\ttest('Defaults to \\'ASTAR\\' when not given', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_equal(getmetatable(pf), PF)\n\t\t\tassert_equal(pf:getFinder(), 'ASTAR')\n\t\tend)\n\t\t\n\t\ttest('Third arg walkable can be a string, function, int or nil', function()\n\t\t\tassert_equal(getmetatable(PF(grid, 'ASTAR', 'A')), PF)\n\t\t\tassert_equal(getmetatable(PF(grid, 'ASTAR', function() end)), PF)\n\t\t\tassert_equal(getmetatable(PF(grid, 'ASTAR', 1)), PF)\n\t\t\tassert_equal(getmetatable(PF(grid, 'ASTAR', nil)), PF)\n\t\t\tassert_error(pcall(PF, PF, grid, 'ASTAR', 2.2))\n\t\t\tassert_error(pcall(PF, PF, grid, 'ASTAR', {}))\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:getGrid()', function()\n\t\t\n\t\ttest('returns the grid object used by the Pathfinder', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_equal(pf:getGrid(), grid)\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:setGrid()', function()\n\t\n\t\ttest('Sets the grid object on which the Pathfinder performs', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tlocal newGrid = Grid('00000\\n00000')\n\t\t\t\n\t\t\tassert_equal(pf:getGrid(), grid)\n\t\t\tpf:setGrid(newGrid)\n\t\t\tassert_equal(pf:getGrid(), newGrid)\n\t\tend)\n\t\t\n\t\ttest('passing nil raises an error', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_error(pcall(pf.setGrid, pf, nil))\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:getWalkable()', function()\n\t\n\t\ttest('returns the walkable parameter', function()\n\t\t\tlocal pf = PF(grid, 'ASTAR', 1)\n\t\t\tassert_equal(pf:getWalkable(), 1)\n\t\tend)\n\t\t\n\t\ttest('is nil when not given', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_nil(pf:getWalkable())\t\t\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:setWalkable()', function()\n\t\n\t\ttest('sets the string, function, nil or int walkable value', function()\n\t\t\tlocal pf = PF(grid, 'ASTAR')\n\t\t\tassert_nil(pf:getWalkable())\n\t\t\t\n\t\t\tpf:setWalkable('A')\n\t\t\tassert_equal(pf:getWalkable(), 'A')\n\t\t\t\n\t\t\tpf:setWalkable(2)\n\t\t\tassert_equal(pf:getWalkable(), 2)\n\t\t\t\n\t\t\tlocal f = function() end\n\t\t\tpf:setWalkable(f)\n\t\t\tassert_equal(pf:getWalkable(), f)\n\t\tend)\n\t\t\n\t\ttest('is nil when not given', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_nil(pf:getWalkable())\t\t\n\t\tend)\n\t\t\n\t\ttest('raises an error when passed-in value is not a string, int, nil or function', function()\n\t\t\tlocal pf = PF(grid)\t\t\t\n\t\t\tassert_error(pcall(pf.setWalkable, pf, {}))\n\t\t\tassert_error(pcall(pf.setWalkable, pf, 0.4))\n\t\tend)\n\t\t\n\tend)\t\n\t\n\tcontext('Pathfinder:getFinder()', function()\n\t\t\n\t\ttest('returns the finder name used', function()\n\t\t\tlocal pf = PF(grid, 'JPS')\n\t\t\tassert_equal(pf:getFinder(), 'JPS')\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:setFinder()', function()\n\n\t\ttest('sets the finder to be used', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tpf:setFinder('DFS')\n\t\t\tassert_equal(pf:getFinder(), 'DFS')\n\t\tend)\n\t\t\n\t\ttest('Upon init, the default finder, when not given, is \\'ASTAR\\'', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_equal(pf:getFinder(), 'ASTAR')\n\t\tend)\n\n\t\ttest('Passing nil sets \\'ASTAR\\` as the finder if no previous finder was set, is \\'ASTAR\\'', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tpf:setFinder()\n\t\t\tassert_equal(pf:getFinder(), 'ASTAR')\n\t\tend)\n\t\t\n\t\ttest('Passing nil has no effect if a finder was set previously', function()\n\t\t\tlocal pf = PF(grid, 'JPS')\n\t\t\tpf:setFinder()\n\t\t\tassert_equal(pf:getFinder(), 'JPS')\n\t\tend)\t\t\t\n\t\n\tend)\n\t\n\tcontext('Pathfinder:getFinders()', function()\n\t\t\n\t\ttest('returns the list of all existing finders', function()\n\t\t\tlocal fs = PF:getFinders()\n\t\t\tlocal pf = PF(grid)\n\t\t\t\n\t\t\tassert_greater_than(#fs, 0)\n\t\t\tfor i,finder in ipairs(fs) do\n\t\t\t\tpf:setFinder(finder)\n\t\t\t\tassert_equal(pf:getFinder(), finder)\n\t\t\tend\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:getHeuristic()', function()\n\t\t\n\t\ttest('returns the heuristic function used', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_not_nil(pf:getHeuristic())\n\t\tend)\n\t\t\n\t\ttest('default heuristic is \\'MANHATTAN\\'', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_equal(pf:getHeuristic(), H.MANHATTAN)\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:setHeuristic()', function()\n\t\t\n\t\ttest('sets the heuristic function to be used', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tpf:setHeuristic('MANHATTAN')\n\t\t\tassert_equal(pf:getHeuristic(), H.MANHATTAN)\n\t\tend)\n\t\t\n\t\ttest('handles custom heuristic functions', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tlocal f = function() end\n\t\t\tpf:setHeuristic(f)\n\t\t\tassert_equal(pf:getHeuristic(),f)\n\t\tend)\n\t\t\n\t\ttest('passing nil produces an error',function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_error(pcall(pf.setHeuristic, pf))\n\t\tend)\n\t\t\n\tend)\n\n\tcontext('Pathfinder:getHeuristics()', function()\n\t\t\n\t\ttest('returns all available heuristics', function()\n\t\t\tlocal hs = PF:getHeuristics()\n\t\t\tassert_greater_than(#hs, 0)\n\t\t\tlocal pf = PF(grid)\n\t\t\tfor i, heur in ipairs(hs) do\n\t\t\t\tpf:setHeuristic(heur)\n\t\t\t\tassert_equal(pf:getHeuristic(), H[heur])\n\t\t\tend\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:getMode()', function()\n\t\n\t\ttest('returns the actual search mode', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tpf:setMode('DIAGONAL')\n\t\t\tassert_equal(pf:getMode(),'DIAGONAL')\n\t\tend)\n\n\t\ttest('default search mode is  \\'DIAGONAL\\'', function()\n\t\t\tlocal pf = PF(grid)\n\t\t\tassert_equal(pf:getMode(),'DIAGONAL')\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:setMode()', function()\n\t\t\n\t\ttest('sets the search mode', function()\n\t\t\tlocal pf = PF(grid)\t\t\n\t\t\tpf:setMode('ORTHOGONAL')\n\t\t\tassert_equal(pf:getMode(), 'ORTHOGONAL')\n\t\t\tpf:setMode('DIAGONAL')\n\t\t\tassert_equal(pf:getMode(), 'DIAGONAL')\t\n\t\tend)\n\t\t\n\t\ttest('passing nil or any other invalid arg causes an error', function()\n\t\t\tlocal pf = PF(grid)\t\t\n\t\t\t\n\t\t\tassert_error(pcall(pf.setMode, pf))\t\t\n\t\t\tassert_error(pcall(pf.setMode, pf, 'ORTHO'))\t\t\n\t\t\tassert_error(pcall(pf.setMode, pf, function() end))\t\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:getModes()', function()\n\t\t\n\t\ttest('returns all available modes', function()\n\t\t\tlocal ms = PF:getModes()\n\t\t\tassert_equal(#ms, 2)\n\t\t\tlocal pf = PF(grid)\n\t\t\t\n\t\t\tfor i, mode in ipairs(ms) do\n\t\t\t\tpf:setMode(mode)\n\t\t\t\tassert_equal(pf:getMode(),mode)\n\t\t\tend\n\t\tend)\n\t\t\n\tend)\n\t\t\n\tcontext('Pathfinder:setTunnelling()', function()\n\t\t\n\t\ttest('Enables or disables tunnelling feature', function()\n\t\t\tPF:setTunnelling(true)\n\t\t\tassert_true(PF:getTunnelling())\n\t\t\tPF:setTunnelling(false)\n\t\t\tassert_false(PF:getTunnelling())\n\t\tend)\n\t\t\n\t\ttest('Enables or disables tunnelling feature', function()\n\t\t\tPF:setTunnelling(true)\n\t\t\tassert_true(PF:getTunnelling())\n\t\t\tPF:setTunnelling(false)\n\t\t\tassert_false(PF:getTunnelling())\n\t\tend)\n\t\t\n\t\ttest('When on, finder goes through walls heading diagonally', function()\n\t\t\tlocal map = {{0,0,0},{1,0,0},{0,2,0}}\n\t\t\tlocal grid = Grid(map)\n\t\t\tlocal finder = PF(grid, 'ASTAR',0)\n\t\t\tfinder:setTunnelling(true)\n\t\t\tlocal path = finder:getPath(1,3,3,1)\n\t\t\tassert_equal(path._nodes[1]._x,1)\n\t\t\tassert_equal(path._nodes[1]._y,3)\n\t\t\tassert_equal(path._nodes[2]._x,2)\n\t\t\tassert_equal(path._nodes[2]._y,2)\n\t\t\tassert_equal(path._nodes[3]._x,3)\n\t\t\tassert_equal(path._nodes[3]._y,1)\t\t\t\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:getTunnelling()', function()\n\t\t\n\t\ttest('Returns the actual state of tunnelling feature', function()\n\t\t\tassert_false(PF:getTunnelling())\n\t\tend)\n\t\t\n\tend)\n\n\tcontext('Pathfinder:annotateGrid()', function()\n\t\t\n\t\ttest('Calculates clearance for the entire grid', function()\n\t\t\tlocal map = {\n\t\t\t{0,0,0,0,0,0,0,0,0,0},\n\t\t\t{0,0,0,0,0,0,0,0,1,0},\n\t\t\t{0,0,0,0,0,0,0,0,0,0},\n\t\t\t{0,0,0,1,0,0,0,0,0,0},\n\t\t\t{0,0,1,0,0,0,0,0,2,0},\n\t\t\t{0,0,1,1,1,0,0,2,0,0},\n\t\t\t{0,0,0,1,1,0,2,0,0,2},\n\t\t\t{0,0,0,0,1,0,0,0,0,2},\n\t\t\t{0,0,0,0,0,0,0,0,0,0},\n\t\t\t{0,0,0,0,0,0,0,0,0,0}\n\t\t}\n\t\tlocal clearances = {\n\t\t\t{6,6,5,5,4,4,4,3,2,1},\n\t\t\t{6,5,5,4,4,3,3,3,2,1},\n\t\t\t{6,5,4,4,3,3,2,2,2,1},\n\t\t\t{6,5,4,3,3,2,2,1,1,1},\n\t\t\t{6,5,4,3,2,2,1,1,0,1},\n\t\t\t{5,5,4,3,2,1,1,0,1,1},\n\t\t\t{4,4,4,3,2,1,0,2,1,0},\n\t\t\t{3,3,3,3,3,3,3,2,1,0},\n\t\t\t{2,2,2,2,2,2,2,2,2,1},\n\t\t\t{1,1,1,1,1,1,1,1,1,1}\n\t\t}\n\t\tlocal grid = Grid(map)\n\t\tlocal walkable = function(v) return v~=2 end\n\t\tlocal finder = PF(grid, 'ASTAR', walkable)\n\t\tfinder:annotateGrid()\n\t\tfor node in grid:iter() do\n\t\t\tassert_equal(node:getClearance(walkable), clearances[node._y][node._x])\n\t\tend\t\t\t\n\t\tend)\n\t\t\n\tend)\n\n\tcontext('Pathfinder:clearAnnotations()', function()\n\t\t\n\t\ttest('Clears cached clearance values for the entire grid', function()\n\t\t\tlocal map = {{0,1,0},{0,0,0},{1,1,0}}\n\t\t\tlocal grid = Grid(map)\n\t\t\tlocal walkable = 0\n\t\t\tlocal finder = PF(grid, 'ASTAR', walkable)\n\t\t\tfinder:annotateGrid()\n\t\t\tfinder:clearAnnotations()\n\t\t\tfor node in grid:iter() do\n\t\t\t\tassert_nil(node:getClearance(walkable))\n\t\t\tend\t\t\t\n\t\tend)\n\t\t\n\tend)\n\t\n\tcontext('Pathfinder:getPath()', function()\n\t\t\n\t\ttest('returns a path', function()\n\t\t\tlocal pf = PF(grid, 'ASTAR', 0)\n\t\t\tlocal path = pf:getPath(1,1,3,3)\n\t\t\tassert_equal(getmetatable(path), Path)\n\t\tend)\n\t\t\n\t\ttest('start and end locations must exist on the map', function()\n\t\t\tlocal pf = PF(grid, 'ASTAR', 0)\n\t\t\tassert_error(pcall(pf.getPath, pf, 0,0, 3, 3))\n\t\t\tassert_error(pcall(pf.getPath, pf, 1, 1, 4, 4))\n\t\t\tassert_error(pcall(pf.getPath, pf, 0,0, 4, 4))\n\t\tend)\n\t\t\n\t\ttest('goal location must be walkable', function()\n\t\t\tlocal pf = PF(grid, 'ASTAR', 0)\n\t\t\tmap[3][3] = 1\n\t\t\tassert_error(pcall(pf.getPath, pf, 0,0, 3, 3))\n\t\tend)\n\t\t\n\tend)\t\n\t\nend)"
  },
  {
    "path": "version_history.md",
    "content": "#Version history#\n\n##1.8.1 (03/01/2013)\n* Added optionnal `tunneling` feature (not fully compatible with `Jump Point Search` as of now)\n* Fixed path request failure when stepping from an unwalkable location\n* Fixed `getPath()` to keep continuously failing right after an wrong path request\n* Fixed _PATH for compatibility with handheld devices\n* Added handling for nil values pushed into heaps\n* Added `Node` as a syntactic shortcut to `Node:new(...)`\n* Added type & validity checking for grid objects\n* Added type & validity checking for passed-in maps\n* Changed pathfinder initialization args order\n* `PathFinder:setFinder()` now handles nil\n* New implementation of Astar, reused internally for Dijkstra Algorithm\n* Added Telescope specs tests\n* Added Travis-CI validation\n\n##1.8.0 (01/26/2013)\n* Moved the internal `Grid` module at the top level\n* Separated path handling logic from the pathfinder class\n* Added a new `Path` class\n* Moved <tt>Pathfinder:filter</tt> and <tt>Pathfinder:fill</tt> to <tt>Path:filter</tt> and <tt>Path:fill</tt> \n* Changed <tt>Pathfinder:new</tt> args, to handle the explicit choice of a finder.\n* Added <tt>Pathfinder:setGrid</tt> \n* Added <tt>Pathfinder:getGrid</tt> \n* Added <tt>Pathfinder:setWalkable</tt> \n* Added <tt>Pathfinder:getWalkable</tt>\n* Changed <tt>Grid:isWalkableAt</tt> to handle a third-parameter for node walkability testing\n* Added <tt>Grid:getWidth</tt>\n* Added <tt>Grid:getHeight</tt>\n* Added <tt>Grid:getMap</tt>\n* Added <tt>Grid:getNodes</tt>\n* Added <tt>Grid:getNodes</tt>\n* Added <tt>Path:getLength</tt> for the `Path` class, for path length self-evaluation, as it fails with finders not handling heuristics.\n* Added Dijkstra algorithm\n* Added Breadth-First search algorithm\n* Added Depth-First search algorithm\n* Updated README and documentation\n\n##1.7.0 (01/22/13)\n* Added Astar search algorithm, along with Jump Point Search\n* Implemented a common interface for the <tt>Pathfinder</tt> object\n* Added argument type checking on pathfinder initialization\n* Added <tt>Pathfinder:setFinder</tt>\n* Added <tt>Pathfinder:getFinder</tt>\n* Added <tt>Pathfinder:getFinders</tt>\n* Added <tt>Pathfinder:getHeuristics</tt>\n* Added <tt>Pathfinder:getModes</tt>\n* Added <tt>Pathfinder:filter</tt> for path compression\n* Removed <tt>autoFill</tt> feature (<tt>setAutoFill</tt>, <tt>getAutoFill</tt>)\n* Faster heapify method in binary heaps module\n* Updated docs, README, rockspecs\n\n## 1.6.3 (01/19/13)\n* Added <tt>Grid:iter</tt>\n* Added <tt>Grid:each</tt>\n* Added <tt>Grid:eachRange</tt>\n* Added <tt>Grid:imap</tt>\n* Added <tt>Grid:imapRange</tt>\n* Added <tt>Grid:__call</tt>\n* Added <tt>Pathfinder:version</tt>\n* Added path iterator\n* Improved node passability handling\n* Added support for string maps\n* Various code improvements\n* Hardcoded documentation, generation with LDoc\n* Updated README, rockspecs\n\n## 1.6.2 (12/01/12)\n* Third-party lib 30log replaced by an hardocded class system\n* Third-party lib binary-heaps replaced by a lighter implementation\n* Changed initialization pattern : three-args are needed, only the first one is mandatory.\n* Added support for custom heuristics\n* Removed <tt>getDiagonalMoves()</tt> and <tt>setDiagonalMoves()</tt>, replaced by <tt>getMode()</tt> and <tt>setMode()</tt>\n* Internal improvements, reuse data.\n* Updated Readme\n\n## 1.6.1 (11/22/12)\n* Added Cardinal/Intercardinal heuristic\n\n## 1.6.0 (11/05/12)\n* Added specialized grids : preprocessed/postprocessed grids\n* Nodes walkability is no longer stored as an attribute, but computed on the fly with respect to the map passed to init Jumper\n\n##1.5.2.2 (11/02/12)\n* Bugfix on resetting nodes properties (Thanks to Srdjan Marković)\n* Bugfix on path cost return\n\n##1.5.2.1 (10/27/12)\n* Bugfix (Thanks to Srdjan Marković)\n\n##1.5.2 (10/25/12)\n* Fixed \"tunneling\" issue in diagonal-mode\n\n##1.5.1.3 (10/18/12)\n* Third-party 30log requiring enhanced\n* Huge documentation update (See Readme)\n\n##1.5.1.2 (10/17/12) - Fix \n* Bugfix with the previous commit (requiring third-party would not work with Lve2D, now fixed)\n\n##1.5.1.2 (10/16/12)\n* Fix on internal grid width calculation\n* Added path to 30log in package.path\n* Some code cleaning\n\n\n##1.5.1.1 (10/15/12)\n* Smoothing renamed to filling, self-explanatory (See Readme for public interface changes)\n\n##1.5.1 (10/09/12)\n* Fix for pathfinding with no diagonal moves allowed : paths returned looks more \"natural\".\n\n##1.5.0 (10/06/12)\n* Added support for collision maps starting at locations different than (1,1).\n* Heuristic name CHEBYSHEV was removed, now on will use DIAGONAL instead.\n* Changes in Jumper's initialization arguments\n* Various improvements\n* Updated Readme\n\n##1.4.1 (10/04/12)\n* Third-parties are now git submodules.\n* Bugfix with grid reset process\n* Optimized the grid reset process. Successive calls to <tt>pather:getPath()</tt> yield faster.\n* Removed <tt>grid:reset()</tt>\n\n##1.3.3 (10/01/12)\n* Removed useless lines of code\n\n##1.3.2 (09/26/12)\n* Compatibility issue with Gideros : Jumper couldn't be required, due to the way Gideros run projects.\n* Updated Readme\n\n##1.3.1 (09/25/12)\n* Jumper no longer uses internally Lua's <tt>module</tt> function.\n* Global env pollution bugfix\n\n##1.3 (09/25/12)\n* added autoSmooth feature : returned paths can now be automatically smoothered on return\n* <tt>searchPath</tt> renamed to <tt>getPath</tt>\n* Added chaining\n* Slight enhancements in code, making profit of Lua's multiple return values ability\n* Updated Readme\n* Updated demos\n\n##1.2 (08/28/12)\n* Jumper now uses [30log](http://github.com/Yonaba/30log) as its object orientation library\n* Global env pollution when requiring jumper now fixed (See init.lua)\n* Updated Readme\n\n##1.1.1 (08/27/12)\n* Third party updated (Binary_Heaps v1.5)\n* Code cleaning, Fixed indentation\n\n##1.1 (08/01/12)\n* Updated with third-party (with Binary_Heaps ported to 1.4)\n\n##1.0 (06/14/12)\n* Added Path smoother\n* Better handling of straight moves\n* Code cleaning\n\n##0.3 (06/01/12)\n* Bugfix with internal paths calls to third-parties.\n\n##0.2 (05/28/12)\n* Updated third-party libraries (Lua Class System, Binary Heaps)\n* Added version_history.md\n\n##0.1 (05/26/12)\n* Initial release\n\t\t\t\n"
  }
]