This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__DEBUG_BASIC = true | |
local function NULLFUNC() end | |
local old_print, print = print, NULLFUNC | |
if __DEBUG_BASIC then | |
print = function(...) old_print(("%i"):format(debug.getinfo(2, 'l').currentline), ...) end | |
end | |
local unpack = unpack or table.unpack | |
local class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lua gen.lua --times=25 sample.txt | |
Your pack contains another rucksack containing a shard of bone, some lint and an old bronze ring. | |
Your bag contains a tin of tobacco, an old bronze ring and a tin of tobacco. | |
Your pack contains a tin of tobacco, some lint and another bag containing another pack containing a handkerchief. | |
Your knapsack contains another bag containing an old bronze ring, a tin of tobacco and a tin of tobacco. | |
Your pack contains an old silver ring, a tin of tobacco and a shard of bone. | |
Your purse contains another backpack containing a tin of tobacco, some lint and some lint. | |
Your bag contains some coins, another rucksack containing some coins and some coins. | |
Your bag contains a tin of tobacco, an old silver ring and an old silver ring. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L=love;G=L.graphics;W=267;H=200;F=math.floor;L.load=function()K={0,0,0,0,0,0,0,0,0}end;B={1,3,7,9,5,2,4,6,8}L.mousepressed=function(x,y,a)if C(K,1)or C(K,2)then L.load()else i=F(y/H)*3+F(x/W)+1;if K[i]<1 then K[i]=1;if C(K,1)then return end;for i=1,9 do if K[i]<1 and C(K,2,i)then K[i]=2;return end end;for i=1,9 do if K[i]<1 and C(K,1,i)then K[i]=2;return end end;for i=1,9 do if K[B[i]]<1 then K[B[i]]=2;return end end else for i=1,9 do if K[i]<1 then return end end;L.load()end end end;R=function(b,c,x,y,d)return b[x]==c and b[y]==c and b[d]==c end;C=function(b,c,e)if e then b={unpack(b)}b[e]=c end;return R(b,c,1,2,3)or R(b,c,4,5,6)or R(b,c,7,8,9)or R(b,c,1,4,7)or R(b,c,2,5,8)or R(b,c,3,6,9)or R(b,c,1,5,9)or R(b,c,3,5,7)end;L.draw=function()for i=1,9 do x=(i-1)%3*W;y=F((i-1)/3)*H;G.line(x+W,0,x+W,y+H)G.line(0,y+H,x+W,y+H)if K[i]==1 then G.line(x,y,x+W,y+H)G.line(x,y+H,x+W,y)elseif K[i]==2 then G.circle('line',x+W/2,y+H/2,H/2)end end end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- LFSRs are good for games where you want a random number generator with a short period, | |
-- so that speed runners can device tactics to control the RNG's state. | |
-- Otherwise they're a bit of an obsolete piece of tech. | |
-- See: https://en.wikipedia.org/wiki/Linear-feedback_shift_register | |
-- LFSRs work by shifting all of the bits to the right by one, and using the shifted | |
-- out bit to XOR in at specific taps. Another way to put it is that they first check | |
-- if the state is odd, then divides by two, and if it was odd, Exclusive-Ors in a value. | |
-- The bit shifted out is suitably random. Want more bits, cycle the generator more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// object containing the call and parameters, and optionally context | |
function tail_call() { | |
this.params = Array.prototype.slice.call(arguments); | |
this.fn = this.params.shift(); | |
} | |
tail_call.prototype.self = function (context) { | |
this.that = context; | |
return this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preamble = [=[ | |
local p, d = 1, {} | |
function g() return d[p] or 0 end | |
function s(v) d[p] = v end | |
function o() io.write(string.char(g())) end | |
function i() s(string.byte(io.read(1))) end | |
]=] | |
subst = { | |
['>'] = "p=p+1\n", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function abs(x) | |
if x < 0 then | |
return -1 | |
else | |
return 1 | |
end | |
end | |
oper = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Fast options parser | |
-- License: Public Domain | |
-- Can parse --arg=value types | |
-- Anything not --arg or --arg=value are positional types | |
-- Everything is a string, doesn't parse anything for you | |
-- OS/Host usually does the string split for you, so I don't bother. | |
-- Isn't POSIX compliant, because -arg and --arg and ---arg are treated the same. | |
function optparse(...) | |
local cfg = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[=[ | |
Silly little 80s nostalgia game passcode generator. | |
Of course, the JUSTIN BAILEY password was hardcoded in and not decoded, | |
but having a convincing password entry form that works is the piece that | |
makes hard coded passwords all the more magic. | |
The codes do embed an inverse checksum at the end, which means newbies | |
have slightly more math to do in order to hack ur gaems. When you Decode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local complex = { | |
__tostring = function(self) return ("(% .5f % .5fi)"):format(self[1], self[2]) end | |
} | |
local A = -2 * math.pi | |
local function C(t) return setmetatable(t, complex) end | |
local function cexp(x) | |
local er = math.exp(x[1]) | |
return C{ er*math.cos(x[2]), er*math.sin(x[2]) } | |
end |
NewerOlder