From b330b6b3c31e13b1ed423eccc3165f0b3b151176 Mon Sep 17 00:00:00 2001 From: 0C65C3 <79181143+ajimidebug@users.noreply.github.com> Date: Sun, 15 Mar 2026 08:57:05 +0800 Subject: [PATCH] Add files via upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改随机逻辑使得靠前的分组必定被穷尽才会随机到后面分组的任务,实现任务优先级的划分 --- index.html | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 8e9a173..4e96496 100644 --- a/index.html +++ b/index.html @@ -2381,9 +2381,36 @@

📦 数据导出

} const slotsLeft=needed-locked.length; if(free.length0;i--){const j=Math.floor(Math.random()*(i+1));[free[i],free[j]]=[free[j],free[i]];} - const picked=new Set([...locked,...free.slice(0,slotsLeft)].map(({gi,ti})=>`${gi}_${ti}`)); + // Group-based prioritization: prioritize tasks from earlier groups + // 1. Sort free tasks by group index (gi) first + free.sort((a,b)=>a.gi-b.gi); + + // 2. For each group, shuffle tasks within the group + let groupedFree=[]; + let currentGroup=-1; + let groupTasks=[]; + + for(const task of free){ + if(task.gi!==currentGroup){ + if(groupTasks.length>0){ + // Shuffle current group tasks + for(let i=groupTasks.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[groupTasks[i],groupTasks[j]]=[groupTasks[j],groupTasks[i]];} + groupedFree.push(...groupTasks); + groupTasks=[]; + } + currentGroup=task.gi; + } + groupTasks.push(task); + } + + // Add the last group + if(groupTasks.length>0){ + for(let i=groupTasks.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[groupTasks[i],groupTasks[j]]=[groupTasks[j],groupTasks[i]];} + groupedFree.push(...groupTasks); + } + + // 3. Pick tasks in group priority order + const picked=new Set([...locked,...groupedFree.slice(0,slotsLeft)].map(({gi,ti})=>`${gi}_${ti}`)); for(let gi=0;gi