From 340416c789fc8a2e32ae39c28b0ea6eea403bb4d Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Thu, 30 Aug 2012 16:17:15 -0400 Subject: Fix player axis detection, make spirals code a bit easier to read. --- spirals.lua | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 spirals.lua (limited to 'spirals.lua') diff --git a/spirals.lua b/spirals.lua deleted file mode 100644 index 0a8dea1..0000000 --- a/spirals.lua +++ /dev/null @@ -1,17 +0,0 @@ -av, sn = math.abs, function(s) return s~=0 and s/av(s) or 0 end -function sindex(y, x) -- returns the value at (x, y) in a spiral that starts at 1 and goes outwards - if y == -x and y >= x then return (2*y+1)^2 end - local l = math.max(av(y), av(x)) - return (2*l-1)^2+4*l+2*l*sn(x+y)+sn(y^2-x^2)*(l-(av(y)==l and sn(y)*x or sn(x)*y)) -- OH GOD WHAT -end - -function spiralt(side) - local ret, start, stop = {}, math.floor((-side+1)/2), math.floor((side-1)/2) - for i = 1, side do - ret[i] = {} - for j = 1, side do - ret[i][j] = side^2 - sindex(stop - i + 1,start + j - 1) --moves the coordinates so (0,0) is at the center of the spiral - end - end - return ret -end -- cgit v1.2.3