My 66% rare BBQ receipts cooked with machine
I was trying to make my BBQ cook recipes with machine for a week. Here is the experience what I […]
might not equal 0.0091 US Dollar
I was trying to make my BBQ cook recipes with machine for a week. Here is the experience what I […]
I eat, therefore I am. – A mini recipes generator using neural network. Inspirations ( Could you tell which painting […]
with tone.js (weasel program) http://alpha.editor.p5js.org/Yen168/sketches/HkTNMxWsz
One of my favorite childhood memories is liquid timer. I can play with it for whole afternoon until my mom […]
Cursive script https://alpha.editor.p5js.org/Yen168/sketches/rkn6JxgwM dew http://alpha.editor.p5js.org/Yen168/sketches/BkkpbxgwG
Observation. 1. Use and rewrite this demo. 2. Force is the cause of acceleration. To make Helium-filled balloon float, need […]
My first random walker experience is changing classes demo into self-avoiding walk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
class Walker { constructor() { this.x = width / 2; this.y = height / 2; this.marked = {}; this.marked[this.x, this.y] = 1; } render() { stroke(0); strokeWeight(0); point(this.x, this.y); } check(x, y) { var i = 0; var testHash = {}; testHash[[x - 1, y]] = 1; testHash[[x, y - 1]] = 1; testHash[[x + 1, y]] = 1; testHash[[x, y + 1]] = 1; //console.log('Checking: x='+x+' y='+y); Object.keys(testHash).forEach(function(key, index) { if (testHash.hasOwnProperty(key)) { //console.log(key); i++; } }, testHash); if (i == 4) { return; } } step() { var d = 1; var choice = floor(random(4)); if (choice === 0) { //this.x++; this.x = this.x + d; } else if (choice == 1) { //this.x--; this.x = this.x - d; } else if (choice == 2) { //this.y++; this.y = this.y + d; } else { //this.y--; this.y = this.y - d; } this.x = constrain(this.x, 0, width - 1); this.y = constrain(this.y, 0, height - 1); let val = [this.x, this.y]; if (this.marked.hasOwnProperty(val)) { if (choice === 0) { //this.x++; this.x = this.x - d; } else if (choice == 1) { //this.x--; this.x = this.x + d; } else if (choice == 2) { //this.y++; this.y = this.y - d; } else { //this.y--; this.y = this.y + d; } this.check(this.x, this.y); //this.step(); //console.log(val); } else { this.marked[val] = 1; } } } |
The result was quick and dirty. […]