memoscan
← all memos

Memo 0x97ebb023…0d922a on Ethereum

console.log("World v.12 © Matto 2022");const levels=64,levelCap=64,mint=4096,side=Math.sqrt(4096),inputPat=/^[lL]{1}[0-9]+$|[tT]{1}[0-9]+$/,voxelSize=10,mapSize=400,generatorURL="https://api.gengames.io/project/chainlife/generator/",tokenURL="https://chainlife.xyz/token/",esoterraURL="https://api.gengames.io/project/chainlife/esoterra/",levelURL="https://api.gengames.io/project/chainlife/level";let singleLevel=-1,singleToken=-1,canvas,record=!1,LevelData;console.log(`Grid: ${side} x ${side} (collection of 4096).`);let levelOf=Array(levelsArray.length);for(let i=0;i<levelsArray.length;i++)levelOf[i]=[],levelOf[i][0]=levelsArray[i].transfer_count+levelsArray[i].level_shift,levelOf[i][0]<0&&(levelOf[i][0]=0),levelOf[i][0]>64&&(levelOf[i][0]=64);let cube=Array(64);for(let z=0;z<=64;z++){cube[z]=Array(side);for(let e=0;e<=side;e++){cube[z][e]=Array(side);for(let l=0;l<=side;l++){let n=e*side+l;levelsArray.length-1>=n?levelOf[n][0]==z?cube[z][e][l]=1:cube[z][e][l]=0:0==z?cube[z][e][l]=.5:cube[z][e][l]=0}}}function setup(){(canvas=createCanvas(windowWidth,windowHeight,WEBGL)).parent("canvas-container"),camera(0,-800,-22.5),describeFeatures()}function describeFeatures(){let e=this.canvas.id;this.dummyDOM=document.getElementById(e).parentNode;let l=`<div id="${e}_Description" role="region" aria-label="${altText="Chainlife is a generative art project that explores two-dimensional cellular automata, and on-chain owner collaboration. It was made by an artist named Matto, and released in 2022. This is a view of the 3d, Chainlife world, where each token is placed on a world-level corresponding to it's token-level. Owners can collaborate by placing their tokens on specific levels to build unique patterns."}"></div>`;this.dummyDOM.querySelector(`#${e}`).innerHTML=l}function keyTyped(){if("\"===key)record=!0,(input=createInput()).position(window.innerWidth/2-80,window.innerHeight/2),(button=createButton("⯈")).position(input.x+input.width,input.y),button.mousePressed(checkInput);else if(keyCode===ENTER||keyCode===RETURN)checkInput();else if(!1==record){if(key=key.toUpperCase(),-1!=singleLevel&&"E"==key){console.log("Preparing seed pattern...");let e=createExport();console.log(`Seed pattern for level ${singleLevel} is:`),console.log(e),saveStrings([`#C Pattern of Chainlife World Level ${singleLevel}`,"x = 64, y = 64, rule = B3/S23",e],`Chainlife-World_level-${singleLevel}`,"rle"),console.log("")}else if(-1!=singleLevel&&"P"==key){console.log("Preparing data...");let l=createExport();console.log(l),window.levelData={level_id:singleLevel,level_seed:l},console.log(`Seed pattern for level ${levelData.level_id} is:`),console.log(levelData.level_seed),console.log(`Opening level ${levelData.level_id} with that seed in a new tab for play.`),window.open("https://api.gengames.io/project/chainlife/level")}else -1!=singleToken&&"G"==key?(console.log(`Opening Chainlife ${singleToken} fullscreen in a new tab.`),window.open("https://api.gengames.io/project/chainlife/generator/"+singleToken)):-1!=singleToken&&"C"==key?(console.log(`Opening Chainlife ${singleToken} page on chainlife.xyz.`),window.open("https://chainlife.xyz/token/"+singleToken)):-1!=singleToken&&"V"==key?(console.log(`Opening Chainlife Esoterra ${singleToken} in a new tab.`),window.open("https://api.gengames.io/project/chainlife/esoterra/"+singleToken)):(singleLevel=-1,singleToken=-1,console.log("Showing all levels."),console.log(""))}}function checkInput(){let e=input.value();if(e=e.toUpperCase(),input.hide(),button.hide(),e.match(inputPat)){let l=parseInt(e.slice(1));"L"==e.slice(0,1)&&l<=64?(singleToken=-1,singleLevel=parseInt(e.slice(1)),console.log(`Only showing level: ${singleLevel}.`)):"T"==e.slice(0,1)&&l<4096&&(singleLevel=levelOf[singleToken=parseInt(e.slice(1))],console.log(`Highlighting token: ${singleToken}, which is on level ${singleLevel}`),console.log("Press 'C' to open this Chainlife."),console.log("Press 'V' to view this Chainlife's Esoterra.")),console.log("Press 'E' to export the seed pattern of this level."),console.log("Press 'P' to play this level as a cellular automata."),console.log("Press any other key to return to world view."),console.log("")}else console.log("Display level by entering 'L'n (n is an integer between 0 and 63), or tokenID by entering 'T'n (n is an integer between 0 and 4095)."),console.log(""),e="";record=!1}function createExport(){let e="";for(let l=0;l<side;l++){0!=l&&(e+="$");for(let n=0;n<side;n++)1!=cube[singleLevel][l][n]?e+="b":e+="o"}return e+"!"}function draw(){stroke("rgba(0,80,80, 1)"),strokeWeight(.5),orbitControl(4,4,.1),background("rgb(240,240,240)");for(let e=-32;e<=32;e++)for(let l=-side/2;l<side/2;l++)for(let n=-side/2;n<side/2;n++){-1==singleLevel?(fill("rgba(0,128,128, 1)"),t()):(singleLevel==e+32?(stroke("rgba(0,80,80, 1)"),fill("rgba(0,128,128, 1)")):(noStroke(),fill("rgba(0,128,128, 0.1)")),t());function t(){cube[e+32][n+side/2][l+side/2]>0&&(push(),translate(-(10*l),-1.5*e*10,-(10*n)),singleToken==(n+side/2)*side+(l+side/2)?(fill("rgba(0,222,222, 1)"),stroke("white")):.5==cube[e+32][n+side/2][l+side/2]&&(stroke("rgba(0,80,80, 0.1)"),noFill()),box(10,10/6,10),pop())}}}