Skip to content

Instantly share code, notes, and snippets.

/*
A* Pathfinding
*/
function Path(map, start, end) {
// Sets
var open = [],
closed = [];
// Create node for start
@huckfinnaafb
huckfinnaafb / gist:1549077
Created January 2, 2012 02:44
A*pathfinding implementation
/*
A* Pathfinding
*/
function Path(map, start, end) {
// Sets
var open = [],
closed = [];
// Create node for start
$image = array();
$image['acl'] = S3_ACL_PUBLIC;
$image['filename'] = '000-images/agent_photos/'.$this->logged_in_user->id.'.jpg';
$image['contentType'] = image_type_to_mime_type(exif_imagetype($_FILES['photo']['tmp_name']));
$image['body'] = file_get_contents($_FILES['photo']['tmp_name']);
function Foo() {}
Foo.prototype = {
bar: function () {},
baz: function () {},
fiz: function () {}
};
function Foo() {}
Foo.prototype.bar = function () {};
Foo.prototype.baz = function () {};
Foo.bar = function (a, b) { // ... }
function toIndice(vector, graph_width) {
return (vector.y * graph_width) + vector.x;
}
toIndice({x:4, y:2}, 10);
=> 24
function toIndice(vec, gw) {
return ((vec.y) * gw + vec.x);
}
function isUnique(array) {
var uniques = _.uniq(array);
return array.length === uniques.length;
};
function toIndice(vec, graph_width) {
return ((vec.y) * graph_width + vec.x);
}
function allUnique(array) {
var uniques = _.uniq(array);
return array.length === uniques.length;
};
function Foo() {
var pass = true;
if (false) {
pass = false;
} else if (false) {
pass = false;
} else if (false) {
pass = false;
}
Graph.inBounds = function (G, x) {
var vec = x.vector;
return (vec.x < G.w && vec.x >= 0 && vec.y < G.h && vec.y >= 0);
};