{"id":988,"date":"2026-11-26T06:11:42","date_gmt":"2026-11-26T06:11:42","guid":{"rendered":"https:\/\/pruebas.escacimat.com\/?page_id=988"},"modified":"2026-11-26T06:43:03","modified_gmt":"2026-11-26T06:43:03","slug":"el-repte-del-cavall","status":"publish","type":"page","link":"https:\/\/escacimat.com\/es\/juga-i-apren\/el-repte-del-cavall\/","title":{"rendered":"El reto del caballo"},"content":{"rendered":"\n<style>\n.ec-games{color:#f4f8ff;margin:35px 0;padding:clamp(16px,3vw,34px);border-radius:24px;background:radial-gradient(ellipse at 10% 5%,#405ca4 0%,transparent 50%),radial-gradient(ellipse at 92% 25%,#235989 0%,transparent 56%),#152443;scroll-margin-top:100px}\n.ec-games h2,.ec-games h3{color:#fff;margin:0 0 12px}.ec-games h2{font-size:clamp(1.45rem,3vw,2.1rem)}\n.ec-game-menu{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-bottom:16px}\n.ec-game-menu>a,.ec-game-menu>div{display:grid;align-content:start;gap:3px;min-width:0;padding:13px;background:#203859;border:1px solid #6280aa;border-radius:14px;color:#fff;text-decoration:none;overflow-wrap:anywhere}\n.ec-game-menu>a:hover{background:#2e4d75}.ec-game-menu span{color:#ffdc8a;font-size:1.7rem;line-height:1.2}.ec-game-menu small{color:#e0eeff;line-height:1.35}\n.ec-games details{background:#10213b;border:1px solid #6583a9;border-radius:12px;margin:8px 0;scroll-margin-top:105px}\n.ec-games summary{padding:12px 15px;cursor:pointer;font-weight:800;color:#fff}.ec-games summary:hover{background:#263f64;border-radius:12px}\n.ec-game-body{padding:0 15px 15px}.ec-game-body>p{margin:4px 0 13px}.ec-game-layout{display:grid;grid-template-columns:minmax(0,400px) minmax(0,1fr);gap:15px;align-items:start;margin-top:12px}\n.ec-game-controls{display:flex;flex-wrap:wrap;align-items:end;gap:9px}.ec-game-controls label{display:grid;gap:3px;font-size:.85rem}\n.ec-games button,.ec-games select{font:inherit}.ec-game-controls button,.ec-game-controls select,.ec-game-stats button{min-height:40px;padding:5px 10px;border:1px solid #9db7d5;border-radius:7px;background:#edF5ff;color:#182e4c;font-weight:700;cursor:pointer}\n.ec-games button[hidden]{display:none}.ec-game-stats{padding:12px;border-radius:10px;background:#203859;min-width:0}.ec-game-stats p{margin:0 0 7px}.ec-game-stats h3{font-size:1rem;margin:13px 0 6px}\n.ec-board,.ec-memory-grid{display:grid;grid-template-columns:repeat(var(--ec-board-size,8),minmax(0,1fr));gap:2px;width:100%;border-radius:9px;overflow:hidden;background:#0c192d;border:2px solid #7896bc}\n.ec-games .ec-cell{display:grid;place-items:center;aspect-ratio:1;min-width:0;padding:0;border:0;border-radius:0;background:#e3efff;color:#152640;font-family:system-ui,'Segoe UI Symbol',sans-serif;font-size:clamp(15px,5vw,39px);line-height:1;cursor:pointer}\n.ec-games .ec-cell.ec-dark{background:#85abdc}.ec-games .ec-cell.ec-void{background:#1b2d46;cursor:default}.ec-games .ec-cell.ec-visited{background:#4e749f}.ec-games .ec-cell.ec-current,.ec-games .ec-cell.ec-matched{background:#ffda86;color:#182b49}.ec-games .ec-cell:focus-visible{outline:3px solid #fa9d21;outline-offset:-3px;z-index:1}\n.ec-memory-grid{--ec-board-size:4;gap:5px;padding:4px}.ec-memory-grid .ec-cell{background:#365783;color:#fff;border-radius:6px}.ec-memory-grid .ec-cell.ec-revealed{background:#dcecff;color:#132c4c}\n.ec-game-resources{display:flex;flex-wrap:wrap;gap:10px 16px;margin-top:15px}.ec-game-resources a{color:#dcecff}\n@media(max-width:720px){.ec-game-menu{grid-template-columns:repeat(2,minmax(0,1fr))}.ec-game-layout{grid-template-columns:minmax(0,1fr)}.ec-games .ec-cell{font-size:clamp(16px,6vw,35px)}}\n<\/style><style>\n#content:has(.ec-solo)>.container.entry-content{max-width:900px}\n.ec-solo.ec-games{container-type:inline-size;margin-top:12px;padding:clamp(14px,3vw,28px)}\n.ec-solo .ec-game-body{padding:0;min-width:0}\n.ec-solo .ec-game-layout{grid-template-columns:minmax(0,1fr);gap:13px}\n.ec-solo .ec-board,.ec-solo .ec-memory-grid{max-width:440px;margin-inline:auto}\n.ec-solo .ec-game-back{display:inline-block;margin-bottom:15px;color:#e2efff;font-weight:700}\n@container (min-width:590px){.ec-solo .ec-game-layout{grid-template-columns:minmax(0,1.65fr) minmax(180px,1fr);align-items:start}.ec-solo .ec-board,.ec-solo .ec-memory-grid{margin-inline:0}}\n<\/style><style>\nbody:has(.ec-solo) .interior-hero{padding-block:clamp(13px,2.5vh,24px);text-align:center}\nbody:has(.ec-solo) .interior-hero .eyebrow{margin-bottom:4px}\nbody:has(.ec-solo) .interior-hero h1{margin:0;font-size:clamp(1.65rem,4vw,2.5rem);line-height:1.15}\n#content:has(.ec-solo)>.container.entry-content{margin-top:clamp(10px,2vh,20px)}\n.ec-solo.ec-games{margin-top:0;padding:clamp(14px,2.5vw,22px)}\n.ec-solo .ec-game-back{margin-bottom:8px}\n.ec-solo .ec-game-layout{width:100%;max-width:720px;margin:10px auto 0;overflow-anchor:none}\n.ec-solo .ec-game-stats [data-restart]{display:block;margin-top:15px}\n.ec-solo .ec-game-stats [data-restart]+h3{margin-top:17px}\n.ec-solo .ec-game-stats [data-message]{min-height:1.55em}\n@container (min-width:590px){.ec-solo .ec-game-layout{grid-template-columns:minmax(0,440px) minmax(180px,1fr);gap:14px}.ec-solo .ec-board,.ec-solo .ec-memory-grid{max-width:clamp(265px,calc(100svh - 320px),440px);margin-inline:auto}}\n<\/style><section class=\"ec-games ec-solo\" id=\"ec-solo-0\" aria-label=\"El repte del cavall\"><nav class=\"ec-game-nav\" aria-label=\"Navegaci\u00f3 entre reptes\"><a class=\"ec-game-back\" href=\"\/juga-i-apren\/#jocs-escacimat\">\u2190 Tots els jocs d\u2019Escacimat<\/a><a class=\"ec-game-next-link\" href=\"https:\/\/escacimat.com\/juga-i-apren\/el-repte-de-les-8-dames\/\">Seg\u00fcent repte <span aria-hidden=\"true\">\u2192<\/span><\/a><\/nav><div id=\"ec-knight\"><div class=\"ec-game-body\">\n<p>Visita totes les caselles clares i blaves. El cavall salta en forma de L. Si tornes a una casella visitada, perds 50 punts.<\/p>\n<div class=\"ec-game-controls\"><label>Tauler <select data-level><option value=\"daily\">Repte del dia<\/option><\/select><\/label><label>Modalitat <select data-mode><option value=\"timer\">Amb temps<\/option><option value=\"practice\">Sense temps<\/option><\/select><\/label><\/div>\n<div class=\"ec-game-layout\"><div class=\"ec-board\" data-board role=\"group\" aria-label=\"Tauler del cavall\"><\/div><div class=\"ec-game-stats\"><p data-progress><\/p><p data-clock><\/p><p data-score><\/p><p data-message role=\"status\"><\/p><button data-restart type=\"button\">Torna a comen\u00e7ar<\/button><h3>R\u00e8cords d\u2019aquest navegador<\/h3><p data-personal><\/p><p data-daily><\/p><button data-next type=\"button\" hidden>Seg\u00fcent nivell \u2192<\/button><\/div><\/div>\n<\/div><\/div><\/section><script>(function(){const root=document.getElementById(\"ec-solo-0\");if(!root)return;\n const playArea=root.querySelector('.ec-game-layout');\n playArea.addEventListener('wheel',function(event){\n   if(!event.ctrlKey&&!event.metaKey)event.preventDefault();\n },{passive:false}); const by=(element,name)=>element.querySelector('[data-'+name+']');\n const cellName=(i,size)=>'abcdefgh'[i%size]+(size-Math.floor(i\/size));\n function cells(board,size,render){\n   board.style.setProperty('--ec-board-size',size);\n   board.replaceChildren(...Array.from({length:size*size},function(_,index){\n     const button=document.createElement('button');\n     button.type='button';button.className='ec-cell';button.dataset.cell=index;\n     if((index%size+Math.floor(index\/size))%2)button.classList.add('ec-dark');\n     render(button,index);\n     return button;\n   }));\n }\n function knob(board,handler){board.addEventListener('click',function(event){const button=event.target.closest('[data-cell]');if(button)handler(Number(button.dataset.cell));});}\n function isJump(a,b,n){return Math.abs(a%n-b%n)*Math.abs(Math.floor(a\/n)-Math.floor(b\/n))===2;}\n function generate(n,start,count,seed){\n   const used=new Set([start]);const path=[start];\n   const all=Array.from({length:n*n},(_,i)=>i);\n   const near=all.map(a=>all.filter(b=>isJump(a,b,n)));\n   function extend(from){\n     if(path.length===count)return true;\n     const options=near[from].filter(x=>!used.has(x)).sort((a,b)=>near[a].filter(x=>!used.has(x)).length-near[b].filter(x=>!used.has(x)).length||((a*11+seed)%23)-((b*11+seed)%23));\n     for(const target of options){used.add(target);path.push(target);if(extend(target))return true;path.pop();used.delete(target);}\n     return false;\n   }\n   return extend(start)?[n,path]:null;\n }\n const levels=[[4,0,6],[4,1,8],[5,0,10],[5,6,12],[5,12,15],[6,0,18],[6,8,21],[6,14,24],[7,8,27],[8,0,32]].map((spec,i)=>generate(...spec,i*3));\n const knight=root.querySelector('#ec-knight'),kb=by(knight,'board'),level=by(knight,'level'),mode=by(knight,'mode');\n levels.forEach(function(_,i){const option=document.createElement('option');option.value=i;option.textContent='Nivell '+(i+1);level.append(option);});\n level.value='0';\n let records={};try{records=JSON.parse(localStorage.getItem('ec-cavall-records')||'{}')||{};}catch(error){}\n let n,allowed,visited,at,repeats,budget,ends,timer,done,won,dayKey,finalSeconds;\n function timeLeft(){if(done)return finalSeconds;return ends?Math.max(0,Math.ceil((ends-Date.now())\/1000)):budget;}\n function points(){return Math.max(0,(visited.size-1)*100-repeats*50+(won?(500+(repeats===0?1000:0)+(mode.value==='timer'?timeLeft()*10:0)):0));}\n function stats(){\n   by(knight,'progress').textContent='Caselles visitades: '+visited.size+' \/ '+allowed.size;\n   by(knight,'clock').textContent=mode.value==='timer'?'Temps: '+timeLeft()+' s':'Sense cron\u00f2metre';\n   by(knight,'score').textContent='Punts: '+points();\n   by(knight,'personal').textContent='Millor marca: '+(records.best||0)+' punts';\n   by(knight,'daily').textContent='Millor marca del repte del dia: '+(records.date===dayKey?records.daily||0:0)+' punts';\n }\n function paintKnight(){\n   cells(kb,n,function(button,i){\n     const active=allowed.has(i);const seen=visited.has(i);\n     button.disabled=!active;button.classList.toggle('ec-void',!active);button.classList.toggle('ec-visited',seen);button.classList.toggle('ec-current',i===at);\n     button.textContent=i===at?'\u265e':'';\n     button.setAttribute('aria-label',cellName(i,n)+(i===at?', cavall':seen?', visitada':''));\n   });\n   stats();\n }\n function resetKnight(){\n   clearInterval(timer);\n   dayKey=new Intl.DateTimeFormat('sv-SE',{timeZone:'Europe\/Madrid'}).format(new Date());\n   const dayNumber=Math.floor(Date.parse(dayKey)\/86400000);\n   const index=level.value==='daily'?Math.abs(dayNumber%levels.length):Number(level.value);\n   const [size,path]=levels[index];n=size;at=path[0];allowed=new Set(path);visited=new Set([at]);repeats=0;budget=25+path.length*5;ends=0;done=false;won=false;\n   by(knight,'message').textContent='Tria la casella del primer salt.';by(knight,'next').hidden=true;paintKnight();\n }\n function finish(wasWon){\n   finalSeconds=timeLeft();done=true;won=wasWon;clearInterval(timer);\n   if(won){\n     by(knight,'message').textContent=repeats===0?'Repte superat! Medalla d\u2019or per una ruta sense repetir.':'Repte superat! Has visitat totes les caselles.';\n     if(mode.value==='timer'){\n       records.best=Math.max(records.best||0,points());\n       if(level.value==='daily'){records.daily=Math.max(records.date===dayKey?records.daily||0:0,points());records.date=dayKey;}\n       try{localStorage.setItem('ec-cavall-records',JSON.stringify(records));}catch(error){}\n     }\n     by(knight,'next').hidden=level.value==='daily'||Number(level.value)>=levels.length-1;\n   }else by(knight,'message').textContent='S\u2019ha acabat el temps. Pots tornar a comen\u00e7ar.';\n   stats();\n }\n knob(kb,function(index){\n   if(done||!allowed.has(index))return;\n   if(ends){if(!timeLeft()){finish(false);return;}}\n   if(!isJump(at,index,n)){by(knight,'message').textContent='Tria un salt en L: dues caselles en una direcci\u00f3 i una de costat.';return;}\n   if(!ends && mode.value==='timer'){ends=Date.now()+budget*1000;timer=setInterval(function(){if(!timeLeft())finish(false);else stats();},250);}\n   const repeated=visited.has(index);if(repeated)repeats++;\n   visited.add(index);at=index;by(knight,'message').textContent=repeated?'Casella repetida: \u221250 punts.':'Bon salt!';\n   if(visited.size===allowed.size)finish(true);\n   paintKnight();kb.querySelector('[data-cell=\"'+index+'\"]').focus();\n });\n by(knight,'restart').addEventListener('click',resetKnight);level.addEventListener('change',resetKnight);mode.addEventListener('change',resetKnight);\n by(knight,'next').addEventListener('click',function(){level.value=Number(level.value)+1;resetKnight();level.focus();});\n resetKnight();\n})();<\/script>\n","protected":false},"excerpt":{"rendered":"<p>\u2190 Tots els jocs d\u2019EscacimatSeg\u00fcent repte \u2192 Visita totes les caselles clares i blaves. El cavall salta en forma de L. Si tornes a una casella visitada, perds 50 punts. Tauler Repte del diaModalitat Amb tempsSense temps Torna a comen\u00e7ar R\u00e8cords d\u2019aquest navegador Seg\u00fcent nivell \u2192<\/p>","protected":false},"author":1,"featured_media":0,"parent":13,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-988","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/pages\/988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/comments?post=988"}],"version-history":[{"count":3,"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/pages\/988\/revisions"}],"predecessor-version":[{"id":1006,"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/pages\/988\/revisions\/1006"}],"up":[{"embeddable":true,"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/escacimat.com\/es\/wp-json\/wp\/v2\/media?parent=988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}