diff options
author | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-18 23:37:08 -0500 |
---|---|---|
committer | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-18 23:37:08 -0500 |
commit | 24e14950fed8f7396253637fb6657c6d6072efa7 (patch) | |
tree | e35adc83e2353205166b3f3b437ef7711dbe72f8 /examples | |
parent | bad2bd5bd1c26e33a902b03ff4670aaa5e9fdc1d (diff) |
finished sparse collector
Diffstat (limited to 'examples')
-rw-r--r-- | examples/jarvis.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js index f31a9ea..ccf1f80 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -28,10 +28,16 @@ main.on('identity', (sender) => { console.log('identity activated'); main.on('tileUpdate', (send, source, tiles) => { if (send == sender) return; - let dim = tilekeys(tiles); - let data = new Space(); data.fromfetch(tiles, [dim[0][0],dim[0][1],dim[0][0],dim[0][1]],conform=false); - console.log(data.print()); - //let data = new Space(); data.fromfetch(tiles, dim); - //data.search - }) -}) + let locs = tilekeys(tiles); + for (let i=0; i<locs.length; i++){ + let loc = locs[i]; + if (read[loc]) clearTimeout(read[loc].timer); + read[loc] = ({ + "timer":setTimeout(()=>{delete read[dim]},30000), + "block":new Space(), + }); + read[loc].block.fromfetch(tiles, [loc[0][0], loc[0][1], loc[1][0], loc[1][1]], conform=false); + // TODO : if any pair or quadruplet of blocks are adjacent, SEARCH THEM! + } + }); +}); |