Skip to content

Instantly share code, notes, and snippets.

@tiffany352
Created December 29, 2011 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiffany352/1534881 to your computer and use it in GitHub Desktop.
Save tiffany352/1534881 to your computer and use it in GitHub Desktop.
function getCost(A,B)
return (A-B).magnitude();
end
while true
local point = getPosition();
local points = {
point+vec2i( 1, 0),
point+vec2i( 0, 1),
point+vec2i( 1, 1),
point+vec2i(-1, 0),
point+vec2i( 0,-1),
point+vec2i(-1,-1),
point+vec2i( 1,-1),
point+vec2i(-1, 1)
};
local a={};
for i=1,#points do
a[getCost(points[i],point)] = points[i];
end
points = talbe.sort(points);
moveToPoint(points[1]);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment