Deploying to gh-pages from @ morten-olsen/bob@bdc2eb3ad7 🚀

This commit is contained in:
morten-olsen
2023-09-06 09:30:01 +00:00
parent d379532f93
commit 2ff77cd5b8
4 changed files with 4965 additions and 0 deletions

4910
assets/index-1d7f1b78.js Normal file

File diff suppressed because one or more lines are too long

40
assets/index-4a90bf6b.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
(function(){"use strict";const x=({node:t})=>!!t.remaining.find(o=>o.start?o.start.max<t.time+t.duration:!1),y=async({node:t,generateId:e,plugins:o})=>{if(x({node:t}))return t.deadEnd=!0,[];const s=await Promise.all(o.map(async i=>i.getMetaNodes?(await i.getMetaNodes(t)).map(n=>({...n,parent:t.id,exploreId:0,id:e()})):[]));return[...t.remaining.filter(i=>!o.some(n=>n.isPlanable&&!n.isPlanable(t,i))).map(i=>{var m;const n=t.remaining.map(d=>d===i?{...d,count:(d.count||1)-1}:d).filter(d=>d.count!==0),u=Math.max(t.time+t.duration,((m=i.start)==null?void 0:m.min)||0);return{...t,type:"planable",exploreId:0,id:e(),score:t.score+i.score,planable:i.id,time:u,duration:i.duration,remaining:n,completed:n.length===0,parent:t.id}}),...s.flat()]},w=()=>{let t=0;return()=>(t+=1,t.toString())},N=async({location:t,time:e,planables:o,plugins:r,heuristic:s,onUpdated:c})=>{const g=w();let i=1;const l={id:g(),type:"root",score:0,parent:null,duration:0,time:e,location:t,exploreId:0,remaining:o},n=[l],u=[l],m=[],d=()=>{const b=Math.max(...u.map(f=>f.score)),p=u.find(f=>f.score===b);if(!p)throw new Error("No highest score node");return u.splice(u.indexOf(p),1),p};for(;u.length>0;){const b=d();b.exploreId=i++;const p=await y({node:b,generateId:g,plugins:r});if(n.push(...p),m.push(...p.filter(f=>f.remaining.length===0)),u.push(...p.filter(f=>f.remaining.length>0)),s&&s({root:l,nodes:n,completed:m,planables:o}))break;c&&c({root:l,nodes:n,completed:m,planables:o})}return{root:l,nodes:n,completed:m,planables:o}},k={transport:({getTravelTime:t})=>({getMetaNodes:async e=>{const o=e.type!=="travel"&&[...new Set(e.remaining.map(s=>{var c;return(c=s.attributes)==null?void 0:c.locations}).flat())].filter(s=>s!==e.location).filter(Boolean).map(s=>s)||[];return await Promise.all(o.map(async s=>{const c=await t(e.location,s);return{...e,type:"travel",planable:void 0,location:s,exploreId:0,score:e.score-20,time:e.time+e.duration,duration:c,parent:e.id}}))},isPlanable:(e,o)=>{var r,s;return!((r=o.attributes)!=null&&r.locations&&!((s=o.attributes)!=null&&s.locations.includes(e.location)))}})},I=t=>{self.addEventListener("message",e=>{const{action:o,vars:r={},id:s}=e.data;(async()=>{const g=performance.now();try{const i=await t[o](r),n=performance.now()-g;self.postMessage({type:"output",payload:i,id:s,duration:n})}catch(i){self.postMessage({type:"error",payload:i,id:s})}})()})};function M(t){let e=t/1e3;const o=e/3600;e=e%3600;const r=e/60;return e=e%60,o+":"+r+":"+e}const v=t=>{const e=t.nodes.map(r=>{let s=`root (${r.location})`;return r.type==="planable"?s=`task: ${r.planable.toString()}`:r.type==="travel"&&(s=`travel->${r.location}`),{id:r.id,label:`${M(r.time)}: ${s}`,data:{type:r.type,exploreId:r.exploreId,completed:r.completed,deadEnd:r.deadEnd}}}),o=t.nodes.filter(r=>r.parent).map(r=>({id:`${r.id}->${r.parent}`,source:r.parent,target:r.id,label:r.score.toFixed(2)}));return{nodes:e,edges:o,result:t}},h=1e3*60,a=1e3*60*60,T=async()=>30*h;I({realistic:async()=>{const t=await N({location:"home",time:0,heuristic:({completed:e})=>e.length>=3,plugins:[k.transport({getTravelTime:T})],planables:[{id:"Brush teeth",duration:2*h,start:{min:7*a,max:8*a},attributes:{locations:["home"]},score:1},{id:"Drop off kids",duration:30*h,attributes:{locations:["daycare"]},score:1,start:{min:7*a,max:9*a}},{id:"Pickup the kids",duration:30*h,attributes:{locations:["daycare"]},score:1,start:{min:15*a,max:15.5*a}},{id:"Eat breakfast",duration:15*h,start:{min:7*a,max:9*a},attributes:{locations:["home"]},score:1},{id:"Do work",duration:1*a,count:5,attributes:{locations:["work"]},score:10,start:{min:8*a,max:18*a}},{id:"Read book",duration:.5*a,attributes:{locations:["home","work"]},score:3,count:2,start:{min:8*a,max:22*a}},{id:"Meditate",duration:10*h,score:1,attributes:{},start:{min:8*a,max:22*a}},{id:"Meeting 1",duration:1*a,attributes:{locations:["work","work"]},score:10,start:{min:10*a,max:10*a}},{id:"Meeting 2",duration:1*a,attributes:{locations:["work","work"]},score:10,start:{min:12*a,max:12*a}},{id:"Play playstation",duration:1*a,attributes:{locations:["home"]},score:10,start:{min:16*a,max:24*a}}]});return v(t)}})})();