 
 		distance: distance
 		heuristic: (node) -> distance node, end
-		hash: ({x, y}) -> "#{x};#{y}"
+		hash: posToStr
 
 	aStar opts
 

		start: start
		isEnd: (node) -> node.x is end.x and node.y is end.y
		neighbor: (node) ->
			a = [
				'up', 'down', 'left', 'right'
				'up-left', 'up-right', 'down-left', 'down-right'
			]
			.map (dir) -> vectorMath.add node, direction.parse(dir)
			.filter ({x, y}) ->
				(0 <= x < map.w and 0 <= y < map.h) and
				tileFn map, {x, y}, map.data[y][x]

_ = require 'lodash'
aStar = require 'a-star'

direction = require './direction'
vectorMath = require './vector-math'
{distance} = require './util'

offsets = [
	'up', 'down', 'left', 'right'
	'up-left', 'up-right', 'down-left', 'down-right'
].map (dir) -> direction.parse(dir)

posToStr = ({x, y}) -> "#{x};#{y}"

getNeighbouringTiles = ({x, y}, map, tileFn) ->
	if tileFn?
		result = []

		for {x: i, y: j} in offsets
			pos = {x: x+i, y: y+j}

			if tileFn(map, pos)
				result.push pos

		result

	else offsets.map ({x: i, y: j}) -> {x: x+i, y: y+j}

exports.aStar = (map, start, end, tileFn) ->
	tileFn ?= (map, {x, y}, data) ->
