The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
// Pocket Conservatory: original two-player simultaneous-hand drafting rules.
const setting=(p,id)=>p.settings.find(s=>s.id===id).value;
const component=(p,id)=>p.components.find(c=>c.id===id);
export function score(cards,p){let points=cards.reduce((n,id)=>n+component(p,id).values.points,0);const counts={};for(const id of cards){const group=component(p,id).values.group;counts[group]=(counts[group]??0)+1;}points+=Math.min(counts.water??0,counts.flower??0)*setting(p,'pair_bonus');points+=Object.keys(counts).length*setting(p,'variety_bonus');return points;}
export function initial(p,ctx){const rounds=setting(p,'rounds'),deck=p.components.flatMap(c=>Array(c.quantity).fill(c.id));if(deck.length<rounds*2)throw new Error('Print enough cards to deal both hands.');const shuffled=ctx.shuffle(deck,'deal');return{player:0,round:1,done:false,hands:[shuffled.slice(0,rounds),shuffled.slice(rounds,rounds*2)],tableaux:[[],[]],picked:[false,false]};}
export function legal(s,p){return s.done?[]:s.hands[s.player].map((id,i)=>({id:'draft-'+i,label:'Plant '+component(p,id).name,index:i}));}
export function apply(s,a,p){const n=JSON.parse(JSON.stringify(s)),who=n.player,[card]=n.hands[who].splice(a.index,1);n.tableaux[who].push(card);n.picked[who]=true;if(n.picked.every(Boolean)){if(!n.hands[0].length)n.done=true;else{n.hands.reverse();n.round++;n.picked=[false,false];}n.player=0;}else n.player=1;return n;}
export function observe(s,player,p){return{title:'Round '+s.round+' · Gardener '+(player+1),message:s.done?'Compare your planted gardens.':'Choose one plant, then pass the remaining hand after both gardeners choose.',private:!s.done,scores:s.tableaux.map((cards,i)=>({label:'Gardener '+(i+1),value:score(cards,p)})),zones:[...(!s.done?[{id:'hand',label:'Your hand · choose a plant below',items:s.hands[player].map((id,i)=>({key:'hand-'+i,component:id,action:'draft-'+i}))}]:[]),...s.tableaux.map((cards,i)=>({id:'garden-'+i,label:'Gardener '+(i+1)+' · planted',items:cards.map((id,j)=>({key:i+'-'+j,component:id}))}))]};}
export function outcome(s,p){if(!s.done)return null;const scores=s.tableaux.map(c=>score(c,p)),high=Math.max(...scores),winners=scores.flatMap((n,i)=>n===high?[i]:[]);return{title:winners.length===2?'Both gardens flourish':'Gardener '+(winners[0]+1)+' wins',winners,scores};}
export function validate(s,p){if(p.players!==2||!Number.isInteger(setting(p,'rounds')))return 'This game needs two players and a whole number of cards per hand.';if(!Array.isArray(s.hands)||s.hands.length!==2||!Array.isArray(s.tableaux)||s.tableaux.length!==2)return'Keep both hands and gardens.';if(s.hands.flat().length+s.tableaux.flat().length!==setting(p,'rounds')*2)return'Card conservation failed.';const counts={};for(const id of [...s.hands.flat(),...s.tableaux.flat()]){const c=component(p,id);if(!c)return'Unknown card.';counts[id]=(counts[id]??0)+1;if(counts[id]>c.quantity)return'Too many copies of a card.';}return true;}
export function bot(view,actions){return actions[0].id;}