aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/jarvis.js4
-rw-r--r--tools/schedule.js5
2 files changed, 6 insertions, 3 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js
index 1a8137f..7b5c64e 100644
--- a/examples/jarvis.js
+++ b/examples/jarvis.js
@@ -99,14 +99,16 @@ function timect(){
}
function protectArea(send, tiles, locs, id, space, ctrl){
+ let writelist = [];
for (let loc of locs){
let tile = tiles[loc];
// Write diffs from the tile
let diff = space.copy(); // Acts as a window for tile (only see relevant data)
diff.comb(tile, comb.flip(comb.unmask));
diff.comb(tile, comb.sub);
- main.enqueue(diff.towrite())
+ writelist.push(...diff.towrite())
}
+ main.enqueue(writelist);
}
var search = new Space();
diff --git a/tools/schedule.js b/tools/schedule.js
index 526ebe4..3254a24 100644
--- a/tools/schedule.js
+++ b/tools/schedule.js
@@ -33,9 +33,9 @@ exports.Queue = function(delayms, maxExport, call){
let prio = job.prio;
if (!jobs[prio]){
jobs[prio] = [];
- prios.splice(0, Math.abs(bs(prios, prio, (el, ne) => el-ne)), prio); // prios is meant to be sorted least to most, and each job layer is too (by "maximum number of rounds").
+ prios.splice(Math.abs(bs(prios, prio, (el, ne) => el-ne)), 0, prio); // prios is meant to be sorted least to most, and each job layer is too (by "maximum number of rounds").
}
- jobs[prio].splice(0, Math.abs(bs(jobs[prio], job, (el, ne) => el.maxr() - ne.maxr())), job);
+ jobs[prio].splice(Math.abs(bs(jobs[prio], job, (el, ne) => el.maxr() - ne.maxr())), 0, job);
// These were sorted like this so that getNumOrAll could use [0] or [.length-1] or .pop instead of having to re-sort lists repetitively.
this.size += job.data.length;
if (open) this.dequeue();
@@ -87,6 +87,7 @@ 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)){
+ num -= jobq[0].data.length;
weightsum -= jobq[0].wt;
dequeued.push(...jobq.shift().data);
}