0,P$8¶ÆÂÿ8ÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3À?""""""""""3333333333333333""""""""""3333333333""""""""""3333333333333333""""""""""3333333333""""""""""3333333333333333""""""""""3333333333""""""""""3333333333333333""""""""""3333333333""""""""""""33333333333333""""""""""33333333""""""""""""33333333333333""""""""""33333333""""""""""""33333333333333""""""""""33333333""""""""""""33333333333333""""""""""33333333""""""""""""""""333333333333""""""3333333333""""""""""""""""""333333333333""""""3333333333""""""""""""""""""333333333333""""""3333333333""""""""""""""""""333333333333""""""3333333333""""""""33333333""3333333333333333333333""""""""33333333""3333333333333333333333""""""""33333333""3333333333333333333333""""""""33333333""3333333333333333333333""""""333333333333333333333333333333333333""""""""""333333333333333333333333333333333333""""""""""333333333333333333333333333333333333""""""""""333333333333333333333333333333333333""""""""""""33333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333""""""""""""""""333333333333333333333333333333333333333333333333""""""""""""""""""333333333333333333333333333333333333333333333333""""""""""""""""""333333333333333333333333333333333333333333333333""""""""""""""""""333333333333333333333333333333333333333333333333""""""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""33333333333333333333333333333333333333333333333333""""""""""""""""3333333333333333333333333333333333333333333333333333333333""""""""""""""""3333333333333333333333333333333333333333333333333333333333""""""""""""""""3333333333333333333333333333333333333333333333333333333333""""""""""""""""3333333333333333333333333333333333333333333333333333333333""""""""""""""3333333333333333333333""""""""33333333333333333333333333333333""""""""""""""3333333333333333333333""""""""33333333333333333333333333333333""""""""""""""3333333333333333333333""""""""33333333333333333333333333333333""""""""""""""3333333333333333333333""""""""33333333333333333333333333333333""""""""33333333333333""""""""""""3333333333333333333333333333""""""""33333333333333""""""""""""3333333333333333333333333333""""""""33333333333333""""""""""""3333333333333333333333333333""""""""33333333333333""""""""""""3333333333333333333333333333""""""333333333333333333""""""33333333333333333333333333""""333333333333333333""""""33333333333333333333333333""""333333333333333333""""""33333333333333333333333333""""333333333333333333""""""33333333333333333333333333""""33333333333333333333""333333333333333333333333333333333333333333""333333333333333333333333333333333333333333""333333333333333333333333333333333333333333""3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333""""""""3333333333333333333333333333333333333333""""""""3333333333333333333333333333333333333333""""""""3333333333333333333333333333333333333333""""""""3333333333333333333333333333333333333333""""""""""""3333333333333333333333333333333333333333""""""""""""3333333333333333333333333333333333333333""""""""""""3333333333333333333333333333333333333333""""""""""""3333333333333333333333333333333333333333""""""33""33""33333333333333333333333333333333""""""33""33""33333333333333333333333333333333""""""33""33""33333333333333333333333333333333""""""33""33""33333333333333333333333333333333""""333333333333333333333333333333333333333333""""333333333333333333333333333333333333333333""""333333333333333333333333333333333333333333""""333333333333333333333333333333333333333333""3333333333333333333333333333333333333333333333""3333333333333333333333333333333333333333333333""3333333333333333333333333333333333333333333333""333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333""""""""""3333""3333333333333333333333333333333333333333333333""""""""""3333""3333333333333333333333333333333333333333333333""""""""""3333""3333333333333333333333333333333333333333333333""""""""""3333""3333333333333333333333333333333333333333333333""""""""""""""""""""""3333333333333333333333333333333333333333333333""""""""""""""""""""""3333333333333333333333333333333333333333333333""""""""""""""""""""""3333333333333333333333333333333333333333333333""""""""""""""""""""""3333333333333333333333333333333333333333""""""""""""""""""""""""""""3333333333333333333333333333333333333333""""""""""""""""""""""""""""3333333333333333333333333333333333333333""""""""""""""""""""""""""""3333333333333333333333333333333333333333""""""""""""""""""""""""""""3333333333333333333333333333333333""""""""""""""""""""""""""""""""33333333333333333333333333333333333333""""""""""""""""""""""""""""""""33333333333333333333333333333333333333""""""""""""""""""""""""""""""""33333333333333333333333333333333333333""""""""""""""""""""""""""""""""333333333333333333333333333333333333""""""""""""""""""""""""""""""""""33333333333333333333333333333333333333""""""""""""""""""""""""""""""""""33333333333333333333333333333333333333""""""""""""""""""""""""""""""""""33333333333333333333333333333333333333""""""""""""""""""""""""""""""""""33333333""333333333333333333333333""""""""""""""""""""""""""""""""""""""""""33333333""333333333333333333333333""""""""""""""""""""""""""""""""""""""""""33333333""333333333333333333333333""""""""""""""""""""""""""""""""""""""""""33333333""333333333333333333333333""""""""""""""""""""""""""""""""""""""""""33333333""""""""3333333333""""""""""""""""""""""""""""""""""""""""""""""""33333333""""""""3333333333""""""""""""""""""""""""""""""""""""""""""""""""33333333""""""""3333333333""""""""""""""""""""""""""""""""""""""""""""""""33333333""""""""3333333333""""""""""""""""""""""""""""""""""""""""""""""""3333333333""""""""""333333333333""""""""""""""""""""""""3333""""""""""""""""""""3333333333""""""""""333333333333""""""""""""""""""""""""3333""""""""""""""""""""3333333333""""""""""333333333333""""""""""""""""""""""""3333""""""""""""""""""""3333333333""""""""""333333333333""""""""""""""""""""""""3333""""""""""""""""""""3333333333""""33333333333333""""""""""""""""""""""3333333333""""""""""""""""33333333""""33333333333333""""""""""""""""""""""3333333333""""""""""""""""33333333""""33333333333333""""""""""""""""""""""3333333333""""""""""""""""33333333""""33333333333333""""""""""""""""""""""3333333333""""""""""""""""3333""""""""333333333333""""""""""""""""""""3333333333333333""""""""""""""""""""""""""333333333333""""""""""""""""""""3333333333333333""""""""""""""""""""""""""333333333333""""""""""""""""""""3333333333333333""""""""""""""""""""""""""333333333333""""""""""""""""""""3333333333333333""""""""""""""""""""""""""33333333333333""""""""""""""""""33333333333333""""""""""""""""""""""""33333333333333""""""""""""""""""33333333333333""""""""""""""""""""""""33333333333333""""""""""""""""""33333333333333""""""""""""""""""""""""33333333333333""""""""""""""""""33333333333333""""""""""""""""""""""""33333333333333""""""""""""""333333333333""""""""""""""33333333333333""""""""""""""333333333333""""""""""""""33333333333333""""""""""""""333333333333""""""""""""""33333333333333""""""""""""""333333333333""""""""""""""33333333333333""""""""""""3333333333""""""""""""""33333333333333""""""""""""3333333333""""""""""""""33333333333333""""""""""""3333333333""""""""""""""33333333333333""""""""""""3333333333""""""þ-- title: Janken Cellular Automata -- author: diguh -- desc: Implementation of RPS cellular automata -- site: https://twitter.com/rhirotom -- license: MIT License (change this to your license of choice) -- version: 0.1 -- script: lua HEIGHT=136 WIDTH=240 CLL=4 MINX=0 MINY=0 MAXX=(WIDTH/CLL)-1 MAXY=(HEIGHT/CLL)-1 RAND=3 do_r=true --1: rock --2: paper --3: scissors --# of janken neighbors that will turn the cell rules={{9,2,9},{9,9,2},{2,9,9}} buffer={} function check(x,y) local nei={0,0,0} local f=pix(x*CLL,y*CLL) for dx=-1,1 do for dy=-1,1 do if dy~=0 or dx~=0 then --trace('dx:'..dx..' '..'dy:'..dy,f) local nx=x+dx if nxMAXX then nx=MINY end local ny=y+dy if nyMAXY then ny=MINY end local n=pix(nx*CLL,ny*CLL) nei[n]=nei[n]+1 end end end local r_f=0 if do_r then r_f=math.random(RAND)-1 end --trace('x:'..x..' y:'..y,2) for i,r in ipairs(rules[f]) do --trace('RPS:'..f) --trace('Nei:'..i..' num:'..nei[i]) if nei[i]>r+r_f then buffer[x][y]=i end end end function setup() cls(1) for x=MINX,MAXX do buffer[x]={} for y=MINY,MAXY do local clr=math.random(3) buffer[x][y]=clr rect(x*CLL,y*CLL,CLL,CLL,clr) end end end setup() function TIC() for x=MINX,MAXX do for y=MINY,MAXY do check(x,y) end end for x=MINX,MAXX do for y=MINY,MAXY do rect(x*CLL,y*CLL,CLL,CLL,buffer[x][y]) end end if btnp(5) then exit() end end