From 4fde8d201b089587aef027627cc5490a3671a884 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Tue, 11 Feb 2020 20:28:08 +0000
Subject: no longer sends `undefined` char with job pad step
---
tools/schedule.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'tools')
diff --git a/tools/schedule.js b/tools/schedule.js
index dfbe854..d8509b8 100644
--- a/tools/schedule.js
+++ b/tools/schedule.js
@@ -104,7 +104,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)){
// Step 5: Iterate through array (high->low), and subtract 1 until the length of output is num.
- if (dequeued.length == num) break;
+ if (dequeued.length == num || job.data.length == 0) break;
job.wacc--;
dequeued.push(job.data.pop());
}
--
cgit
From 5912a13ccb48313da191741931409a11b217d306 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Sat, 22 Feb 2020 22:56:41 +0000
Subject: removed global variable pollution
---
tools/claim.js | 6 +++---
tools/schedule.js | 4 ++--
tools/search.js | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'tools')
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 b18f5e8..f9604bf 100644
--- a/tools/schedule.js
+++ b/tools/schedule.js
@@ -93,7 +93,7 @@ exports.Queue = function(delayms, maxExport, call){
// 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 +102,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]);
}
--
cgit
From 183b38854c8efef2af9e4118060bc2dc4a84befc Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Thu, 26 Mar 2020 03:28:41 +0000
Subject: fixed bug which has been making me tear my hair out
---
tools/schedule.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'tools')
diff --git a/tools/schedule.js b/tools/schedule.js
index f9604bf..c110bb3 100644
--- a/tools/schedule.js
+++ b/tools/schedule.js
@@ -87,7 +87,10 @@ 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].wt*num/weightsum)){
- weightsum -= jobq[0].wt;
+ // 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);
}
--
cgit