diff options
| -rw-r--r-- | examples/jarvis.js | 4 | ||||
| -rw-r--r-- | socket.js | 2 | ||||
| -rw-r--r-- | space.js | 3 | ||||
| -rw-r--r-- | tools/claim.js | 6 | ||||
| -rw-r--r-- | tools/schedule.js | 11 | ||||
| -rw-r--r-- | tools/search.js | 2 | ||||
| -rw-r--r-- | utils/raster.js | 2 | 
7 files changed, 17 insertions, 13 deletions
| diff --git a/examples/jarvis.js b/examples/jarvis.js index 4fc84a0..7268ad2 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -67,8 +67,6 @@ const notifsrc = '\  &   git.hrhr.dev/ywot-clean                  \n\  &   Try `COMMAND` today. Uptime: UPTIME.     \n\  &   Called: JARVISx ~SIGNATURE               \n\ -&   If you have any good bullet art (<100 chars),\n\ -&    please send it to me at hr@hrhr.dev.        \n\                                           '.replace('COMMAND', command).replace('SIGNATURE', sig);  const notifloc = [0, 20];  var minsUp = 0; @@ -147,3 +145,5 @@ function respond(coord, send){    setTimeout(() => {limits.splice(limits.indexOf(send))}, 5*1000);    limits.push(send);  } + +setInterval(()=>{console.log('time ' + new Date().getTime());}, 60*1000); @@ -49,7 +49,7 @@ class Socket extends retryws {      this.fetch = function(coords){ //coords is a list of min/max pairs of y/x coordinate pairs which each describe at most 1000 tiles      //Unchecked for speed -      for (var i=0; i<coords.length; i++){ +      for (let i=0; i<coords.length; i++){          coords[i] = {"minY":coords[i][0][0], "minX":coords[i][0][1], "maxY":coords[i][1][0], "maxX":coords[i][1][1]};        }        this.send( JSON.stringify({ @@ -39,7 +39,7 @@ function Space(){        let cont = chop(tile.content,16);        let read = 0; //line of cont to read        for (let line=0; line<8; line++){ -        curline = line+8*tilerow; +        let curline = line+8*tilerow;          if (conform && incl.includes(line)){            for (let i=0; i<16; i++) this.data[curline].push(' ');          } else { @@ -85,6 +85,7 @@ function Space(){    this.comb = function(other, func){ // other must have a valid .loc. If this.loc null, treated as offset      if (! other.loc) throw "The secondary space must have a valid .loc" +    let offset;      if (this.loc.length == 0) {        offset = [0, 0];        this.loc = other.loc; diff --git a/tools/claim.js b/tools/claim.js index b43417b..5989a8c 100644 --- a/tools/claim.js +++ b/tools/claim.js @@ -25,9 +25,9 @@ module.exports = function(){    this.handle = function(send, tilespaces, locs){      // Because usually tilespaces is small, the inefficiency of an O(nk) rect match is acceptable      for (let id in claims){ -      claim = claims[id]; -      diffspace = {}; -      rellocs = []; +      let claim = claims[id]; +      let diffspace = {}; +      let rellocs = [];        for (let loc of locs){          let tile = tilespaces[loc];          if (ri(claim.area, [vec.tileToChar(loc), vec.tileToChar(vec.add(loc, [1,1]))])){ diff --git a/tools/schedule.js b/tools/schedule.js index d8509b8..c110bb3 100644 --- a/tools/schedule.js +++ b/tools/schedule.js @@ -86,14 +86,17 @@ exports.Queue = function(delayms, maxExport, call){      // Step 2: Start at lowest, and pop all until job.data.length>job.normweight*num (decreasing num as popping and recalc job.normweight). Delete the job.       let weightsum = jobq.map(job => job.wt).reduce((acc, cur)=>acc+cur); -    while (jobq[0] && jobq[0].data.length<(jobq[0].wacc+jobq[0].wt*num/weightsum)){ -      weightsum -= jobq[0].wt; +    while (jobq[0] && jobq[0].data.length<(jobq[0].wt*num/weightsum)){ +      // The second req is SO weird. Think about it this way: for len objs +      // to be pushed, the "odds" of the job getting a push must >= len (pushed +      // len times). But it gets num tries, so the odds*num >= len. +      // The odds are wt/wtsum for each try.        dequeued.push(...jobq.shift().data);      }      // Step 3: Then, pop job.normweight*num//1 elems from remaining, without num decrease or normweight recalc. But keep job.wacc = job.normweight*num%1      let efflen = num - dequeued.length; -    for (job of jobq){ +    for (let job of jobq){        let topop = job.wt*efflen/weightsum;        job.wacc += topop%1;        topop = topop-topop%1; @@ -102,7 +105,7 @@ exports.Queue = function(delayms, maxExport, call){      }      // Step 4: Shallow copy job array, and sort by job.wacc. -    for (job of jobq.slice().sort((el, ne) => el.wacc-ne.wacc)){ +    for (let job of jobq.slice().sort((el, ne) => el.wacc-ne.wacc)){        // Step 5: Iterate through array (high->low), and subtract 1 until the length of output is num.        if (dequeued.length == num || job.data.length == 0) break;        job.wacc--; diff --git a/tools/search.js b/tools/search.js index 78e0ee7..e365214 100644 --- a/tools/search.js +++ b/tools/search.js @@ -78,7 +78,7 @@ function Search(){ // searchBlock should be a Space object.    this.update = function(space){ // Must be a space w/ valid loc; allows overlay of some arbitrary text (in the space) mostly for recording updates from the server without directly cataloguing them      let tiles = raster(space); // Returns a this.tiles-style binding: {'2,-3':Space object} -    for (tile in tiles){ +    for (let tile in tiles){        if (this.tiles[tile]) this.tiles[tile].comb(tiles[tile], comb.flip(comb.add));        else this.add(tile, tiles[tile]);      } diff --git a/utils/raster.js b/utils/raster.js index 1e17838..c1a204b 100644 --- a/utils/raster.js +++ b/utils/raster.js @@ -6,7 +6,7 @@ const vec = require('./vec');  module.exports = function(space){    // just use .subsection    let tiles = {}; -  dim = ms(space).map(coord => vec.charToTile(coord)); +  let dim = ms(space).map(coord => vec.charToTile(coord));    for (let y=dim[0][0]; y<=dim[0][1]; y++) for (let x=dim[1][0]; x<=dim[1][1]; x++){      let tile = tileToChar([y,x]);      tiles[tile] = space.subsection(tile, vec.add(tile, [8,16])); | 
