baseScript
Contract variable
within
Slot
0x0000000000000000000000000000000000000000000000000000000000000001 Offset
0 Type
string
Value
let n = 100;let board;let next;let state = 0;let paused = 0;function setup() {board = new Array(n);for (let i = 0; i < n; i++) {board[i] = new Array(n);}next = new Array(n);for (i = 0; i < n; i++) {next[i] = new Array(n);}frameRate(20);createCanvas(500, 500);initalize();}function draw() {background(bg);generate();for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {if(board[i][j] == 0){fill(bg);stroke(bg);} else {let c = lerpColor(color(fg1), color(fg2), board[i][j]);fill(c);stroke(c);}rect(i * 5, j * 5, 5, 5);}}}function initalize() {randomSeed(seed);for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {board[i][j] = rand();next[i][j] = 0;}}}function mouseDragged() {noLoop();if(state == 1){board[floor(mouseX / 5)][floor(mouseY / 5)] = 1;fill(fg2);stroke(bg);rect(floor(mouseX / 5) * 5, floor(mouseY / 5) * 5, 5, 5);}}function mouseReleased() {if(!paused){loop();}}function mousePressed() {if(state == 0){seed++;initalize();}}function keyPressed() {if (keyCode === 32) {if(state == 1){state = 0;initalize();loop();paused = 0;} else {state = 1;for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {board[i][j] = 0;}}loop();paused = 0;}} else if (keyCode == 90) {if(paused){loop();} else {noLoop();}paused = !paused;}}function generate() {for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {next[i][j] = convolution(i, j);}}let temp = board;board = next;next = temp;}function convolution(x, y) {let sum = 0;for (let i = -1; i <= 1; i++) {for (let j = -1; j <= 1; j++) {sum += board[wrap(x+i)][wrap(y+j)] * matrix[i+1][j+1];}}sum = activation(sum);if(sum > 1){return 1;} else if (sum < 0) {return 0;} else {return sum;}}function wrap(x) {if(x == n){return 0;} else if (x == -1){return n-1;} else {return x;}} Size
32 bytes Last txn
Txn hash | Block number | Date | From | Value before | Value after |
---|---|---|---|---|---|
16407932 | -- | "let n = 100;let board;let next;let state = 0;let paused = 0;function setup() {board = new Array(n);for (let i = 0; i < n; i++) {board[i] = new Array(n);}next = new Array(n);for (i = 0; i < n; i++) {next[i] = new Array(n);}frameRate(20);createCanvas(500, 500);initalize();}function draw() {background(bg);generate();for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {if(board[i][j] == 0){fill(bg);stroke(bg);} else {let c = lerpColor(color(fg1), color(fg2), board[i][j]);fill(c);stroke(c);}rect(i * 5, j * 5, 5, 5);}}}function initalize() {randomSeed(seed);for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {board[i][j] = rand();next[i][j] = 0;}}}function mouseDragged() {noLoop();if(state == 1){board[floor(mouseX / 5)][floor(mouseY / 5)] = 1;fill(fg2);stroke(bg);rect(floor(mouseX / 5) * 5, floor(mouseY / 5) * 5, 5, 5);}}function mouseReleased() {if(!paused){loop();}}function mousePressed() {if(state == 0){seed++;initalize();}}function keyPressed() {if (keyCode === 32) {if(state == 1){state = 0;initalize();loop();paused = 0;} else {state = 1;for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {board[i][j] = 0;}}loop();paused = 0;}} else if (keyCode == 90) {if(paused){loop();} else {noLoop();}paused = !paused;}}function generate() {for (let i = 0; i < n; i++) {for (let j = 0; j < n; j++) {next[i][j] = convolution(i, j);}}let temp = board;board = next;next = temp;}function convolution(x, y) {let sum = 0;for (let i = -1; i <= 1; i++) {for (let j = -1; j <= 1; j++) {sum += board[wrap(x+i)][wrap(y+j)] * matrix[i+1][j+1];}}sum = activation(sum);if(sum > 1){return 1;} else if (sum < 0) {return 0;} else {return sum;}}function wrap(x) {if(x == n){return 0;} else if (x == -1){return n-1;} else {return x;}} " |