1import{J as F,al as T,ab as _,B as x,y as n,a5 as C,A as w,aw as N,G as le,a6 as oe,d as j,am as G,H as P,aY as $,n as H,z as K,m as se,a4 as ne,x as V,r as re,c as ue,aH as ie}from"./BRmlP7xU.js";import{u as ce}from"./BVT59sr3.js";import{_ as de}from"./C6IXV3VF.js";import{_ as fe}from"./Vt_RF1Q8.js";import{_ as ve}from"./Y4rNzQtG.js";import{h as me,i as pe,j as be}from"./CshGXoZE.js";import{u as _e}from"./DPoMep2H.js";import{u as xe}from"./X5ghqqtO.js";import"./BsvMOEaX.js";import"./D8Y2ukjb.js";import"./B8XgxyKV.js";import"./Bz5BUBp2.js";import"./D_j0JRW0.js";const he={class:"mx-auto max-w-3xl px-4 py-8"},ge={class:"mb-6 text-center"},ye={class:"mt-3 flex items-center justify-center gap-2"},ke={key:0,class:"mb-4 flex items-center justify-center gap-3 rounded-2xl bg-white px-6 py-3 shadow-sm border border-slate-200/80"},we={class:"text-sm font-bold text-slate-700"},Te={key:1,class:"inline-flex items-center gap-1 text-xs text-slate-400"},Ce={class:"relative mx-auto w-fit select-none rounded-3xl bg-[#dcb87a] p-3 shadow-xl shadow-amber-900/20"},Se=["onClick"],Pe={key:0,class:"absolute h-2 w-2 rounded-full bg-[#8b6914]/70"},$e={class:"mt-6 flex justify-center gap-3"},Ae=["disabled"],Me={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm"},Be={class:"mx-4 w-full max-w-sm rounded-3xl bg-white p-8 text-center shadow-2xl"},ze={class:"mb-4 text-6xl"},Ne={class:"mb-2 text-2xl font-bold text-slate-900"},Ve={class:"mb-6 text-sm text-slate-500"},i=15,h=null,v="black",g="white",je=F({__name:"GomokuView",setup(R){const p=T("pve"),{fireSmall:I}=ce(),o=T(Array.from({length:i},()=>Array(i).fill(h))),r=T(v),c=T([]),d=T(null),A=[[0,1],[1,0],[1,1],[1,-1]];function L(e,t,a){for(const[l,f]of A){let u=1;for(let s=1;s<5;s++){const b=e+l*s,m=t+f*s;if(b<0||b>=i||m<0||m>=i)break;if(o.value[b]?.[m]===a)u++;else break}for(let s=1;s<5;s++){const b=e-l*s,m=t-f*s;if(b<0||b>=i||m<0||m>=i)break;if(o.value[b]?.[m]===a)u++;else break}if(u>=5)return!0}return!1}function W(e,t){if(!(d.value||o.value[e][t]!==h)&&!(p.value==="pve"&&r.value!==v)){if(o.value[e][t]=r.value,c.value.push({row:e,col:t,player:r.value}),L(e,t,r.value)){d.value=r.value,ne(()=>I());return}if(D()){d.value="draw";return}r.value=r.value===v?g:v,p.value==="pve"&&r.value===g&&!d.value&&E()}}function Y(){if(c.value.length===0||d.value)return;const e=c.value.pop();if(o.value[e.row][e.col]=h,r.value=e.player,p.value==="pve"&&c.value.length>0){const t=c.value[c.value.length-1];t.player===g&&(o.value[t.row][t.col]=h,r.value=v,c.value.pop())}}const M=T(!1);function E(){d.value||r.value!==g||(M.value=!0,setTimeout(()=>{const e=J();e.move&&(o.value[e.move.row][e.move.col]=g,c.value.push({row:e.move.row,col:e.move.col,player:g}),L(e.move.row,e.move.col,g)?d.value=g:D()?d.value="draw":r.value=v),M.value=!1},300))}function J(){let e=-1/0,t=null;const a=U();for(const{row:l,col:f}of a){const u=Z(l,f);u>e&&(e=u,t={row:l,col:f})}return{score:e,move:t}}function U(){const t=new Set;for(const a of c.value)for(let l=-2;l<=2;l++)for(let f=-2;f<=2;f++){const u=a.row+l,s=a.col+f;u>=0&&u<i&&s>=0&&s<i&&!o.value[u][s]&&t.add(`${u},${s}`)}if(t.size===0){const a=Math.floor(i/2);return[{row:a,col:a}]}return Array.from(t).map(a=>{const[l,f]=a.split(",").map(Number);return{row:l,col:f}})}function Z(e,t){o.value[e][t]=g;const a=O(e,t,g);o.value[e][t]=h,o.value[e][t]=v;const l=O(e,t,v);return o.value[e][t]=h,Math.max(a*1.05,l)}function O(e,t,a){let l=0;for(const[f,u]of A){const s=q(e,t,f,u,a);l+=Q(s.count,s.openEnds)}return l}function q(e,t,a,l,f){let u=1,s=0,b=!1,m=1;for(;;){const y=e+a*m,k=t+l*m;if(y<0||y>=i||k<0||k>=i){b=!0;break}const S=o.value[y][k];if(S===f)u++;else if(S===h){s++;break}else{b=!0;break}m++}for(m=1;;){const y=e-a*m,k=t-l*m;if(y<0||y>=i||k<0||k>=i){b=!0;break}const S=o.value[y][k];if(S===f)u++;else if(S===h){s++;break}else{b=!0;break}m++}return{count:u,openEnds:s,connected:!b&&u>=4}}function Q(e,t,a){return e>=5?2e5:e===4&&t===2?1e5:e===4&&t===1?1e4:e===3&&t===2?5e3:e===3&&t===1?800:e===2&&t===2?300:e===2&&t===1?50:e===1&&t===2?10:e===1&&t===1?2:0}function D(){return o.value.every(e=>e.every(t=>t!==h))}function B(){o.value=Array.from({length:i},()=>Array(i).fill(h)),r.value=v,c.value=[],d.value=null,M.value=!1}function X(){B(),p.value="pve"}function ee(){B(),p.value="pvp"}const z=V(()=>c.value.length>0?c.value[c.value.length-1]:null),te=V(()=>p.value==="pve"?r.value===v?"ä½ çæ£å (é»)":"çµèæèä¸...":r.value===v?"黿£":"ç½æ£"),ae=V(()=>d.value==="draw"?"å¹³å±ï¼":p.value==="pve"?d.value===v?"æåä½ èµ¢äºï¼":"çµèè·èï¼ä¸æ¬¡åæ¥ååï¼":`${d.value===v?"黿£":"ç½æ£"}è·èï¼`);return(e,t)=>(_(),x("div",he,[n("div",ge,[t[0]||(t[0]=n("h1",{class:"text-3xl font-bold tracking-tight text-slate-900"},"äºåæ£",-1)),t[1]||(t[1]=n("p",{class:"mt-1 text-sm text-slate-500"},"äºåè¿çº¿è·è",-1)),n("div",ye,[n("button",{type:"button",class:C(["rounded-full px-4 py-1.5 text-sm font-medium transition-all",p.value==="pve"?"bg-teal-500 text-white shadow-sm":"bg-white text-slate-500 border border-slate-200 hover:bg-slate-50"]),onClick:X}," ð¤ 人æºå¯¹æ ",2),n("button",{type:"button",class:C(["rounded-full px-4 py-1.5 text-sm font-medium transition-all",p.value==="pvp"?"bg-teal-500 text-white shadow-sm":"bg-white text-slate-500 border border-slate-200 hover:bg-slate-50"]),onClick:ee}," ð¥ å人对æ ",2)])]),d.value?w("",!0):(_(),x("div",ke,[p.value==="pvp"?(_(),x("span",{key:0,class:C(["inline-block h-6 w-6 rounded-full shadow-md ring-2",r.value===v?"bg-[#1a1a2e] ring-black/40":"bg-[#f0f0f0] ring-slate-400/60"])},null,2)):w("",!0),n("span",we,N(te.value),1),M.value?(_(),x("span",Te,[...t[2]||(t[2]=[n("span",{class:"inline-block h-2 w-2 rounded-full bg-teal-400 animate-pulse"},null,-1),le(" æèä¸ ",-1)])])):w("",!0)])),n("div",Ce,[n("div",{class:"grid gap-0 overflow-hidden rounded-lg",style:oe([{gridTemplateColumns:`repeat(${i}, minmax(0, 1fr))`},{width:"min(80vw, 540px)","aspect-ratio":"1"}])},[(_(),x(j,null,G(i,a=>(_(),x(j,{key:a},[(_(),x(j,null,G(i,l=>n("button",{key:`${a}-${l}`,type:"button",class:C(["relative flex items-center justify-center transition-colors duration-100",["border border-[#b8944a]/60",(a+l)%2===0?"bg-[#e6c97e]":"bg-[#f0d58a]"]]),onClick:f=>W(a-1,l-1)},[(a===4||a===7||a===12)&&(l===4||l===7||l===12)||a===7&&l===7?(_(),x("span",Pe)):w("",!0),z.value&&z.value.row===a-1&&z.value.col===l-1?(_(),x("span",{key:1,class:C(["absolute z-10 h-2 w-2 rounded-full",z.value.player===v?"bg-red-500":"bg-red-400"])},null,2)):w("",!0),P(H,{name:"stone"},{default:$(()=>
1[o.value[a-1][l-1]?(_(),x("div",{key:0,class:C(["h-[80%] w-[80%] rounded-full shadow-md",o.value[a-1][l-1]===v?"bg-[#1a1a2e] shadow-[0_2px_4px_rgba(0,0,0,0.4),inset_0_-2px_4px_rgba(255,255,255,0.1)]":"bg-[#f0f0f0] shadow-[0_2px_4px_rgba(0,0,0,0.2),inset_0_-2px_4px_rgba(0,0,0,0.05)] ring-1 ring-slate-300/50"])},null,2)):w("",!0)]),_:2},1024)],10,Se)),64))],64))),64))],4)]),n("div",$e,[n("button",{type:"button",class:"rounded-full bg-white px-6 py-2.5 text-sm font-medium text-slate-700 shadow-sm border border-slate-200 transition-all hover:bg-slate-50 hover:shadow-md active:scale-95 disabled:opacity-40 disabled:hover:bg-white",disabled:c.value.length===0,onClick:Y}," â© ææ£ ",8,Ae),n("button",{type:"button",class:"rounded-full bg-teal-500 px-6 py-2.5 text-sm font-semibold text-white shadow-sm transition-all hover:bg-teal-600 hover:shadow-md active:scale-95",onClick:B}," æ°æ¸¸æ ")]),(_(),K(se,{to:"body"},[P(H,{name:"fade"},{default:$(()=>[d.value?(_(),x("div",Me,[n("div",Be,[n("div",ze,N(d.value==="draw"?"ð¤":"ð"),1),n("h2",Ne,N(ae.value),1),n("p",Ve,"å
±èµ°äº "+N(c.value.length)+" ææ£",1),n("button",{type:"button",class:"rounded-full bg-teal-500 px-8 py-3 text-sm font-semibold text-white shadow-md transition-all hover:bg-teal-600 hover:shadow-lg active:scale-95",onClick:B}," 忥ä¸å± ")])])):w("",!0)]),_:1})]))]))}}),Ie=re(je,[["__scopeId","data-v-567df720"]]),Ze=F({__name:"index",setup(R){const p=ue["game/gomoku"];return _e("fun","game/gomoku"),xe(V(()=>({title:be(p),description:pe(p),path:"/fun/game/gomoku",keywords:me(p),ogType:"article"}))),ie({meta:[{name:"theme-color",content:"#0d9488"}]}),(I,o)=>{const r=Ie,c=de,d=fe,A=ve;return _(),K(A,{width:"main",compact:""},{default:$(()=>[P(c,null,{fallback:$(()=>[...o[0]||(o[0]=[n("div",{class:"py-24 text-center text-sm text-slate-500"},"å è½½ä¸...",-1)])]),default:$(()=>[P(r)]),_:1}),P(d,{kind:"fun",slug:"game/gomoku"})]),_:1})}}});
1export{Ze as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.