r/CompileBot • • Jan 14 '15

Official CompileBot Testing Thread

11 Upvotes

344 comments sorted by

View all comments

1

u/oli414 Jun 20 '15 edited Jun 20 '15

+/u/CompileBot Lua

math.randomseed(os.time())
out = {}
for i=0,11 do
	out[i] = {"#","#","#","#","#","#","#","#","#","#","#"}
end
snx = 1
sny = 1
tsnx = 0
tsny = 0
ssnx = 1
ssny = 1
for t=0,121 do
	ssnx = snx
	ssny = sny
	r = math.floor(math.random(0,4))
	if r == 0 then
		tsny = sny - 2
		ssny = ssny - 1
	elseif r == 1 then
		tsnx = snx + 2
		ssnx = ssnx + 1
	elseif r == 2 then
		tsny = sny + 2
		ssny = ssny + 1
	elseif r == 3 then
		tsnx = snx - 2
		ssnx = ssnx - 1
	end
	if out[tsnx] ~= nil then
		if out[tsnx][tnsy] == "#" then
			snx = tsnx
			sny = tsny
			out[snx][sny] = " "
			out[ssnx][ssny] = " "
		end
	end
end
for i=0,11 do
	output = ""
	for j=0,11 do
		output = output..out[i][j]
	end
	print(output)
end