fix: C1/C2 simulate heights only, off the drawn packing, and skip the gap above 300 pieces (Rodada 5)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m2s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 56s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m2s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 56s
The simulations went through encaixar, so the browser test, which watches the drawn packing, sometimes read a simulated one (failed 1 in 3), and each simulation built the preview's masks: 0,5 s per run with 143 pieces. alturaSimulada applies the same rule (same heights in every mode, checked) in 155 ms; the test wrapper also passes the new mode through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -132,7 +132,7 @@ try{
|
||||
// Observe the actual engine, without replacing its placement or rendering.
|
||||
await evaluate(`(()=>{
|
||||
const original=encaixar;
|
||||
encaixar=(pieces,width)=>{const result=original(pieces,width);
|
||||
encaixar=(pieces,width,...rest)=>{const result=original(pieces,width,...rest);
|
||||
if(pieces.some(p=>p.a))window.lastLayout={altura:result.altura,pos:result.pos.map(p=>({x:p.x,y:p.y,w:p.w,h:p.h,rot:p.rot}))};
|
||||
return result;};
|
||||
window.sendImage=async(type='image/png',drop=false)=>{
|
||||
|
||||
@@ -166,6 +166,20 @@ function desenhaMontagem(area,lista,mts,W,fora,aoTerminar){
|
||||
|
||||
function previaArtes(){ desenhaMontagem($('pArea'), artes, metros, 560); }
|
||||
|
||||
// C1/C2 simulam encaixes que não vão para a tela: só a altura, com a mesma
|
||||
// regra de encaixar (web/packing.js) e sem as máscaras que a prévia desenha,
|
||||
// que custam metade do tempo. A montagem desenhada é a única que passa por
|
||||
// encaixar.
|
||||
function alturaSimulada(cargas,W,modo){
|
||||
if(cargas.some(p=>!Number.isFinite(p.w) || p.w<=0 || p.w>W)) throw new RangeError('largura');
|
||||
if(modo==='forma') return encaixarComMargens(cargas,W).altura;
|
||||
const linhas=encaixarEmLinhas(cargas,W).altura;
|
||||
if(modo==='linhas') return linhas;
|
||||
const forma=encaixarComMargens(cargas,W).altura;
|
||||
return forma<=linhas-GANHO_FORMA_CM ? forma : linhas;
|
||||
}
|
||||
// Acima disso o cálculo do vão pesa no celular e a sobra é pequena.
|
||||
const VAO_MAX_PECAS=300;
|
||||
// C2 · as mesmas peças nas duas formas de encaixar, já na metragem cobrada.
|
||||
// Com as folhas de traço, cada folha arredonda sozinha e a soma tem o mínimo de 1 m.
|
||||
let encaixeAlt=null; // {linhas, forma, alturasLinhas, alturasForma}
|
||||
@@ -176,7 +190,7 @@ function metragemDasAlturas(alturas){
|
||||
}
|
||||
function alternativasDasCargas(grupos){
|
||||
const filme=larguraFilme();
|
||||
const alturas=modo=>grupos.map(cs=>encaixar(cs,filme,modo).altura);
|
||||
const alturas=modo=>grupos.map(cs=>alturaSimulada(cs,filme,modo));
|
||||
const li=alturas('linhas'), fo=alturas('forma');
|
||||
// Em automático cada folha fica pela forma só se ela encurta GANHO_FORMA_CM
|
||||
// (web/packing.js): o botão marcado é o encaixe que está na tela.
|
||||
@@ -217,7 +231,8 @@ async function calculaVao(listas,grupos,versao){
|
||||
// cabe "sem custo" é medido contra a metragem cobrada de verdade.
|
||||
const modo=modoEncaixe;
|
||||
let base;
|
||||
try{ base=grupos.map(cs=>encaixar(cs,larguraFilme(),modo).altura); }catch(e){ return; }
|
||||
if(grupos.reduce((t,cs)=>t+cs.length,0)>VAO_MAX_PECAS) return;
|
||||
try{ base=grupos.map(cs=>alturaSimulada(cs,larguraFilme(),modo)); }catch(e){ return; }
|
||||
const alvo=metragemDasAlturas(base);
|
||||
const cands=artes.filter(a=>(a.q||1)>=1).sort((a,b)=>(b.q||1)-(a.q||1)).slice(0,5);
|
||||
const achados=[];
|
||||
@@ -233,7 +248,7 @@ async function calculaVao(listas,grupos,versao){
|
||||
const lista=listas[gi].map(x=>x===a?{...x,q:q+k}:x);
|
||||
const cargas=await cargasDe(lista);
|
||||
let altura;
|
||||
try{ altura=encaixar(cargas,larguraFilme(),modo).altura; }catch(e){ return Infinity; }
|
||||
try{ altura=alturaSimulada(cargas,larguraFilme(),modo); }catch(e){ return Infinity; }
|
||||
const alturas=base.slice(); alturas[gi]=altura;
|
||||
return metragemDasAlturas(alturas);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user