PointsBuffer = '' -- A string to accumulate points in function AddPoint(x, y, width, erase) PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff)) if width then width = bor(width,0x80) if erase then width = bor(width,0x40) end PointsBuffer = PointsBuffer .. string.char(width) else PointsBuffer = PointsBuffer .. string.char(0) end if #PointsBuffer > 245 then ParseCommand('draw '..PointsBuffer) PointsBuffer = '' end end function FlushPoints() if #PointsBuffer > 0 then ParseCommand('draw '..PointsBuffer) PointsBuffer = '' end end -- next step, try varying the transformations from -- http://to-campos.planetaclix.pt/fractal/graftale.html -- to see if various neat ferns can be generated -- magic values below could then be variable within reasonable ranges function onGameInit() MapGen = 2 TemplateFilter = 0 -- going to use an imaginary huge sheet of paper 500 times larger x = 0 y = 0 -- following are the initial fern magic values -- there are probably variations of these that look good f1xx = 3125 -- 1/.16*500 f2xx = 2273 -- 1/.22*500 f2xy = 2174 -- 1/.23*500 f2xc = 10240 -- 1.6/160*2048*500 f2yy = 2500 -- 1/.2*500 f2yx = 1923 -- 1/.26*500 f3xx = 2083 -- 1/.24*500 f3xy = f2yx f3xc = 2816 -- .44/160*2048*500 f3yy = 3333 -- 1/.15*500 f3yx = 1786 -- 1/.28*500 f4xx = 588 -- 1/.85*500 f4xy = 12500 -- 1/.04*500 f4xc = f2xc f4yy = f4xx f4yx = f4xy for i = 1,10000 do r = GetRandom(100) tx = x*1000 ty = y*1000 if r == 99 then x = div(x,f1xx) y = 0 elseif r > 91 then x = div(tx,f2xx)+div(ty,f2xy)+f2xc y = div(ty,f2yy)-div(tx,f2yx) elseif r > 84 then x = div(tx,f3xx)+div(ty,f3xy)+f3xc y = div(tx,f3yx)-div(ty,f3yy) else x = div(tx,f4xx)-div(ty,f4xy)+f4xc y = div(ty,f4yy)+div(tx,f4yx) end AddPoint(div(x,500),div(y,500),1) end FlushPoints() end